question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

  • Browser (name & version):
  • vue2-sfc-loader: v0.7.3

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Toilalcommented, Jul 11, 2021

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 .

1reaction
FranckFreiburgercommented, May 15, 2021

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 !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make Vite work with Vue 2 · Issue #305 · vitejs/vite - GitHub
It doesn't work with Vue 2 and vue-template-compiler isn't the right package. So the error is correct. Use Vue 3 and it will...
Read more >
Error : vue-loader requires @vue/compiler-sfc to be present in ...
Looks like you are trying to use vue-loader from Vue 3 in Vue 2 project. Here is a versions I have for Vue...
Read more >
Plugin API - Vite
Virtual modules are a useful scheme that allows you to pass build time information to the source files using normal ESM import syntax....
Read more >
How to Migrate from Vue CLI to Vite - Vue School Blog
Step #1: Updating Dependencies ... The first step to migrating to Vite is to update the dependencies in package.json. We'll need to remove...
Read more >
Single file components | Vue I18n - Intlify
If you are building Vue component or Vue application using single file ... vite: v2-beta or later; @vitejs/plugin-vue: v1.0.4 or later.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found