-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxt doesn't transpile NPM modules that expose source ES6 / Vue files as default entries #3485
Comments
I'd be interested in a solution as well. Usually putting my Vue plugins up as ES6 and have the same problem (which I often fix with an edit to the webpack config through the As |
With |
This bug-report has been fixed by @manniL.
|
Hi @manniL thanks for fixing it in Also I see https://nuxtjs.org/api/configuration-build#transpile in |
Hey @tim-yao You are right, the You can already switch to Another way to solve the issue in 1.4.X is to extend the webpack config and use |
Thanks @manniL I will check the code for transpile. BTW, I used the way #924 (comment) mentioned, and looks fixed the issue as well. |
@tim-yao I was unsucessful applying the comment in #924 suggests. Whatever I do to the Regex or extends it seams that babel-loeader still ignores me and still sends untranspiled ES6 to the This is my particular setup in nuxt.config.js build: {
extend: function(config) {
const babelLoader = config.module.rules.find((rule) => rule.loader === 'babel-loader')
babelLoader.exclude = /node_modules(?!(\/epic-spinners))/
},
.... The error is the same as above. |
@bmarkovic below is how I implemented at the moment.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
v1.4.0
Reproduction link
https://gist.github.com/bmarkovic/69c802d4eec12073b52a0aa37ee87606
Steps to reproduce
This is easily reproducible by initializing the Nuxt starter with
vue-cli
and addingepic-spinners
which exposessrc/lib.js
i.e. it's ES6 entry point, to the project. One just needs to replacepages/index.vue
with the one in the accompanying Gist.The environment where I got this error:
Linux x64 (Xubuntu 17.10)
What is expected ?
The module described in this actually works with non-SSR Vue. You should be seeing two animated spinning arcs.
What is actually happening?
The following error.
Additional comments?
I have tried to debug and from what I've seen, the entry file gets wrapped in a
function (the signature is seen above) but not transpiled.
Another issue is that the syntax that gets passed on to "eval" (in this case Node's
vm.runInThisCotext
) has imports i.e. untranspiled top-level ES6 wrapped in afunction which wouldn't be correct ES6 even if
vm.runInThisCotext
could interpretit.
All in all the issue is in Webpack configuration which is handled by Nuxt internally.
I understand that even front-end modules should be exposing transpiled versions but
ES6 modules will become more and more commonplace.
The text was updated successfully, but these errors were encountered: