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
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties #3008
Comments
What version of Webpacker are you using (both Ruby gem and JavaScript package), and what is the content of your |
Same issue here - just updated Webpacker to version 5.3.0 (from 5.2.1) and I'm getting this warning. Here is my module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
}
return {
presets: [
isTestEnv && [
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
].filter(Boolean),
plugins: [
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
[
'@babel/plugin-proposal-class-properties',
{
loose: true
}
],
[
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true
}
],
[
'@babel/plugin-transform-runtime',
{
helpers: false,
regenerator: true,
corejs: false
}
],
[
'@babel/plugin-transform-regenerator',
{
async: false
}
]
].filter(Boolean)
}
} |
Running webpacker 6.0.0-beta7 using webpack 5.36.2, this did the trick for me:
"babel": {
"presets": [
"./node_modules/@rails/webpacker/package/babel/preset.js"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods"
]
} You can then set the |
Hi, I think I've found a way to replicate with a new webpacker installation $ rails _6.1.3.2_ new test-babel-warning --skip-active-record --skip-javascript
$ cd test-babel-warning
$ echo "{ \"private\": true }" > package.json
$ echo "gem 'webpacker', '5.3.0'" >> Gemfile
$ bundle
$ bundle exec rails webpacker:install
$ echo "class Counter extends HTMLElement { #xValue = 0; }" >> app/javascript/packs/application.js
$ bin/webpack (demo javascript taken from https://babeljs.io/docs/en/babel-plugin-proposal-private-methods) Output:
NOTE the warning will disappear after the second run of Fix: diff --git a/babel.config.js b/babel.config.js
index 4df1949..2fdd7d3 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -53,6 +53,12 @@ module.exports = function(api) {
useBuiltIns: true
}
],
+ [
+ '@babel/plugin-proposal-private-methods',
+ {
+ loose: true
+ }
+ ],
[
'@babel/plugin-transform-runtime',
{ edit: not reproducible with Webpacker 6 beta 7 |
The "loose" option must be the same for: - @babel/plugin-proposal-class-properties, - @babel/plugin-proposal-private-methods - @babel/plugin-proposal-private-property-in-object class-properties and private-methods are dependencies of @babel/preset-env, which is required by webpacker. This commit sets the same loose value for both class-properties and private-methods to silence the warning Fix rails#3008
This avoids the warning error we're seeing about "loose" configs. See rails/webpacker#3008
You can try this way:
Webpacker 6 doesn't have this issue because it no longer uses this loader Issue about this in babel rep: |
This avoids the warning error we're seeing about "loose" configs. See rails/webpacker#3008
This avoids the warning error we're seeing about "loose" configs. See rails/webpacker#3008
The "loose" option must be the same for: - @babel/plugin-proposal-class-properties, - @babel/plugin-proposal-private-methods - @babel/plugin-proposal-private-property-in-object class-properties and private-methods are dependencies of @babel/preset-env, which is required by webpacker. This commit sets the same loose value for both class-properties and private-methods to silence the warning Fix rails#3008
I just did |
Hi @dorianmariefr , I cannot confirm that adding that package makes the warning disappear. I've tried with the reduced test case at #3016, by running
This warning is not always displayed, I think it is only displayed the first time a class with a private variable is going to be compiled. You can just try to run |
I did it to solve this error: 1º - My babelrc:
2º - I've installed this: My scenario: "webpack": "^4.46.0", "react": "^16.14.0", "@storybook/react": "^6.2.9". |
If You're looking how to fix is easly in Nuxt.js, check this > issue fix |
The "loose" option must be the same for: - @babel/plugin-proposal-class-properties, - @babel/plugin-proposal-private-methods - @babel/plugin-proposal-private-property-in-object class-properties and private-methods are dependencies of @babel/preset-env, which is required by webpacker. This commit sets the same loose value for both class-properties and private-methods to silence the warning Fix #3008
Try add these in nuxt.config.js:
|
Adding ['@babel/plugin-proposal-private-property-in-object', { loose: true }] in build of nuxt.config.js solved my issue for Nuxt @ v2.15.7
|
What about for Webpacker 5.x? Will there be no release which fixes this? |
I fixed this in Webpacker 5.4 by using adding the following assumptions: {
privateFieldsAsProperties: true,
}, which is a slightly cleaner and more "modern" version (if you are on Babel 7.13+) of what @htetaung7 proposed. (This is assuming you do want private fields to be treated loosely.) |
Fixed in 5.4.2 for new installations. |
|
I was still running into this on webpacker 6.0.0-rc.5 with a babel.config.js file with an additional plugin, but adding the fix someone mentioned above and installing them as dependencies seems to have fixed the issue. Before
After
Plus
|
This issue is back for Hotwire 1.0 (Stimulus 3 + Turbo 7). |
Running into these Babel configuration warnings: rails/webpacker#3008 Upgrading webpacker should fix them: rails/webpacker#3008 (comment) 🤞 Refs: #3169
Running into these Babel configuration warnings: rails/webpacker#3008 Upgrading webpacker should fix them: rails/webpacker#3008 (comment) 🤞 Refs: #3169
Fixed @tomprats |
@sivaraj-v thanks it is working for me. |
* Upgrade react-native to 0.69.2 - Tested on iOS build * Upgrade reanimated to v3 for Android build - Related software-mansion/react-native-reanimated#3310 * Update packages to recent - Tested on iOS, Android and web * Remove all useless tests for now * Add Sponsor page * Fix craco build - Related rails/webpacker#3008 * Downgrade react-native-reanimated on deploy
I'm getting this warning over and over:
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties. The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding ["@babel/plugin-proposal-private-methods", { "loose": true }] to the "plugins" section of your Babel config.
The text was updated successfully, but these errors were encountered: