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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/links/react.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/react');
module.exports = require('./dist/esm/react');
4 changes: 2 additions & 2 deletions app/angular/src/server/framework-preset-angular-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,8 @@ const newWebpackConfiguration = (
bail: false,
devtool: 'cheap-module-source-map',
entry: [
'/Users/joe/storybook/lib/core-server/dist/cjs/globals/polyfills.js',
'/Users/joe/storybook/lib/core-server/dist/cjs/globals/globals.js',
'/Users/joe/storybook/lib/core-server/dist/esm/globals/polyfills.js',
'/Users/joe/storybook/lib/core-server/dist/esm/globals/globals.js',
'/Users/joe/storybook/examples/angular-cli/.storybook/storybook-init-framework-entry.js',
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js',
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/angular/config.js-generated-other-entry.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
// eslint-disable-next-line import/no-extraneous-dependencies
import { drawSelectedElement } from '@storybook/addon-measure/dist/cjs/box-model/visualizer';
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';
Comment on lines +4 to +6
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.


export const ShadowRoot = ({ label = 'Hello from shadow DOM', drawMode = 'ROOT' }) => {
const ref = React.useRef();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
// eslint-disable-next-line import/no-extraneous-dependencies
import { drawSelectedElement } from '@storybook/addon-measure/dist/cjs/box-model/visualizer';
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';

export const Visualization = ({ render }) => {
const element = useRef(null);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/html.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/html');
module.exports = require('./dist/esm/html');
2 changes: 1 addition & 1 deletion lib/core/client.js
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion lib/router/utils.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/utils');
module.exports = require('./dist/esm/utils');
2 changes: 1 addition & 1 deletion lib/theming/create.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/create');
module.exports = require('./dist/esm/create');