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

add the builderOptions to webpack config not only when disableWebpackDefaults = false #19376

Closed
wants to merge 5 commits into from
Closed
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
30 changes: 0 additions & 30 deletions code/cypress/generated/addon-docs.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export default {
};

export const Basic = () => <Button label="Click me" />;

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Form } from '@storybook/components';
const { Button } = Form;

export default {
title: 'CustomTitle',
component: Button,
title: 'CustomTitle',
component: Button,
};

export const Basic = () => <Button label="Click me" />;
2 changes: 1 addition & 1 deletion examples/react-ts/src/title/AutoTitle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export default {
component: Button,
};

export const Basic = () => <Button label="Click me" />;
export const Basic = () => <Button label="Click me" />;
4 changes: 2 additions & 2 deletions examples/react-ts/src/title/CustomTitle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Form } from '@storybook/components';
const { Button } = Form;

export default {
title: 'CustomTitle',
component: Button,
title: 'CustomTitle',
component: Button,
};

export const Basic = () => <Button label="Click me" />;
11 changes: 10 additions & 1 deletion lib/builder-webpack5/src/preview/iframe-webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import TerserWebpackPlugin from 'terser-webpack-plugin';
import VirtualModulePlugin from 'webpack-virtual-modules';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import type { Options, CoreConfig, Webpack5BuilderConfig } from '@storybook/core-common';

import themingPaths from '@storybook/theming/paths';

import type { Options, CoreConfig } from '@storybook/core-common';
import {
toRequireContextString,
es6Transpiler,
Expand Down Expand Up @@ -86,6 +86,13 @@ export default async (options: Options & Record<string, any>): Promise<Configura
workingDir,
});

const builderOptions = (coreOptions.builder as Webpack5BuilderConfig).options;
const cacheConfig = builderOptions?.fsCache
? { cache: { type: 'filesystem' as 'filesystem' } }
: {};
const lazyCompilationConfig =
builderOptions?.lazyCompilation && !isProd ? { lazyCompilation: { entries: false } } : {};

