Closed tjk closed 3 years ago
Yup, as soon as you use @babel/core
and @babel/preset-env
instead of @babel/standalone
and its included env
preset in the legacy plugin, the issue disappears. Not necessary to manually add the relevant Babel plugin. (not possible anyway as afaik those depend on @babel/core
and aren't compatible with the standalone version)
Is there a quick workaround possible here? I imagine the more proper fix is to allow hooking into babel to add custom, required plugins? (and these would have to be written to be compatible with babel standalone?)
If you just need a quick way to get it to work, try this:
npm i -D @babel/core @babel/preset-env module-alias
then add this to your package.json:
"_moduleAliases": {
"@babel/standalone": "node_modules/@babel/core",
"babel-preset-env": "node_modules/@babel/preset-env"
}
and in your vite.config.js
add this as the very first line:
import 'module-alias/register'
Now when @vitejs/plugin-legacy
requires Babel standalone, it'll actually get the full @babel/core
because of the module alias :)
That worked! Thanks a bunch.
This was fixed by Babel and released in version 7.13.0: https://github.com/babel/babel/blob/main/CHANGELOG.md#bug-bug-fix-5
@tjk You can already remove the packages needed for the workaround, then just reinstall the dependencies and it'll work
(npm rm module-alias @babel/core @babel/preset-env && rm -rf node_modules && npm i
)
I'm trying to log out the code babel transform craps out on and noticed this (from monaco-editor dependency):
(essentially the code here: https://github.com/microsoft/vscode/blob/main/src/vs/editor/contrib/linesOperations/linesOperations.ts#L1058)
I looked in to https://babeljs.io/docs/en/babel-plugin-proposal-unicode-property-regex and tried to manually inject it into this plugin (I don't think there are hooks to configure babel standalone that is run?) but no success yet. ~Not sure if I'm doing it wrong or if this is a red herring... any guidance would be useful (even tips on debugging).~
UPDATE: Not a red herring! Deleting those two lines using
\p
regex in monaco-editor caused the build to succeed! Now would just love your help to understand the underlying issue and hopefully the fix. :)PS: Thanks for this amazing software!
System Info
vite
version: 2.0.1