-
-
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
Update some references to use ESM rather than CJS #17868
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit becc386. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
import { drawSelectedElement } from '@storybook/addon-measure/dist/esm/box-model/visualizer'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { init, destroy } from '@storybook/addon-measure/dist/cjs/box-model/canvas'; | ||
import { init, destroy } from '@storybook/addon-measure/dist/esm/box-model/canvas'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports will likely break over time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am not sure what's going on here exactly (cc @winkerVSbecks) but I just figure this is strictly better, anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test the addon I call an internal method from within stories. Instead of importing from the source, I ended up importing from the built addon. Probably a mistake. I can submit a PR to make this import relative.
@@ -1 +1 @@ | |||
module.exports = require('./dist/cjs/index'); | |||
module.exports = require('./dist/esm/index'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why lib/core/client.js
exists? It seems strange to just re-export the index...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only for backwards compatibility since @storybook/core
was refactored into core-client
and core-server
in a minor release (6.2) and we didn't know what might point at the @storybook/core/client
and @storybook/core/server
entry points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I did
@IanVS found some places in the codebase where web-based entries end up using CJS built files. These seem like mistakes, we should always use ESM on web, AFAIK.
How to test
Hopefully any problems will get picked up by automated testing.