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

chore: Update Storybook bundler to webpack 5 #56305

Merged
merged 2 commits into from Sep 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 4 additions & 12 deletions .teamcity/_self/projects/WebApp.kt
Expand Up @@ -264,21 +264,13 @@ object RunAllUnitTests : BuildType({
"""
}
bashNodeScript {
name = "Build components storybook"
name = "Run storybook tests"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I merged the two Storybook jobs into one, and added composite-checkout.

Also, I dropped NODE_ENV="production". It was causing problems, because Storybook sets it to development internally, and webpack's DefinePlugin was failing with storybookjs/storybook#14257 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
scriptContent = """
export NODE_ENV="production"

set -x
yarn components:storybook:start --ci --smoke-test
"""
}
bashNodeScript {
name = "Build search storybook"
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
scriptContent = """
export NODE_ENV="production"

yarn search:storybook:start --ci --smoke-test
yarn composite-checkout:storybook:start --ci --smoke-test
"""
}
}
Expand Down Expand Up @@ -807,4 +799,4 @@ object PreReleaseE2ETests : BuildType({
failureConditions {
executionTimeoutMin = 20
}
})
})
10 changes: 9 additions & 1 deletion bin/storybook-default-config.js
Expand Up @@ -5,8 +5,15 @@ const { dirname } = require( 'path' );
// of the given module.
const findModule = ( module ) => dirname( require.resolve( module + '/package.json' ) );

module.exports = function storybookDefaultConfig( { stories, webpackAliases = {} } = {} ) {
module.exports = function storybookDefaultConfig( {
stories,
plugins = [],
webpackAliases = {},
} = {} ) {
return {
core: {
builder: 'webpack5',
},
stories: stories && stories.length ? stories : [ '../src/**/*.stories.{js,jsx,ts,tsx}' ],
addons: [ '@storybook/addon-actions', '@storybook/preset-scss' ],
typescript: {
Expand Down Expand Up @@ -39,6 +46,7 @@ module.exports = function storybookDefaultConfig( { stories, webpackAliases = {}
...webpackAliases,
};
config.resolve.mainFields = [ 'browser', 'calypso:src', 'module', 'main' ];
config.plugins.push( ...plugins );
return config;
},
};
Expand Down
10 changes: 9 additions & 1 deletion packages/search/.storybook/main.js
@@ -1,2 +1,10 @@
const storybookDefaultConfig = require( '../../../bin/storybook-default-config' );
module.exports = storybookDefaultConfig();
const webpack = require('webpack');

module.exports = storybookDefaultConfig({
plugins: [
new webpack.ProvidePlugin( {
process: 'process/browser.js',
} ),
]
});
2 changes: 2 additions & 0 deletions packages/search/package.json
Expand Up @@ -46,6 +46,8 @@
"@babel/core": "^7.14.8",
"@babel/preset-env": "^7.14.8",
"@storybook/addon-actions": "^6.3.8",
"@storybook/builder-webpack5": "^6.3.8",
"@storybook/manager-webpack5": "^6.3.8",
"@storybook/preset-scss": "^1.0.3",
"@testing-library/dom": "^8.1.0",
"@testing-library/react": "^12.0.0",
Expand Down