const virtualModuleMapping: Record<string, string> = {};
if (features?.storyStoreV7) {
const storiesFilename = 'storybook-stories.js';
Expand Down Expand Up @@ -274,5 +281,7 @@ export default async (options: Options & Record<string, any>): Promise<Configura
performance: {
hints: isProd ? 'warning' : false,
},
...cacheConfig,
experiments: { ...lazyCompilationConfig },
};
};
3 changes: 2 additions & 1 deletion lib/channel-postmessage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export class PostmsgTransport {
private handleEvent(rawEvent: MessageEvent): void {
try {
const { data } = rawEvent;
const { key, event, refId } = typeof data === 'string' && isJSON(data) ? parse(data, global.CHANNEL_OPTIONS || {}) : data;
const { key, event, refId } =
typeof data === 'string' && isJSON(data) ? parse(data, global.CHANNEL_OPTIONS || {}) : data;

if (key === KEY) {
const pageString =
Expand Down
4 changes: 3 additions & 1 deletion lib/codemod/src/transforms/csf-2-to-3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const isSimpleCSFStory = (init: t.Expression, annotations: t.ObjectProperty[]) =
annotations.length === 0 && t.isArrowFunctionExpression(init) && init.params.length === 0;

function transform({ source }: { source: string }, api: any, options: { parser?: string }) {
const makeTitle = (userTitle?: string) => { return userTitle || 'FIXME' }
const makeTitle = (userTitle?: string) => {
return userTitle || 'FIXME';
};
const csf = loadCsf(source, { makeTitle });

try {
Expand Down
257 changes: 0 additions & 257 deletions lib/core-server/src/__snapshots__/cra-ts-essentials_manager-prod-posix
Original file line number Diff line number Diff line change
@@ -1,262 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials manager dev 1`] = `
Object {
"entry": Array [
"NODE_MODULES/@storybook/addon-ie11/dist/event-source-polyfill.js",
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
"ROOT/lib/core-client/dist/esm/manager/index.js",
"ROOT/addons/docs/manager.js",
"ROOT/addons/controls/manager.js",
"ROOT/addons/actions/manager.js",
"ROOT/addons/backgrounds/manager.js",
"ROOT/addons/toolbars/manager.js",
"ROOT/addons/measure/manager.js",
"ROOT/addons/outline/manager.js",
],
"keys": Array [
"name",
"mode",
"bail",
"devtool",
"entry",
"output",
"watchOptions",
"plugins",
"module",
"resolve",
"resolveLoader",
"recordsPath",
"performance",
"optimization",
],
"module": Object {
"rules": Array [
Object {
"exclude": Array [
"NODE_MODULES/",
"/dist/",
],
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
"use": Array [
Object {
"loader": "NODE_MODULES/babel-loader/lib/index.js",
"options": Object {
"babelrc": false,
"configFile": false,
"plugins": Array [
"NODE_MODULES/@babel/plugin-transform-shorthand-properties/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"NODE_MODULES/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"NODE_MODULES/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"NODE_MODULES/@babel/plugin-proposal-private-property-in-object/lib/index.js",
Object {
"loose": true,
},
],
Array [
"NODE_MODULES/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"NODE_MODULES/@babel/plugin-proposal-export-default-from/lib/index.js",
"NODE_MODULES/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"NODE_MODULES/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"NODE_MODULES/@babel/plugin-transform-classes/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-arrow-functions/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-parameters/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-destructuring/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-spread/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-for-of/lib/index.js",
"NODE_MODULES/babel-plugin-macros/dist/index.js",
"NODE_MODULES/@babel/plugin-proposal-optional-chaining/lib/index.js",
"NODE_MODULES/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"NODE_MODULES/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "NODE_MODULES/core-js/index.js",
"method": "usage-global",
"version": "*",
},
],
"NODE_MODULES/@babel/plugin-transform-template-literals/lib/index.js",
],
"presets": Array [
Array [
"NODE_MODULES/@babel/preset-env/lib/index.js",
Object {
"loose": true,
"shippedProposals": true,
},
],
"NODE_MODULES/@babel/preset-typescript/lib/index.js",
"NODE_MODULES/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"include": [Function],
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "NODE_MODULES/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"NODE_MODULES/@babel/plugin-transform-shorthand-properties/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"NODE_MODULES/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"NODE_MODULES/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"NODE_MODULES/@babel/plugin-proposal-private-property-in-object/lib/index.js",
Object {
"loose": true,
},
],
Array [
"NODE_MODULES/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"NODE_MODULES/@babel/plugin-proposal-export-default-from/lib/index.js",
"NODE_MODULES/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"NODE_MODULES/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"NODE_MODULES/@babel/plugin-transform-classes/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-arrow-functions/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-parameters/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-destructuring/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-spread/lib/index.js",
"NODE_MODULES/@babel/plugin-transform-for-of/lib/index.js",
"NODE_MODULES/babel-plugin-macros/dist/index.js",
"NODE_MODULES/@babel/plugin-proposal-optional-chaining/lib/index.js",
"NODE_MODULES/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"NODE_MODULES/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "NODE_MODULES/core-js/index.js",
"method": "usage-global",
"version": "*",
},
],
],
"presets": Array [
Array [
"NODE_MODULES/@babel/preset-env/lib/index.js",
Object {
"loose": true,
"modules": false,
"shippedProposals": true,
"targets": "defaults",
},
],
"NODE_MODULES/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"test": "/\\\\.css$/",
"use": Array [
"NODE_MODULES/style-loader/dist/cjs.js",
Object {
"loader": "NODE_MODULES/css-loader/dist/cjs.js",
"options": Object {
"importLoaders": 1,
},
},
],
},
Object {
"loader": "NODE_MODULES/file-loader/dist/cjs.js",
"options": Object {
"name": "static/media/[path][name].[ext]",
},
"test": "/\\\\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\\\?.*)?$/",
},
Object {
"loader": "NODE_MODULES/url-loader/dist/cjs.js",
"options": Object {
"limit": 10000,
"name": "static/media/[path][name].[ext]",
},
"test": "/\\\\.(mp4|webm|wav|mp3|m4a|aac|oga)(\\\\?.*)?$/",
},
Object {
"include": "NODE_MODULES[\\\\\\\\/](@storybook[\\\\\\\\/]node_logger|@testing-library[\\\\\\\\/]dom|@testing-library[\\\\\\\\/]user-event|acorn-jsx|ansi-align|ansi-colors|ansi-escapes|ansi-regex|ansi-styles|better-opn|boxen|camelcase|chalk|color-convert|commander|find-cache-dir|find-up|fs-extra|highlight.js|json5|node-fetch|pkg-dir|prettier|pretty-format|react-dev-utils|resolve-from|semver|slash|strip-ansi|uuid)/",
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "NODE_MODULES/babel-loader/lib/index.js",
"options": Object {
"presets": Array [
Array [
"@babel/preset-env",
Object {
"targets": Object {
"ie": "11",
},
},
"storybook-addon-ie11",
],
],
"sourceType": "unambiguous",
},
},
],
},
],
},
"plugins": Array [
"VirtualModulesPlugin",
"HtmlWebpackPlugin",
"CaseSensitivePathsPlugin",
"DefinePlugin",
],
}
`;

exports[`cra-ts-essentials manager prod 1`] = `
Object {
"entry": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ Object {
},
Object {
"loader": "NODE_MODULES/@storybook/mdx1-csf/loader.js",
"options": Object {
"remarkPlugins": Array [
[Function],
[Function],
],
"skipCsf": false,
},
},
],
},
Expand Down
Loading