-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Enable non-declarative namespaces in Babel #11218
Comments
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
@tbelch-at-eHealth-Tec if you're interested, I did some digging here: #12745 (comment) The short term fix appears to be to mirror / symlink your Babel config into |
In case anyone is looking for alternative solutions, I added the following to babel: async (options) => {
const typescriptPreset = '@babel/preset-typescript';
const presetIndex = options.presets.findIndex(
(preset) =>
(typeof preset === 'string' && preset.match(typescriptPreset)) ||
(Array.isArray(preset) &&
preset[0] &&
preset[0].match(typescriptPreset))
);
if (presetIndex >= 0) {
const oldPreset = options.presets[presetIndex];
if (Array.isArray(oldPreset) && oldPreset.length >= 2) {
const title = oldPreset[0];
const config = oldPreset[1];
options.presets[presetIndex] = [
title,
{
...config,
allowNamespaces: true,
},
];
} else {
options.presets[presetIndex] = [
oldPreset,
{
allowNamespaces: true,
},
];
}
}
return {
...options,
// any extra options you want to set
presets: [...options.presets],
};
}, |
Describe the bug
I am using namespaces to group types and classes with TypeScript in my project, like this...
As described here I have a
.babelrc
file in the root of my project with the following content:This babel configuration enables non-declarative namespaces in my react application, but it doesn't work for storybook. I receive the following error:
If I copy
.babelrc
tostorybook
I receive the following error:Expected behavior
Well, either way, based on the documentation I'd expect storybook to pick up the
.babelrc
and enable non-declarative namespaces.System:
The text was updated successfully, but these errors were encountered: