-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Using transpileDependencies throws runtime error #2637
Comments
You cannot mix commonjs & ES modules in webpack 4. Now that it's a third party dependency, the only way to solve this problem is to let babel take care of the module interop issues, by changing // babel.config.js
module.exports = {
presets: [
["@vue/app", {
modules: "commonjs"
}]
]
}; All your ES module code will be transpiled to commonjs and then pass to webpack for further compilation. |
Looks like that option has been removed, I get this compile error:
|
Using the plugin mentioned in the error message, I get another runtime error:
@sodatea This was not mentioned in Webpack's migration guide from v3 to v4 - could you please cite a source?
My external dependency actually is a CommonJS module already, how would this help me? |
I rewrote my external dep as an ES6 module, and while the runtime error disappears, it is not longer transpiled to es5. To reproduce:
An error is thrown because the fat arrow function in |
Renaming However, rewriting all of my CommonJS deps (most of which I do not control) as es6 modules will be a real pain, especially as some must support both Node.js and the browser. Is that really the only solution? |
(
To add it back, configure it in module.exports = {
chainWebpack: config => config.resolve.extensions.prepend('.mjs')
}
|
Thanks for your help - I fixed up my preset config, but I still get a runtime error:
To reproduce:
However, I think I have found a working solution (from this stackoverflow question). By setting
This appears to work because internally it not only sets
Could you please explain why this works @sodatea, but is not the default behaviour? Thanks. |
Ummm…… After rereading that thread I think my first comment might not be the best solution. Sorry for my oversight. Also, there are several tips on dependencies that needs polyfills in the doc:
Setting In your case it is the helpers that inserts |
Thanks, I'm glad - I didn't want to rely on what felt like a hack of vue-cli's internals. |
fixes CommonJS module transpilation fixes #2637
Just a note for anyone who runs into this - using |
The above answers didn't help me, but setting |
Version
3.0.4
Reproduction link
https://github.com/diachedelic/vue-cli-transpile-dependencies-repro
Node and OS info
Node 8.9.0 / yarn 1.9.4 / MacOS 10.13.6 / Google Chrome 69.0.3497.100 (Official Build) (64-bit)
Steps to reproduce
What is expected?
transpileDependencies
should transpile any listed dependencies to ES5 without compiler warnings or runtime errors.What is actually happening?
I am seeing two distinct runtime errors:
See README.md for full stack traces etc.
I am upgrading a couple of PWAs from their modified vue-cli v2 templates, to use vue-cli v3 (so I don't have to maintain a webpack config). I had dependencies transpiling ok using my own webpack config, and I want to get that behaviour back.
Check out README.md on repro's master branch for a full walkthrough.
The text was updated successfully, but these errors were encountered: