FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.03k stars 116 forks source link

Can't build using vue2-sfc-loader ESM with rollup/vite #67

Closed Toilal closed 2 years ago

Toilal commented 3 years ago

Describe the bug

I try to build an app using vue2-sfc-loader (esm) and vite.

It works properly in dev mode, but when building the app, it fails. Vite is building with rollup under the hood, so it may likely be a configuration issue, but I can't understand the following error.

[commonjs] Unexpected token (15:124277) in /home/toilal/projects/OFB-ESTAMP/frontend-vite/node_modules/vue3-sfc-loader/dist/vue2-sfc-loader.esm.js

To Reproduce

Expected behavior

Versions

Additional context

FranckFreiburger commented 3 years ago

using the dev version of vue3-sfc-loader :

  loc: {
    file: '...vue2-sfc-loader.esm.js',
    line: 76715,
    column: 11
  },
  frame: "76713: process.title = 'browser';\n" +
    '76714: process.browser = true;\n' +
    '76715: process.env = {};\n' +
    '                  ^\n' +
    '76716: process.argv = [];\n' +
    "76717: process.version = ''; // empty string to avoid regexp issues",

https://github.com/defunctzombie/node-process/blob/master/browser.js#L157

Maybe rollup tries to replace process.env with another expression that is not suitable for assignment (eg. {} = {}) ?

note that using process.env = {}; somewhere in the code compiled by vite is enough to rise this issue !

Toilal commented 3 years ago

I tried to build from current master, and it seems it fixe the issue. Can you release a new version ?

FranckFreiburger commented 3 years ago

version 0.8.0 has been released.

however, note that "generate TypeScript definition file as a bundle" feature has been temporary disabled because of https://github.com/FranckFreiburger/vue3-sfc-loader/pull/65#issuecomment-841708263

FranckFreiburger commented 2 years ago

I tried to build from current master, and it seems it fixe the issue. Can you release a new version ?

Can I close this issue ?

Toilal commented 2 years ago

Yes, it works now ! Thanks

Le dim. 11 juil. 2021 à 09:21, Franck Freiburger @.***> a écrit :

I tried to build from current master, and it seems it fixe the issue. Can you release a new version ?

Can I close this issue ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FranckFreiburger/vue3-sfc-loader/issues/67#issuecomment-877754197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI4TPREMIQLLMDZ4F6R2UTTXFA53ANCNFSM44YKGS6A .