-
-
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
Core: Fix package duplication issues by aliasing all storybook packages #11092
Changes from 3 commits
b4bf235
541ce5c
f48edc7
dc65657
262fca6
66e04ca
bec1e35
0e21344
764b689
d91e0b2
6a15159
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const version = '6.0.0-beta.22'; | ||
export const version = '6.0.0-beta.23'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"@storybook/angular": "6.0.0-beta.22", | ||
"@storybook/aurelia": "6.0.0-beta.22", | ||
"@storybook/ember": "6.0.0-beta.22", | ||
"@storybook/html": "6.0.0-beta.22", | ||
"@storybook/marionette": "6.0.0-beta.22", | ||
"@storybook/marko": "6.0.0-beta.22", | ||
"@storybook/mithril": "6.0.0-beta.22", | ||
"@storybook/preact": "6.0.0-beta.22", | ||
"@storybook/rax": "6.0.0-beta.22", | ||
"@storybook/react": "6.0.0-beta.22", | ||
"@storybook/riot": "6.0.0-beta.22", | ||
"@storybook/server": "6.0.0-beta.22", | ||
"@storybook/svelte": "6.0.0-beta.22", | ||
"@storybook/vue": "6.0.0-beta.22", | ||
"@storybook/web-components": "6.0.0-beta.22" | ||
"@storybook/angular": "6.0.0-beta.23", | ||
"@storybook/aurelia": "6.0.0-beta.23", | ||
"@storybook/ember": "6.0.0-beta.23", | ||
"@storybook/html": "6.0.0-beta.23", | ||
"@storybook/marionette": "6.0.0-beta.23", | ||
"@storybook/marko": "6.0.0-beta.23", | ||
"@storybook/mithril": "6.0.0-beta.23", | ||
"@storybook/preact": "6.0.0-beta.23", | ||
"@storybook/rax": "6.0.0-beta.23", | ||
"@storybook/react": "6.0.0-beta.23", | ||
"@storybook/riot": "6.0.0-beta.23", | ||
"@storybook/server": "6.0.0-beta.23", | ||
"@storybook/svelte": "6.0.0-beta.23", | ||
"@storybook/vue": "6.0.0-beta.23", | ||
"@storybook/web-components": "6.0.0-beta.23" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; | |
|
||
import resolveFrom from 'resolve-from'; | ||
|
||
import themingPaths from '@storybook/theming/paths'; | ||
|
||
import { createBabelLoader } from './babel-loader-preview'; | ||
import es6Transpiler from '../common/es6Transpiler'; | ||
|
||
|
@@ -21,6 +23,29 @@ import { toRequireContextString } from './to-require-context'; | |
import { useBaseTsSupport } from '../config/useBaseTsSupport'; | ||
|
||
const reactPaths = {}; | ||
const storybookPaths = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const storybookPaths = ['addons', ...other ].reduce((paths,package) => ({
...paths,
[`@storybook/${package}`]: path.dirname(resolveFrom(__dirname, `@storybook/${package}/package.json`))`
}), {}); Would reduce boilerplate a bit :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes please 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you wish 🎩 |
||
'@storybook/addons': path.dirname(resolveFrom(__dirname, '@storybook/addons/package.json')), | ||
'@storybook/api': path.dirname(resolveFrom(__dirname, '@storybook/api/package.json')), | ||
'@storybook/channels': path.dirname(resolveFrom(__dirname, '@storybook/channels/package.json')), | ||
'@storybook/channel-postmessage': path.dirname( | ||
resolveFrom(__dirname, '@storybook/channel-postmessage/package.json') | ||
), | ||
'@storybook/components': path.dirname( | ||
resolveFrom(__dirname, '@storybook/components/package.json') | ||
), | ||
'@storybook/core-events': path.dirname( | ||
resolveFrom(__dirname, '@storybook/core-events/package.json') | ||
), | ||
'@storybook/router': path.dirname(resolveFrom(__dirname, '@storybook/router/package.json')), | ||
'@storybook/theming': path.dirname(resolveFrom(__dirname, '@storybook/theming/package.json')), | ||
'@storybook/semver': path.dirname(resolveFrom(__dirname, '@storybook/semver/package.json')), | ||
'@storybook/client-api': path.dirname( | ||
resolveFrom(__dirname, '@storybook/client-api/package.json') | ||
), | ||
'@storybook/client-logger': path.dirname( | ||
resolveFrom(__dirname, '@storybook/client-logger/package.json') | ||
), | ||
}; | ||
try { | ||
reactPaths.react = path.dirname(resolveFrom(process.cwd(), 'react/package.json')); | ||
reactPaths['react-dom'] = path.dirname(resolveFrom(process.cwd(), 'react-dom/package.json')); | ||
|
@@ -64,13 +89,8 @@ export default async ({ | |
const match = entryFilename.match(/(.*)-generated-(config|other)-entry.js$/); | ||
if (match) { | ||
const configFilename = match[1]; | ||
const isUsingYarnPnp = typeof process.versions.pnp !== 'undefined'; | ||
const clientApi = isUsingYarnPnp | ||
? `${require.resolve('@storybook/client-api')}` | ||
: '@storybook/client-api'; | ||
const clientLogger = isUsingYarnPnp | ||
? `${require.resolve('@storybook/client-logger')}` | ||
: '@storybook/client-logger'; | ||
const clientApi = storybookPaths['@storybook/client-api']; | ||
const clientLogger = storybookPaths['@storybook/client-logger']; | ||
|
||
virtualModuleMapping[entryFilename] = interpolate(entryTemplate, { | ||
configFilename, | ||
|
@@ -159,8 +179,9 @@ export default async ({ | |
extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json', '.cjs'], | ||
modules: ['node_modules'].concat(raw.NODE_PATH || []), | ||
alias: { | ||
'babel-runtime/core-js/object/assign': require.resolve('core-js/es/object/assign'), | ||
semver: require.resolve('@storybook/semver'), | ||
...themingPaths, | ||
...storybookPaths, | ||
semver: path.dirname(resolveFrom(__dirname, '@storybook/semver/package.json')), | ||
ndelangen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
...reactPaths, | ||
}, | ||
|
||
|
@@ -177,17 +198,19 @@ export default async ({ | |
chunks: 'all', | ||
}, | ||
runtimeChunk: true, | ||
minimizer: [ | ||
new TerserWebpackPlugin({ | ||
cache: true, | ||
parallel: true, | ||
sourceMap: true, | ||
terserOptions: { | ||
mangle: false, | ||
keep_fnames: true, | ||
}, | ||
}), | ||
], | ||
minimizer: isProd | ||
? [ | ||
new TerserWebpackPlugin({ | ||
cache: true, | ||
parallel: true, | ||
sourceMap: true, | ||
terserOptions: { | ||
mangle: false, | ||
keep_fnames: true, | ||
}, | ||
}), | ||
] | ||
: [], | ||
}, | ||
performance: { | ||
hints: isProd ? 'warning' : false, | ||
|
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 are added to be sure to have them and be able to have a working alias?
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 all packages of @storybook/* that are conceivably used are aliased here so that there can only 1 of them in the entire bundle.