-
-
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
@vue/cli 4.0.5 transpileDependencies invalid #4773
Comments
Your reprodution doesn't contain any reference to transpileDepenencies. You likely forgot to push the changes? |
sorry! submitted. |
The problem with the arrow function has been solved, because i uesd tnpm, but new problems have arisen, TypeError. |
After adding transpileDepenencies, @antv/g6 It doesn't work on chrome. |
Workaround: set babel.config.js to: module.exports = {
sourceType: 'unambiguous',
presets: ['@vue/cli-plugin-babel/preset']
}; I think we should set it as the default🤔 |
I this setting safe for arbitrary dependencies? Afaik it's only necessary when attempting to transpile a module that's using the commonjs module format. |
I've been living with |
@JessicaSachs could you elaborate on the incompatible plugins? |
I’ve run into issues with plugins like styleguidist that do some static analysis. They’ve been fixed, but not until I submitted a reproduction repo. It’s not a common setting and there is risk of breaking existing repositories by changing the sourceType default. |
Is there any problem, can you list? |
this can be ok |
@JessicaSachs If you mean this issue vue-styleguidist/vue-styleguidist#436, I believe it's not related to the According to the babel documentation, The edge cases are ambiguous modules as listed in https://github.com/tc39/proposal-UnambiguousJavaScriptGrammar#problem For such a simple and ambiguous file, if no polyfills/helpers are injected:
I think the latter one is more reasonable in the context of third-party dependencies. The real problem: If a module references something like
Because we disabled the module transformation in babel, all This also means, if we don't change the default These use cases are also described in the README (the 3rd option). |
Nice sleuthing 🕵🏻♀️. Yeah, when I was messaging w Bart on Discord in
respect to this issue he said the issue was our sourceType config using
“unambiguous”, but we didn’t document that in the GH issue.
That’s the only issue I can think of off the top of my head. I think it is
likely to change code execution or have downstream affects we’re not
considering.
Solid reasoning on your part. I don’t disagree with any of it, I’m just
paranoid because this isn’t the default for Babel and previously users had
to opt in to do this. I wonder why this wasn’t previously an issue.
…On Thu, Oct 31, 2019 at 3:06 AM Haoqun Jiang ***@***.***> wrote:
@JessicaSachs <https://github.com/JessicaSachs> If you mean this issue
vue-styleguidist/vue-styleguidist#436
<vue-styleguidist/vue-styleguidist#436>, I
believe it's not related to the sourceType configuration.
According to the babel documentation, unambiguous seems to be a safer
option than the default module, especially when dealing with third-party
dependencies.
The edge cases are ambiguous modules as listed in
https://github.com/tc39/proposal-UnambiguousJavaScriptGrammar#problem
For such a simple and ambiguous file, if no polyfills/helpers are injected:
- With sourceType: 'module', a "use strict" pragma would be added to
the top of that file and the whole module will run in strict mode.
- With sourceType: 'unambiguous', it will be considered a CommonJS
module and remain as-is.
I think the latter one is more reasonable in the context of third-party
dependencies.
------------------------------
*The real problem*:
If a module references something like Symbol and a polyfill module needs
to be added:
- With sourceType: 'module', an import statement will be injected to
the file, regardless of the presence of module.exports;
- With sourceType: 'unambiguous', an require statement will be
injected if no import/export is seen in the file.
Because we disabled the module transformation in babel, all import/require
statements are passed down to webpack as-is. And the former case will
encounter an error in webpack *runtime* because webpack has stricter
rules on ES modules (the exports object would be read-only). And that's
exactly the case in this issue.
This also means, if we don't change the default sourceType configuration,
all third-party *CommonJS* dependencies with partially transpiled code
will encounter similar problems.
These use cases are also described in the README
<https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/babel-preset-app/README.md#usebuiltins>
(the 3rd option).
We currently recommend users to set useBuiltIns: 'entry', which is quite
unintuitive and also sub-optimal in code size.
So I believe sourceType: 'unambiguous' could be a much better solution.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4773?email_source=notifications&email_token=AAVL4BASUBXPEJ2232MQ6QDQRJ7Y3A5CNFSM4JGYE5TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECWYDYI#issuecomment-548241889>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVL4BCD2CNXKT2DGP7FPVDQRJ7Y3ANCNFSM4JGYE5TA>
.
|
we could experiment with it in a beta release, maybe? Plus we can document that babel's module.exports = {
sourceType: 'unambiguous',
presets: ['@vue/cli-plugin-babel/preset'],
overrides: [
{
test: 'node_modules/some-package/**/*',
sourceType: 'module'
}
]
}; |
Yeah, we can experiment it in v4.1.0-beta.0. |
Version
4.0.5
Reproduction link
https://github.com/lxfu/vue-g6
Environment info
Steps to reproduce
npm i
npm run serve
What is expected?
app should work under IE11.
What is actually happening?
The arrow function inside the dependency is not compiled
IE11 does not support arrow functions
The text was updated successfully, but these errors were encountered: