-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Description
Version
3.0.4
Reproduction link
https://github.com/jameswragg/vue-ie-transpile-issue
Node and OS info
node v8.11.3 / npm 6.4.1 / macOS 10.14 (18A391)
Steps to reproduce
npm install
npm run build
transpileDependencies doesn't seem to be working as specified in the docs here:
If the dependency is written in an ES version that your target environments do not support: Add that dependency to the transpileDependencies option in vue.config.js. This would enable both syntax transforms and usage-based polyfill detection for that dependency.
npm run server
This serves up the dist dir on http://localhost:8080. Viewing this bundle on IE 11 for instance fails with missing Symbol polyfills, this is seen in the IE 11 console:
SCRIPT5009: 'Symbol' is undefined
chunk-vendors.3e82079c.js (7,82041)
Installing this polyfill manually reveals more transpiling issues.
What is expected?
Adding the dependency to transpileDependencies in vue.config.js should transpile the dependency, adding any required required polyfills for the environment specified in browserslist
What is actually happening?
Required polyfills are missing.
Manually adding the es6.symbol polyfill to babel.config.js (you can see it commented out in my repro) reveals more transpiling issues that I can only hope would be magically resolved after transpileDependencies is doing what it claims.
Activity
LinusBorg commentedon Oct 29, 2018
Without being able to run this right now:
Since the
file-typedependency doesn't useSymboldirectly, I would assume that it's an indirect dependency of some other feature that would have to be polyfilled, and the polyfill detection of babel's preset-env fails here (which would be a bug in their code).I'll look into what you mean with "more transpiling issues" when I get home.
haoqunjiang commentedon Oct 29, 2018
Well, this is a case that matches the 3rd option here:
This is because the usage of spread operator in
file-typepackage implicitly imports a babel helper called_iterableToArrayafter transpilation, which requiresSymbolpolyfill under the hood.Transpilation issues in other browsers are due to similar reasons.
Cannot assign to read only property 'exports' of object '#<Object>'is caused by the mixed usage ofimport(implicitly added by babel to import helpers) andmodule.exports.haoqunjiang commentedon Oct 29, 2018
I have to admit, even for experienced developers, it is not easy to identify such cases at first glance.
But I'm not sure what we can do to improve this situation or how to better document this behavior.
Contributions are welcome.
klarkc commentedon Nov 6, 2018
I am having some issue that might be related, I am getting regeneratorRuntime undefinition on browser for
@wordpress/api-fetchpackage which requires ES2015+ environment. I've added@wordpress/api-fetchin transpileDependencies but it seems ineffective.The 3rd option in #2837 (comment) fixed it for me
Jet12138 commentedon Dec 5, 2018
I wonder if I got something why I can't get the right result.
Jet12138 commentedon Dec 15, 2018
In the development mode, we show transpile dependencies for our codes, our dependencies, our devServer, so fill the babel-polifill can fix this problem, I did it when I found out this method from another way.
worksnpm run serve` breaks when using deps transpiling #3606huang-x-h commentedon Mar 24, 2019
We have the same problem. When we publish
es6module@pillarjs/A, which include object-rest-spread syntax, we add thetranspileDependencies: ['node_modules/@pillarjs'], and define the.browserslistrcfile to support iOS 10We build the project, it can not run on
iOS 10. When we changeimport A from '@pillarjs/A'to direct importimport A from './A.js'which the source file is insrcdirectory notnode_modules, it works.Seem babel do not detect the es feature in node_modules @sodatea
haoqunjiang commentedon Mar 24, 2019
@huang-x-h what about
transpileDependencies: ['@pillarjs']?huang-x-h commentedon Mar 24, 2019
@sodatea 💯 It's ok, thanks a lot.
transpileDependeciesjust set the package name, do not include thenode_modules?haoqunjiang commentedon Mar 25, 2019
@huang-x-h Yes we prepend the
node_modules/prefix internallyvue-cli/packages/@vue/cli-plugin-babel/index.js
Lines 4 to 16 in fd20e1f