Skip to content
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

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented Apr 4, 2022

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.

@tmeasday tmeasday requested review from shilman and ndelangen April 4, 2022 07:51
@nx-cloud
Copy link

nx-cloud bot commented Apr 4, 2022

☁️ Nx Cloud Report

CI 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 target

Sent with 💌 from NxCloud.

Comment on lines +4 to +6
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';
Copy link
Member

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

Copy link
Member Author

@tmeasday tmeasday Apr 4, 2022

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.

Copy link
Contributor

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.

@tmeasday tmeasday added the maintenance User-facing maintenance tasks label Apr 4, 2022
@@ -1 +1 @@
module.exports = require('./dist/cjs/index');
module.exports = require('./dist/esm/index');
Copy link
Member

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...

Copy link
Member

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

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great catch @IanVS @tmeasday

@shilman shilman merged commit bcea801 into next Apr 4, 2022
@shilman shilman deleted the tom/sb-232-get-rid-of-unnecessary-web-cjs branch April 4, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants