-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Babel Loader broken outside of source path #1870
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
Comments
I dunno if it's related, but I'm getting this error with babel-loader when upgrading to webpacker 4.0.0.rc2?
|
I played around with an upgrade to webpacker 4 over the weekend. The biggest challenge here is that webpack 4 upgraded the underlying What important to note here is that babel 7 switched npm wise to scoped packages. For webpacker you also need the correct npm package. Otherwise, let me share what I have installed eventually: //package.json
{
"dependencies": {
"@babel/runtime": "^7.2.0",
"@rails/webpacker": "^4.0.0-rc.2",
"webpack": "^4.28.3"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"babel-loader": "^8.0.5",
...
}
} And I needed to switch to the new //babel.config.js
module.exports = function (api) {
api.cache(true)
const presets = [
[
'@babel/preset-env',
{
targets: {
browsers: '> 1%'
},
useBuiltIns: 'entry',
forceAllTransforms: true
}
]
]
const plugins = [
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-runtime'
]
return {
presets,
plugins
}
} That did the trick for me, and I'm now compiling with webpacker 4, and babel 7 in blazing speed. So the upgrade path is not trivial as it includes many moving parts, but very much worth it. |
Yeah that was definitely a big update, but I think it's completely independent of the original issue here. I ran into this issue while already at Babel 7 and narrowed it down to the issue described above |
For the future you can have babel programmatically update itself with the babel-upgrade package. @tomprats It looks like you are setting the |
@codebryo is this strictly required? Is .babelrc or defining them in package.json being depreciated? I am getting different behaviors/errors when trying all of them separately. Any source for the cause of the switch? Thanks! |
@ghaydarov I did the explicit change after it was stated as a requirement on the |
@tomprats I literally made the exact same change but then solved it by switching over to the new babel config format as mentioned by others (specifically the react sample config in my case) Problem went away after that. |
Interesting... not sure why that worked, but it works! I'm still using my exact same babel config, just in |
Should this be mentioned as part of the upgrade process for webpacker 3->4? (does an upgrade doc even exist?) |
@connorshea it's in progress in #1755 |
Problem
The babel-loader went from using an exclude, to using both an exclude and include. I'm not really sure the reasoning behind it, but since I keep my tests in a different folder (test/javascript), it broke them.
Is the
include
necessary there? Should it maybe have been documented better that the babel loader would be more restricted than previously? Or did I just cause problems for myself because I may have been using it incorrectly in the first place?Origin
Looks like it was introduced in the rc1 release here. It took me a long time to track down exactly what was failing since it gave me an
Unexpected token
error on the first angle bracket of some jsx, making me believe it was jsx or react specific.Temporary Solution
Previously in my test config I just needed:
But now I've updated it to be:
Is there a better solution? Should the babel-loader itself be different?
The text was updated successfully, but these errors were encountered: