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

Perf: Distribute both ESM and CJS modules #13013

Merged
merged 36 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
04acc44
Change /dist to ESM && upgrade required dependencies to make this hap…
ndelangen Nov 26, 2020
80b5af3
remove uuid from transpiled package list
ndelangen Nov 26, 2020
ff68aa2
revert undesired changes
ndelangen Nov 26, 2020
9dedc4b
Merge branch 'next' into perf/esm-dist
ndelangen Nov 26, 2020
165ce2d
Merge branch 'next' into perf/esm-dist
ndelangen Nov 27, 2020
ab7d1b0
Merge branch 'pr/43081j/13055' into perf/esm-dist
ndelangen Nov 27, 2020
b28d812
remove the preset-env babel-preset (it's replaced with the babel-plug…
ndelangen Nov 27, 2020
5c65134
correct preset value
ndelangen Nov 27, 2020
7e89b3e
Merge branch 'next' into perf/esm-dist
shilman Dec 1, 2020
6638cdb
Merge branch 'next' into perf/esm-dist
shilman Dec 1, 2020
2c7c510
fix eslint
ndelangen Dec 1, 2020
6f1e16d
Merge branch 'next' into perf/esm-dist
ndelangen Dec 1, 2020
11d23c7
cleanup
ndelangen Dec 1, 2020
0c8dfcc
Merge branch 'next' into perf/esm-dist
ndelangen Dec 8, 2020
aab422d
move ts3.4 into dist, generate types into dist/ts3.9, make esm dist f…
ndelangen Dec 8, 2020
53b13ad
fix angular, which has no babel build dist
ndelangen Dec 8, 2020
380074c
fix tests
ndelangen Dec 9, 2020
e717ab1
Merge branch 'next' into perf/esm-dist
ndelangen Dec 9, 2020
6bff1ea
Lazy load the custom scrollbar.
ghengeveld Dec 9, 2020
0930e4d
move version.json
ndelangen Dec 9, 2020
5f1ef64
Merge branch 'perf/esm-dist' of github.com:storybookjs/storybook into…
ndelangen Dec 9, 2020
5afd43a
fix
ndelangen Dec 9, 2020
84a4bde
FIX
ndelangen Dec 9, 2020
6338b8b
fix package entry fields of dev-kits
ndelangen Dec 9, 2020
95b3ec0
Replace react-hotkeys with simple keybinding with useEffect.
ghengeveld Dec 10, 2020
ca916ed
Merge branch 'next' into perf/esm-dist
ghengeveld Dec 11, 2020
8fbf8db
Revert "Lazy load the custom scrollbar."
ghengeveld Dec 11, 2020
d0617fa
Merge branch 'perf/esm-dist' into perf/react-hotkeys
ghengeveld Dec 11, 2020
e7f80e6
Merge branch 'next' into perf/esm-dist
ghengeveld Dec 11, 2020
9399648
Update lockfile
ghengeveld Dec 11, 2020
a6e3ea6
Merge pull request #13424 from storybookjs/perf/react-hotkeys
shilman Dec 11, 2020
bf0bb28
Merge branch 'next' into perf/esm-dist
shilman Dec 15, 2020
5ca9ee5
Update scripts/utils/watch-babel.js
shilman Dec 15, 2020
799b34c
Fix types-6-0 exports
shilman Dec 15, 2020
4a1987c
Revert test results
shilman Dec 15, 2020
010938f
Fix type export in vue types
shilman Dec 15, 2020
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
44 changes: 41 additions & 3 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@ const withTests = {
],
};

const modules = process.env.BABEL_ESM === 'true' ? false : 'auto';

module.exports = {
ignore: [
'./lib/codemod/src/transforms/__testfixtures__',
'./lib/postinstall/src/__testfixtures__',
],
presets: [
['@babel/preset-env', { shippedProposals: true, useBuiltIns: 'usage', corejs: '3' }],
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
targets: 'defaults',
modules,
},
],
'@babel/preset-typescript',
'@babel/preset-react',
'@babel/preset-flow',
Expand Down Expand Up @@ -52,7 +63,16 @@ module.exports = {
{
test: './lib',
presets: [
['@babel/preset-env', { shippedProposals: true, useBuiltIns: 'usage', corejs: '3' }],
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
modules,
targets: 'defaults',
},
],
'@babel/preset-react',
],
plugins: [
Expand Down Expand Up @@ -83,8 +103,9 @@ module.exports = {
shippedProposals: true,
useBuiltIns: 'usage',
targets: {
node: '8.11',
node: '10',
},
modules,
corejs: '3',
},
],
Expand All @@ -104,5 +125,22 @@ module.exports = {
test: withTests,
},
},
{
test: ['**/virtualModuleEntry.template.js'],
presets: [
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
targets: {
node: '10',
},
corejs: '3',
modules: false,
},
],
],
},
],
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ node_modules
*.sw*
npm-shrinkwrap.json
dist
ts3.4
.tern-port
*.DS_Store
.cache
Expand Down
10 changes: 5 additions & 5 deletions addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
"directory": "addons/a11y"
},
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"types": "dist/ts3.9/index.d.ts",
"typesVersions": {
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"<3.8": {
"*": [
"ts3.4/*"
"dist/ts3.4/*"
]
}
},
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts",
"ts3.4/**/*"
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
Expand Down
14 changes: 13 additions & 1 deletion addons/a11y/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
module.exports = require('./dist/preset');
function managerEntries(entry = []) {
return [...entry, require.resolve('./dist/esm/register')];
}

function config(entry = []) {
return [
...entry,
require.resolve('./dist/esm/a11yRunner'),
require.resolve('./dist/esm/a11yHighlight'),
];
}

