-
-
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
Allow for a main.cjs
to accommodate module packages
#10075
Comments
main.js
file to specify it as main.cjs
to accommodate module packagesmain.cjs
to accommodate module packages
cc @ndelangen |
Storybook doesn't control the Project Level So the user get's to decide if If the user adds a Is an action required from storybook? I don't think so, perhaps some documentation? I haven't seen this behaviour from node, which version introduced this? |
Once the user decides The action required from Storybook is as specified in the original issue description, or another alternative if available. The behaviour is documented here: https://nodejs.org/api/esm.html |
Yay!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.31 containing PR #10288 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
doesn't work. Where error comes from?
|
confirmed still an issue, investigating.. |
Olé!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.34 containing PR #10358 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Is your feature request related to a problem? Please describe.
When a Node package is specified as a
module
type, the default behaviour loading.js
files changes;.js
files are now treated as ECMAScript modules and.cjs
files are treated as CommonJS modules. When this occurs, it is impossible to load.storybook/main.js
correctly as it is a CommonJS module but it is treated as if it were an ECMAScript module.Describe the solution you'd like
I'd like to be able to configure the
main
file name or have Storybook look for either amain.js
ormain.cjs
file to load themain
file from.Describe alternatives you've considered
Adding an empty
package.json
(a file with an empty JSON object specified) in the.storybook
directory will fix this problem as Node will traverse up the file hierarchy to find out how to load modules. If there is apackage.json
in the.storybook
directory without a"type": "module"
property set, Node will assume it should loadmain.js
as a CommonJS module and not an ECMAScript module. While this does work, it feels like a hack for an absent convention (looking for eithermain.js
ormain.cjs
) or configuration (being able to specify the location of themain
file).Are you able to assist bring the feature to reality?
no
The text was updated successfully, but these errors were encountered: