pipe01 / esbuild-plugin-vue3

esbuild plugin for loading Vue 3 SFC files
MIT License
59 stars 13 forks source link

Build errors, no matching export. #2

Closed mikob closed 3 years ago

mikob commented 3 years ago

Thanks for taking initiative with this library! I have SFCs that use <script lang="ts"> and I get this error when trying to build with your plugin:

> sfc-template:/home/mikob/workspace/lipsurf/chrome-extension/src/components/tooltip.vue?type=template:1:36: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "createElementVNode"
    1 │ import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
      ╵                                     ~~~~~~~~~~~~~~~~~~

 > sfc-template:/home/mikob/workspace/lipsurf/chrome-extension/src/components/tooltip.vue?type=template:1:79: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "normalizeClass"
    1 │ import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
      ╵                                                                                ~~~~~~~~~~~~~~

 > sfc-template:/home/mikob/workspace/lipsurf/chrome-extension/src/components/tooltip.vue?type=template:1:139: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "createElementBlock"
    1 │ import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
      ╵                                                                                                                                            ~~~~~~~~~~~~~~~~~~

 > sfc-template:/home/mikob/workspace/lipsurf/chrome-extension/src/components/shortcut-adder.vue?type=template:1:9: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "normalizeClass"
    1 │ import { normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, createTextVNode as _createTextVNode, toDisplayString as _toDisplayString, vModelText as _vModelText, withDirectives as _withDir...
      ╵          ~~~~~~~~~~~~~~

 > sfc-template:/home/mikob/workspace/lipsurf/chrome-extension/src/components/shortcut-adder.vue?type=template:1:44: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "createElementVNode"
    1 │ import { normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, createTextVNode as _createTextVNode, toDisplayString as _toDisplayString, vModelText as _vModelText, withDirectives as _withDir...
      ╵                                             ~~~~~~~~~~~~~~~~~~

 > sfc-template:/home/mikob/workspace/lipsurf/chrome-extension/src/components/shortcut-adder.vue?type=template:1:422: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "createElementBlock"
    1 │ ...Directives as _withDirectives, vModelCheckbox as _vModelCheckbox, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, vShow as _vShow, Transition as _Transition, withModifiers as _withModifiers, createCommentVNode as _createCommentVNo...
pipe01 commented 3 years ago

That's weird, can you post the build configuration?

mikob commented 3 years ago

Nothing too special.

    "vue": "^3.0.11",
    "esbuild": "^0.13.7",
    "esbuild-plugin-vue3": "^0.2.4",
globby
  .sync(["src/modules/shortcut-adder.ts"])
  .map(async (file) => {
    const splitted = file.split(/\.ts|\//);
    const name = splitted[splitted.length - 2];
    const esbuildRes = await esbuild.build({
      entryPoints: [file],
      bundle: true,
      format: 'esm',
      // null-coalescing not supported by node, needed by plugin-base.js module, which is needed by tests
      target: 'es2017',
      write: !IS_PROD,
      minify: IS_PROD,
      watch: options.watch,
      pure: PURE_FUNCS,
      define: {
        'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
        ...transform(featureFlags.FEATURE_FLAGS, (r, val, key) => r[`process.env.${key}`] = typeof process.env[key] !== 'undefined' ? `'${process.env[key]}'` : `'${val}'`),
      },
      loader: {
        '.html': 'text',
        '.svg': 'text',
      },
      plugins: [vuePlugin()],
      outdir: 'package/dist/modules',
    });
mikob commented 3 years ago

Just upgraded to:

vue: 3.2.20 esbuild: 0.13.8

and the problem went away. Will keep trying the plugin out!

pipe01 commented 3 years ago

Glad to hear!

leemoCode commented 1 year ago

really happy to find your point