unplugin / unplugin-vue2-script-setup

💡 Bring `<script setup>` to Vue 2.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

defineProps is not defined with ESbuild

KevinBerthier opened this issue · comments

I moved from webpack to ESbuild but I get ReferenceError: defineProps is not defined

My config is a bit different from the doc :
plugins: [rails(), vuePlugin(), require('unplugin-vue2-script-setup/esbuild').default()],
instead of
plugins: [rails(), vuePlugin(), require('unplugin-vue2-script-setup/esbuild')()],

try plugins: [rails(), require('unplugin-vue2-script-setup/esbuild').default(), vuePlugin(), ],

@xiaoxiangmoe I get :

✘ [ERROR] The JSX syntax extension is not currently enabled

    apps/notification-center/NotificationCenter.vue:1:0:
      1 │ <template>
        ╵ ^

  The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able
  to parse JSX syntax. You can use "loader: { '.js': 'jsx' }" to do that.

Here is my config :

const config = {
  absWorkingDir: path.join(process.cwd(), 'app/javascript'),
  bundle: true,
  chunkNames: 'chunks/[name]-[hash]',
  entryPoints,
  format: 'esm',
  minify: process.env.RAILS_ENV == 'production',
  metafile: true,
  outdir: path.join(process.cwd(), 'app/assets/builds'),
  platform: 'browser',
  plugins: [rails(), require('unplugin-vue2-script-setup/esbuild').default(), vuePlugin()],
  sourcemap: process.env.RAILS_ENV != 'production',
  splitting: true,
  treeShaking: true,
  loader: {
    '.svg': 'dataurl'
  }
}

Can you provide a minimal reproducible repo

@sxzz Can you help to fix this?

@sxzz Can you help to fix this?

OK, I'll check it later.

It seems to be a problem with unplugin or esbuild-vue, I'll try to fix it later.

We need to wait for esbuild to resolve this issue evanw/esbuild#1902

I wrote a plugin esbuild-plugin-transform. You can try this.