module.exports = { managerEntries, config };
2 changes: 1 addition & 1 deletion addons/a11y/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./dist/register');
require('./dist/esm/register');
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { withA11y } from '../index';
import { withA11y } from '.';

export const decorators = [withA11y];
7 changes: 0 additions & 7 deletions addons/a11y/src/preset/index.ts

This file was deleted.

10 changes: 5 additions & 5 deletions addons/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
"directory": "addons/actions"
},
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/ts3.9/index.d.ts",
"typesVersions": {
"<3.8": {
"*": [
"ts3.4/*"
"dist/ts3.4/*"
]
}
},
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts",
"ts3.4/**/*"
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
Expand Down
17 changes: 16 additions & 1 deletion addons/actions/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
module.exports = require('./dist/preset');
function managerEntries(entry, options) {
return [...entry, require.resolve('./dist/esm/register')];
}

function config(entry = [], { addDecorator = true } = {}) {
const actionConfig = [];
if (addDecorator) {
actionConfig.push(require.resolve('./dist/esm/preset/addDecorator'));
}
return [...entry, ...actionConfig, require.resolve('./dist/esm/preset/addArgs')];
}

module.exports = {
managerEntries,
config,
};
2 changes: 1 addition & 1 deletion addons/actions/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./dist/register');
require('./dist/esm/register');
15 changes: 0 additions & 15 deletions addons/actions/src/preset/index.ts

This file was deleted.

10 changes: 5 additions & 5 deletions addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
},
"license": "MIT",
"author": "jbaxleyiii",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/ts3.9/index.d.ts",
"typesVersions": {
"<3.8": {
"*": [
"ts3.4/*"
"dist/ts3.4/*"
]
}
},
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts",
"ts3.4/**/*"
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
Expand Down
17 changes: 16 additions & 1 deletion addons/backgrounds/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
module.exports = require('./dist/preset');
function config(entry = []) {
return [
...entry,
require.resolve('./dist/esm/preset/addDecorator'),
require.resolve('./dist/esm/preset/addParameter'),
];
}

function managerEntries(entry = [], options) {
return [...entry, require.resolve('./dist/esm/register')];
}

module.exports = {
managerEntries,
config,
};
Copy link
Member

Choose a reason for hiding this comment

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

As it's done for other addons, addons/backgrounds/src/preset/index.ts can be deleted I guess?

Copy link
Member Author

Choose a reason for hiding this comment

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

2 changes: 1 addition & 1 deletion addons/backgrounds/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./dist/register');
require('./dist/esm/register');
7 changes: 0 additions & 7 deletions addons/backgrounds/src/preset/index.ts

This file was deleted.

11 changes: 10 additions & 1 deletion addons/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
"directory": "addons/controls"
},
"license": "MIT",
"main": "dist/register.js",
"main": "dist/cjs/register.js",
"module": "dist/esm/register.js",
"types": "dist/ts3.9/index.d.ts",
"typesVersions": {
"<3.8": {
"*": [
"dist/ts3.4/*"
]
}
},
"files": [
"dist/**/*",
"README.md",
Expand Down
9 changes: 8 additions & 1 deletion addons/controls/preset.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
module.exports = require('./dist/preset');
const { ensureDocsBeforeControls } = require('./dist/cjs/preset/ensureDocsBeforeControls');

function managerEntries(entry = [], options) {
ensureDocsBeforeControls(options.configDir);
return [...entry, require.resolve('./dist/esm/register')];
}

module.exports = { managerEntries };
2 changes: 1 addition & 1 deletion addons/controls/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/register';
import './dist/esm/register';
6 changes: 0 additions & 6 deletions addons/controls/src/preset/index.ts

This file was deleted.

10 changes: 5 additions & 5 deletions addons/cssresources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
},
"license": "MIT",
"author": "nm123github",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/ts3.9/index.d.ts",
"typesVersions": {
"<3.8": {
"*": [
"ts3.4/*"
"dist/ts3.4/*"
]
}
},
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts",
"ts3.4/**/*"
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
Expand Down
5 changes: 5 additions & 0 deletions addons/cssresources/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function managerEntries(entry = [], options) {
return [...entry, require.resolve('./dist/esm/register')];
}

module.exports = { managerEntries };
2 changes: 1 addition & 1 deletion addons/cssresources/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./dist/register.js');
require('./dist/esm/register.js');
10 changes: 5 additions & 5 deletions addons/design-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
"directory": "addons/design-assets"
},
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/ts3.9/index.d.ts",
"typesVersions": {
"<3.8": {
"*": [
"ts3.4/*"
"dist/ts3.4/*"
]
}
},
"files": [
"dist/**/*",
"README.md",
"*.js",
"*.d.ts",
"ts3.4/**/*"
"*.d.ts"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
Expand Down
5 changes: 5 additions & 0 deletions addons/design-assets/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function managerEntries(entry = [], options) {
return [...entry, require.resolve('./dist/esm/register')];
}

module.exports = { managerEntries };
2 changes: 1 addition & 1 deletion addons/design-assets/register.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./dist/register');
require('./dist/esm/register');
2 changes: 1 addition & 1 deletion addons/docs/angular/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('../dist/frameworks/angular/index');
module.exports = require('../dist/esm/frameworks/angular/index');
1 change: 0 additions & 1 deletion addons/docs/aurelia/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion addons/docs/blocks.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/blocks');
export * from './dist/esm/blocks';
Copy link
Member

Choose a reason for hiding this comment

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

Why this one isn't a module.exports anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm good question, don't think this is right

Copy link
Member Author

Choose a reason for hiding this comment

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

@hipstersmoothie WDYT? should this be cjs?

Loading