Closed RyanHavoc closed 3 years ago
Had the same warning on the fresh install of storybook.
I tried to add this plugin in babel
field inside .storybook/main.js
, but the warnings didn't disappear.
However, warnings went away when I manually added [require.resolve("@babel/plugin-proposal-private-property-in-object"), { "loose": true }]
inside my node_modules
in this file:
https://github.com/storybookjs/storybook/blob/60c864bad312aa777657619041d415f03b223496/lib/core-common/src/utils/babel.ts#L3
I suppose this should be in the default Babel config, or I missing something?
Interesting... It would be great if we could find an official solution to this without needing to fork and fix in this way.
I tried manually installing the @babel/plugin-proposal-private-property-in-object
plugin and updated my babel config but it makes no difference. But Storybook will start albeit with lots of these warnings as it builds.
That's what I see too. Would be good to get rid of the warnings. 😕
Updating to the latest @babel/core
at 7.14.0, deleting the node_modules
folder, deleting and rebuilding yarn.lock
also does not remove the warning.
Adding plugins: ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
in main.js removed the warning for me:
addons: [{
name: '@storybook/addon-docs',
options: {
babelOptions: {
plugins: [
['@babel/plugin-proposal-private-property-in-object', {
loose: true
}],
],
},
},
}, ],
Read also: https://github.com/babel/babel/issues/11622
Unfortunately making that same change for me didn't make any difference.
@RyanHavoc Sorry, did you try adding in in .storybook/main.js
and not in your .bashrc
?
Yes, I tried adding those to my babel config in main.js
and also like this:
plugins: [
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-proposal-private-methods", { "loose": true }],
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]
But no joy.
Possibly there's something different with Vue instance. This same setup don't remove the warning for me.
Same here, none of the solutions above do work in our setup.
After Upgrading to latest pre release we do also get a lot of these warnings "Field 'browser' doesn't contain a valid alias configuration".
Storybook doesn't start. Does someone know whats going on?
We are seeing this issue in 6.2.9
when building the manager with Webpack 5. None of the above workarounds eliminate the warns for us.
We are also seeing this issue and none of the workarounds works for us either. (6.2.9
)
Any resolution / workaround here? It is quite a bit annoying due to the amount of output that it spams in the console when building a large project.
I've found that adding:
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-proposal-private-methods", { "loose": true }],
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]
To our .bablerc
file reduces the amount of warning spam to a couple of repetitions, but doesn't make it go away entirely.
I tried all above workarounds, but none worked.
What worked for me was downgrading @babel/preset-env to ~7.13.0
.
The loose warning happened not when I upgraded storybook to 6.2.9, but when @babel/preset-env was upgraded to ^7.14.0
Same here. Tried everything above with no success. Downgrade to @babel/preset-env@7.13.0
didn't help either. I'm out of ideas at the moment, to be honest, sticking to Storybook 6.1 for now :(
@kuk941025 Thanks, indeed, it does fix the issue for us as well.
@erykpiast Initially, we also tried downgrading the @babel/preset-env
to no avail, but that was actually due to it being installed in multiple versions by different packages. Maybe you are in the same situation. You can try to run yarn why @babel/preset-env
or npm ls @babel/preset-env
to actually check which versions are installed - and if you are on yarn you can use package json resolutions to force the version.
You're right @danantal, I have multiple versions indeed and Storybook is still using 7.14
! Thank you for this idea! :D
I'm not using Yarn, but uninstalling Storybook packages via NPM and installing them again did the trick. Poor-man resolution forcing in action 🙃
I resolved this by creating .storybook/.babelrc
with the following:
{
"presets": [
["@babel/preset-env", { "loose": true, "targets": { "node": "current" } }],
["@babel/preset-react", { "runtime": "automatic" }]
],
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-proposal-private-methods", { "loose": true }],
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]
}
This config is only used by storybook so I don't have to worry about loose mode being used when building my modules outside of storybook. You'll need to make sure that you have all of the above presets and plugins defined in your package.json.
package.json > resolutions "**/@babel/preset-env": "7.13.15"
- didn't solve it
package.json > devDependencies > "@babel/preset-env": "7.14.1",
to "@babel/preset-env": "7.13.15", - didn't solve it
audishos's suggestion in my .storybook\.babelrc
(monorepo) - didn't solve it
last ditch effort and rm -rf node_modules && yarn
- didn't solve it
I'm a bit stumped
@binary64 I had success with 7.12.11
, maybe you could try it. See my comment above if resolutions doesn't work (so if npm ls
still shows that Storybook uses newer one).
workaround, add babel config in .storybook/main.js
module.exports = {
stories: ...,
addons: ...,
babel: async (options) => {
const { plugins = [] } = options
return {
...options,
plugins: [
...plugins,
[
require.resolve('@babel/plugin-proposal-private-property-in-object'),
{ loose: true },
],
]
}
},
}
For anyone looking for the doc for the Babel function, here is the link https://storybook.js.org/docs/react/configure/babel
@ThinCats thx for the snippet, sadly this does not solve the problem for us (neither did any of the other suggestions from this and related issues in different repositories)
@pixelass it's supposed to solve just some of the warnings :D it may help by make sure you only have 1 version of these dependencies (e.g. babel-loader, preset-env etc.) but even so there are still 3 - 5 warnings (at least in my case) :(
Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.0-beta.2 containing PR #15055 that references this issue. Upgrade today to the @next
NPM tag to try it out!
npx sb upgrade --prerelease
Closing this issue. Please re-open if you think there's still more to do.
After testing I can confirm that the new beta mentioned in https://github.com/storybookjs/storybook/issues/14805#issuecomment-849600558 removes the warnings.
@shilman I can't seem to use the latest @next
version to fix this issue.
@lifeiscontent meaning upgrading doesn't solve it for you?
@shilman I'm not sure, I think there might be some code outside of this issue preventing me from using it. When I upgraded I couldn't get storybook to run with the latest package pinned to @next
@lifeiscontent Do you have a repro I can look at?
@shilman I also still have the problem, even after trying all the solutions above. I'm on 6.3.1 and come from 6.2.5.
@babel/plugin-proposal-private-property-in-object
plugin everywhere (in addons, in babelrc with loose
mode enabled).storybook/.babelrc.js
const rootConfig = require("../babel.config");
/**
* Take the project config, but set loose to true for class properties and private methods for Storybook.
*
* As Storybook updates, it's probably worth trying to delete this file and seeing if it will run without
* the workaround.
*/
const patchedPlugins = rootConfig.plugins.map((plugin) => {
if (
[
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods",
].includes(plugin)
) {
return [plugin, { loose: true }];
}
return plugin;
});
// Add flow to transpile some dependencies
module.exports = {
...rootConfig,
plugins: patchedPlugins.concat(
"@babel/plugin-transform-flow-strip-types"
),
};
.storybook/main.js
module.exports = {
stories: [
"../shared/**/*.stories.mdx",
"../shared/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-docs",
"@storybook/addon-essentials",
"storybook-addon-designs"
],
};
@pybuche hi, can you try yarn why
with the mentioned packages? (@babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object)
It's to see if there's any duplication in the dependencies.
@thien-do Sorry for the late answer. Here are the yarn why
for the 3 packages
This is the result just after launching npx sb upgrade
. Looks like @babel/plugin-proposal-private-property-in-object
doesn't exist in my current dependencies.
Looking at the results, seems like we have version conflicts with @babel/plugin-proposal-class-properties
. Do you know how we could fix that? Using peerDependencies
maybe?
@pybuche I ran into this exact issue, and discovered that editing my main Babel config (not my storybook/.babelrc
, but the whole project's .babelrc
) fixed the problem. This leads me to believe that somehow acorn-jsx
was using my main .babelrc
instead of the one that Storybook was uising. So, you might try setting loose: true
for all these Babel plugins and/or preset-env
in your main .babelrc
and see if that does anything for you.
Sadly I cannot repro this on a clean repo, and it's on a closed-source project, so I can't provide a good example. :cry:
@vivshaw thanks for the tip!
I finally managed to solve the problem with yarn v2's resolutions
config to fix the right versions for Babel plugins and it works like a charm!
Getting this error again when upgrading @babel/preset-env
from 7.15.0
to 7.15.8
adding
plugins: [
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-private-property-in-object', { loose: true }]
]
to my babel.config.js
removed the warnings for sb@6.4.0
Describe the bug We're upgrading from
@storybook/vue
6.1.21
to6.2.9
an we're now seeing the following error during Storybook start:This warning was shown multiple times during the build and then eventually I'd get an error and the build would fail.
We have a
.bashrc
file so I updated it to this:This has helped somewhat but we still get the error, however Storybook does start.
To Reproduce
All I did to see these issues was
npx sb@latest upgrade
and after starting storybook again I see the warnings.System