Tests for the preset behavior of core

This commit is contained in:
Michael Shilman 2021-02-09 19:02:41 +08:00
parent 013f2658e3
commit d73449dfb8
11 changed files with 1590 additions and 18 deletions

View File

@ -4,8 +4,8 @@ export default {
packageJson: sync({ cwd: __dirname }).packageJson,
framework: 'react',
frameworkPresets: [
require.resolve('./framework-preset-react.js'),
require.resolve('./framework-preset-cra.js'),
require.resolve('./framework-preset-react-docgen.js'),
require.resolve('./framework-preset-react'),
require.resolve('./framework-preset-cra'),
require.resolve('./framework-preset-react-docgen'),
],
};

View File

@ -0,0 +1,204 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`core presets dev mode 1`] = `
Object {
"entry": Array [
"ROOT/lib/core/src/server/common/polyfills.ts",
"ROOT/lib/core/src/client/manager/index.ts",
"ROOT/addons/actions/dist/esm/register.js",
"ROOT/addons/backgrounds/dist/esm/register.js",
"ROOT/addons/viewport/dist/esm/register.js",
"ROOT/addons/toolbars/dist/esm/register.js",
"ROOT/addons/controls/dist/esm/register.js",
"ROOT/addons/storysource/dist/esm/register.js",
"ROOT/addons/docs/dist/esm/register.js",
"ROOT/examples/react-ts/generated-refs.js",
],
"module": Object {
"rules": Array [
Object {
"exclude": Array [
"/node_modules/",
"/dist/",
],
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
"ROOT/node_modules/@babel/plugin-transform-template-literals/lib/index.js",
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
"ROOT/node_modules/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"include": [Function],
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"modules": false,
"shippedProposals": true,
"targets": "defaults",
},
],
"ROOT/node_modules/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"test": "/\\\\.css$/",
"use": Array [
"ROOT/lib/core/node_modules/style-loader/dist/cjs.js",
Object {
"loader": "ROOT/node_modules/css-loader/dist/cjs.js",
"options": Object {
"importLoaders": 1,
},
},
],
},
Object {
"loader": "ROOT/lib/core/node_modules/file-loader/dist/cjs.js",
"query": Object {
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\\\?.*)?$/",
},
Object {
"loader": "ROOT/lib/core/node_modules/url-loader/dist/cjs.js",
"query": Object {
"limit": 10000,
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(mp4|webm|wav|mp3|m4a|aac|oga)(\\\\?.*)?$/",
},
],
},
"plugins": Array [
"VirtualModulesPlugin",
"HtmlWebpackPlugin",
"CaseSensitivePathsPlugin",
"DefinePlugin",
"DefinePlugin",
],
}
`;

View File

@ -0,0 +1,205 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`core presets production mode 1`] = `
Object {
"entry": Array [
"ROOT/lib/core/src/server/common/polyfills.ts",
"ROOT/lib/core/src/client/manager/index.ts",
"ROOT/addons/actions/dist/esm/register.js",
"ROOT/addons/backgrounds/dist/esm/register.js",
"ROOT/addons/viewport/dist/esm/register.js",
"ROOT/addons/toolbars/dist/esm/register.js",
"ROOT/addons/controls/dist/esm/register.js",
"ROOT/addons/storysource/dist/esm/register.js",
"ROOT/addons/docs/dist/esm/register.js",
"ROOT/examples/react-ts/generated-refs.js",
],
"module": Object {
"rules": Array [
Object {
"exclude": Array [
"/node_modules/",
"/dist/",
],
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
"ROOT/node_modules/@babel/plugin-transform-template-literals/lib/index.js",
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
"ROOT/node_modules/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"include": [Function],
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"modules": false,
"shippedProposals": true,
"targets": "defaults",
},
],
"ROOT/node_modules/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"test": "/\\\\.css$/",
"use": Array [
"ROOT/lib/core/node_modules/style-loader/dist/cjs.js",
Object {
"loader": "ROOT/node_modules/css-loader/dist/cjs.js",
"options": Object {
"importLoaders": 1,
},
},
],
},
Object {
"loader": "ROOT/lib/core/node_modules/file-loader/dist/cjs.js",
"query": Object {
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\\\?.*)?$/",
},
Object {
"loader": "ROOT/lib/core/node_modules/url-loader/dist/cjs.js",
"query": Object {
"limit": 10000,
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(mp4|webm|wav|mp3|m4a|aac|oga)(\\\\?.*)?$/",
},
],
},
"plugins": Array [
"VirtualModulesPlugin",
"HtmlWebpackPlugin",
"CaseSensitivePathsPlugin",
"DefinePlugin",
"DefinePlugin",
"BundleAnalyzerPlugin",
],
}
`;

View File

@ -0,0 +1,526 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`core presets dev mode 1`] = `
Object {
"entry": Array [
"ROOT/lib/core/src/server/common/polyfills.ts",
"ROOT/lib/core/src/server/preview/globals.ts",
"ROOT/examples/react-ts/storybook-init-framework-entry.js",
"ROOT/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js",
"ROOT/addons/docs/dist/esm/frameworks/react/config.js-generated-other-entry.js",
"ROOT/addons/actions/dist/esm/preset/addDecorator.js-generated-other-entry.js",
"ROOT/addons/actions/dist/esm/preset/addArgs.js-generated-other-entry.js",
"ROOT/addons/backgrounds/dist/esm/preset/addDecorator.js-generated-other-entry.js",
"ROOT/addons/backgrounds/dist/esm/preset/addParameter.js-generated-other-entry.js",
"ROOT/examples/react-ts/generated-stories-entry.js",
"ROOT/node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined",
],
"module": Object {
"rules": Array [
Object {
"exclude": "/node_modules/",
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"cacheDirectory": "ROOT/node_modules/.cache/storybook/babel",
"overrides": Array [
Object {
"plugins": Array [
Array [
"ROOT/node_modules/babel-plugin-react-docgen/lib/index.js",
Object {
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES",
},
],
],
"test": "/\\\\.(mjs|jsx?)$/",
},
],
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
Array [
"ROOT/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
Object {
"autoLabel": true,
"sourceMap": true,
},
],
"ROOT/node_modules/babel-plugin-add-react-displayname/index.js",
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
Array [
"ROOT/node_modules/@babel/preset-react/lib/index.js",
Object {
"runtime": "automatic",
},
],
"ROOT/node_modules/@babel/preset-flow/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"include": [Function],
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"modules": false,
"shippedProposals": true,
"targets": "defaults",
},
],
"ROOT/node_modules/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"test": "/\\\\.md$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/raw-loader/dist/cjs.js",
},
],
},
Object {
"enforce": "pre",
"test": Array [
"/\\\\.stories\\\\.(jsx?$|tsx?$)/",
],
"use": Array [
Object {
"loader": "ROOT/lib/source-loader/dist/cjs/index.js",
"options": undefined,
},
],
},
Object {
"include": "/node_modules\\\\/acorn-jsx/",
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"modules": "commonjs",
},
],
],
},
},
],
},
Object {
"test": "/\\\\.(stories|story)\\\\.mdx$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"babelrc": false,
"cacheDirectory": "ROOT/node_modules/.cache/storybook/babel",
"configFile": false,
"overrides": Array [
Object {
"plugins": Array [
Array [
"ROOT/node_modules/babel-plugin-react-docgen/lib/index.js",
Object {
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES",
},
],
],
"test": "/\\\\.(mjs|jsx?)$/",
},
],
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
Array [
"ROOT/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
Object {
"autoLabel": true,
"sourceMap": true,
},
],
"ROOT/node_modules/babel-plugin-add-react-displayname/index.js",
Array [
"ROOT/addons/docs/node_modules/@babel/plugin-transform-react-jsx/lib/index.js",
Object {
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
Array [
"ROOT/node_modules/@babel/preset-react/lib/index.js",
Object {
"runtime": "automatic",
},
],
"ROOT/node_modules/@babel/preset-flow/lib/index.js",
],
"sourceType": "unambiguous",
},
},
Object {
"loader": "ROOT/node_modules/@mdx-js/loader/index.js",
"options": Object {
"compilers": Array [
[Function],
],
"remarkPlugins": Array [
[Function],
[Function],
],
},
},
],
},
Object {
"exclude": "/\\\\.(stories|story)\\\\.mdx$/",
"test": "/\\\\.mdx$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"babelrc": false,
"cacheDirectory": "ROOT/node_modules/.cache/storybook/babel",
"configFile": false,
"overrides": Array [
Object {
"plugins": Array [
Array [
"ROOT/node_modules/babel-plugin-react-docgen/lib/index.js",
Object {
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES",
},
],
],
"test": "/\\\\.(mjs|jsx?)$/",
},
],
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
Array [
"ROOT/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
Object {
"autoLabel": true,
"sourceMap": true,
},
],
"ROOT/node_modules/babel-plugin-add-react-displayname/index.js",
Array [
"ROOT/addons/docs/node_modules/@babel/plugin-transform-react-jsx/lib/index.js",
Object {
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
Array [
"ROOT/node_modules/@babel/preset-react/lib/index.js",
Object {
"runtime": "automatic",
},
],
"ROOT/node_modules/@babel/preset-flow/lib/index.js",
],
"sourceType": "unambiguous",
},
},
Object {
"loader": "ROOT/node_modules/@mdx-js/loader/index.js",
"options": Object {
"remarkPlugins": Array [
[Function],
[Function],
],
},
},
],
},
Object {
"enforce": "pre",
"loader": "ROOT/lib/source-loader/dist/cjs/index.js",
"options": Object {
"injectStoryParameters": false,
"inspectLocalDependencies": true,
"parser": "typescript",
},
"test": "/\\\\.(stories|story)\\\\.[tj]sx?$/",
},
Object {
"sideEffects": true,
"test": "/\\\\.css$/",
"use": Array [
"ROOT/lib/core/node_modules/style-loader/dist/cjs.js",
Object {
"loader": "ROOT/node_modules/css-loader/dist/cjs.js",
"options": Object {
"importLoaders": 1,
},
},
Object {
"loader": "ROOT/lib/core/node_modules/postcss-loader/dist/cjs.js",
"options": Object {
"postcssOptions": [Function],
},
},
],
},
Object {
"loader": "ROOT/lib/core/node_modules/file-loader/dist/cjs.js",
"options": Object {
"esModule": false,
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\\\?.*)?$/",
},
Object {
"loader": "ROOT/lib/core/node_modules/url-loader/dist/cjs.js",
"query": Object {
"limit": 10000,
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(mp4|webm|wav|mp3|m4a|aac|oga)(\\\\?.*)?$/",
},
],
},
"plugins": Array [
"FilterWarningsPlugin",
"VirtualModulesPlugin",
"HtmlWebpackPlugin",
"DefinePlugin",
"WatchMissingNodeModulesPlugin",
"HotModuleReplacementPlugin",
"CaseSensitivePathsPlugin",
"ProgressPlugin",
"DefinePlugin",
"ForkTsCheckerWebpackPlugin",
"DocgenPlugin",
],
}
`;

View File

@ -0,0 +1,523 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`core presets production mode 1`] = `
Object {
"entry": Array [
"ROOT/lib/core/src/server/common/polyfills.ts",
"ROOT/lib/core/src/server/preview/globals.ts",
"ROOT/examples/react-ts/storybook-init-framework-entry.js",
"ROOT/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js",
"ROOT/addons/docs/dist/esm/frameworks/react/config.js-generated-other-entry.js",
"ROOT/addons/actions/dist/esm/preset/addDecorator.js-generated-other-entry.js",
"ROOT/addons/actions/dist/esm/preset/addArgs.js-generated-other-entry.js",
"ROOT/addons/backgrounds/dist/esm/preset/addDecorator.js-generated-other-entry.js",
"ROOT/addons/backgrounds/dist/esm/preset/addParameter.js-generated-other-entry.js",
"ROOT/examples/react-ts/generated-stories-entry.js",
],
"module": Object {
"rules": Array [
Object {
"exclude": "/node_modules/",
"include": Array [
"ROOT",
],
"test": "/\\\\.(mjs|tsx?|jsx?)$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"cacheDirectory": "ROOT/node_modules/.cache/storybook/babel",
"overrides": Array [
Object {
"plugins": Array [
Array [
"ROOT/node_modules/babel-plugin-react-docgen/lib/index.js",
Object {
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES",
},
],
],
"test": "/\\\\.(mjs|jsx?)$/",
},
],
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
Array [
"ROOT/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
Object {
"autoLabel": true,
"sourceMap": true,
},
],
"ROOT/node_modules/babel-plugin-add-react-displayname/index.js",
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
Array [
"ROOT/node_modules/@babel/preset-react/lib/index.js",
Object {
"runtime": "automatic",
},
],
"ROOT/node_modules/@babel/preset-flow/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"include": [Function],
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"modules": false,
"shippedProposals": true,
"targets": "defaults",
},
],
"ROOT/node_modules/@babel/preset-react/lib/index.js",
],
"sourceType": "unambiguous",
},
},
],
},
Object {
"test": "/\\\\.md$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/raw-loader/dist/cjs.js",
},
],
},
Object {
"enforce": "pre",
"test": Array [
"/\\\\.stories\\\\.(jsx?$|tsx?$)/",
],
"use": Array [
Object {
"loader": "ROOT/lib/source-loader/dist/cjs/index.js",
"options": undefined,
},
],
},
Object {
"include": "/node_modules\\\\/acorn-jsx/",
"test": "/\\\\.js$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"modules": "commonjs",
},
],
],
},
},
],
},
Object {
"test": "/\\\\.(stories|story)\\\\.mdx$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"babelrc": false,
"cacheDirectory": "ROOT/node_modules/.cache/storybook/babel",
"configFile": false,
"overrides": Array [
Object {
"plugins": Array [
Array [
"ROOT/node_modules/babel-plugin-react-docgen/lib/index.js",
Object {
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES",
},
],
],
"test": "/\\\\.(mjs|jsx?)$/",
},
],
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
Array [
"ROOT/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
Object {
"autoLabel": true,
"sourceMap": true,
},
],
"ROOT/node_modules/babel-plugin-add-react-displayname/index.js",
Array [
"ROOT/addons/docs/node_modules/@babel/plugin-transform-react-jsx/lib/index.js",
Object {
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
Array [
"ROOT/node_modules/@babel/preset-react/lib/index.js",
Object {
"runtime": "automatic",
},
],
"ROOT/node_modules/@babel/preset-flow/lib/index.js",
],
"sourceType": "unambiguous",
},
},
Object {
"loader": "ROOT/node_modules/@mdx-js/loader/index.js",
"options": Object {
"compilers": Array [
[Function],
],
"remarkPlugins": Array [
[Function],
[Function],
],
},
},
],
},
Object {
"exclude": "/\\\\.(stories|story)\\\\.mdx$/",
"test": "/\\\\.mdx$/",
"use": Array [
Object {
"loader": "ROOT/node_modules/babel-loader/lib/index.js",
"options": Object {
"babelrc": false,
"cacheDirectory": "ROOT/node_modules/.cache/storybook/babel",
"configFile": false,
"overrides": Array [
Object {
"plugins": Array [
Array [
"ROOT/node_modules/babel-plugin-react-docgen/lib/index.js",
Object {
"DOC_GEN_COLLECTION_NAME": "STORYBOOK_REACT_CLASSES",
},
],
],
"test": "/\\\\.(mjs|jsx?)$/",
},
],
"plugins": Array [
"ROOT/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js",
"ROOT/lib/core/node_modules/@babel/plugin-transform-block-scoping/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-decorators/lib/index.js",
Object {
"legacy": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
Object {
"loose": true,
},
],
Array [
"ROOT/node_modules/@babel/plugin-proposal-private-methods/lib/index.js",
Object {
"loose": true,
},
],
"ROOT/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js",
"ROOT/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js",
Array [
"ROOT/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js",
Object {
"loose": true,
"useBuiltIns": true,
},
],
"ROOT/node_modules/@babel/plugin-transform-classes/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-arrow-functions/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-parameters/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-destructuring/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-spread/lib/index.js",
"ROOT/node_modules/@babel/plugin-transform-for-of/lib/index.js",
"ROOT/node_modules/babel-plugin-macros/dist/index.js",
"ROOT/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js",
"ROOT/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js",
Array [
"ROOT/node_modules/babel-plugin-polyfill-corejs3/lib/index.js",
Object {
"absoluteImports": "ROOT/node_modules/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
},
],
Array [
"ROOT/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.js",
Object {
"autoLabel": true,
"sourceMap": true,
},
],
"ROOT/node_modules/babel-plugin-add-react-displayname/index.js",
Array [
"ROOT/addons/docs/node_modules/@babel/plugin-transform-react-jsx/lib/index.js",
Object {
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
},
],
],
"presets": Array [
Array [
"ROOT/node_modules/@babel/preset-env/lib/index.js",
Object {
"shippedProposals": true,
},
],
"ROOT/node_modules/@babel/preset-typescript/lib/index.js",
Array [
"ROOT/node_modules/@babel/preset-react/lib/index.js",
Object {
"runtime": "automatic",
},
],
"ROOT/node_modules/@babel/preset-flow/lib/index.js",
],
"sourceType": "unambiguous",
},
},
Object {
"loader": "ROOT/node_modules/@mdx-js/loader/index.js",
"options": Object {
"remarkPlugins": Array [
[Function],
[Function],
],
},
},
],
},
Object {
"enforce": "pre",
"loader": "ROOT/lib/source-loader/dist/cjs/index.js",
"options": Object {
"injectStoryParameters": false,
"inspectLocalDependencies": true,
"parser": "typescript",
},
"test": "/\\\\.(stories|story)\\\\.[tj]sx?$/",
},
Object {
"sideEffects": true,
"test": "/\\\\.css$/",
"use": Array [
"ROOT/lib/core/node_modules/style-loader/dist/cjs.js",
Object {
"loader": "ROOT/node_modules/css-loader/dist/cjs.js",
"options": Object {
"importLoaders": 1,
},
},
Object {
"loader": "ROOT/lib/core/node_modules/postcss-loader/dist/cjs.js",
"options": Object {
"postcssOptions": [Function],
},
},
],
},
Object {
"loader": "ROOT/lib/core/node_modules/file-loader/dist/cjs.js",
"options": Object {
"esModule": false,
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\\\?.*)?$/",
},
Object {
"loader": "ROOT/lib/core/node_modules/url-loader/dist/cjs.js",
"query": Object {
"limit": 10000,
"name": "static/media/[name].[hash:8].[ext]",
},
"test": "/\\\\.(mp4|webm|wav|mp3|m4a|aac|oga)(\\\\?.*)?$/",
},
],
},
"plugins": Array [
"FilterWarningsPlugin",
"VirtualModulesPlugin",
"HtmlWebpackPlugin",
"DefinePlugin",
"CaseSensitivePathsPlugin",
"ProgressPlugin",
"DefinePlugin",
"ForkTsCheckerWebpackPlugin",
"DocgenPlugin",
],
}
`;

View File

@ -131,7 +131,7 @@ async function buildManager(configType: any, outputDir: string, configDir: strin
configType,
outputDir,
configDir,
corePresets: [require.resolve('./manager/manager-preset.js')],
corePresets: [require.resolve('./manager/manager-preset')],
});
if (options.debugWebpack) {
@ -153,8 +153,8 @@ async function buildPreview(configType: any, outputDir: string, packageJson: any
configType,
outputDir,
packageJson,
corePresets: [require.resolve('./preview/preview-preset.js')],
overridePresets: [require.resolve('./preview/custom-webpack-preset.js')],
corePresets: [require.resolve('./preview/preview-preset')],
overridePresets: [require.resolve('./preview/custom-webpack-preset')],
});
if (debugWebpack) {

View File

@ -0,0 +1,118 @@
import 'jest-specific-snapshot';
import path from 'path';
import webpack, { Configuration, Stats } from 'webpack';
import Cache from 'file-system-cache';
import { Config } from 'html-webpack-plugin';
import { buildDevStandalone } from './build-dev';
import { buildStaticStandalone } from './build-static';
import { resolvePathInStorybookCache } from './utils/resolve-path-in-sb-cache';
import reactOptions from '../../../../app/react/src/server/options';
const TIMEOUT = 10000;
const mockStats = {
hasErrors: () => false,
hasWarnings: () => false,
toJson: () => ({ warnings: [], errors: [] }),
};
const webpackStub = (cb) => {
return cb(null, mockStats);
};
const middlewareStub = (_req, _resp, next) => next();
middlewareStub.waitUntilValid = (cb) => cb(mockStats);
jest.mock('webpack-hot-middleware', () => () => middlewareStub);
jest.mock('webpack-dev-middleware', () => () => middlewareStub);
jest.mock('webpack', () => {
const actualWebpack = jest.requireActual('webpack');
return {
__esModule: true, // this property makes it work
default: jest.fn((...args) => {
const compiler = actualWebpack(...args);
compiler.watch = jest.fn(webpackStub);
compiler.run = jest.fn(webpackStub);
return compiler;
}),
...actualWebpack,
};
});
const cache = Cache({
basePath: resolvePathInStorybookCache('dev-server'),
ns: 'storybook-test', // Optional. A grouping namespace for items.
});
const managerOnly = false;
const options = {
...reactOptions,
ignorePreview: managerOnly,
// FIXME: this should just be ignorePreview everywhere
managerOnly, // production
docsMode: false,
cache,
configDir: path.resolve(`${__dirname}/../../../../examples/react-ts`),
outputDir: `${__dirname}/storybook-static`, // production
ci: true,
managerCache: false,
};
const ROOT = process.cwd();
const cleanRoots = (obj): any => {
if (!obj) return obj;
if (typeof obj === 'string') return obj.replace(ROOT, 'ROOT');
if (Array.isArray(obj)) return obj.map(cleanRoots);
if (obj instanceof RegExp) return cleanRoots(obj.toString());
if (typeof obj === 'object') {
return Object.fromEntries(
Object.entries(obj).map(([key, val]) => {
return [key, cleanRoots(val)];
})
);
}
return obj;
};
const prepareSnap = (fn: any, name): Pick<Configuration, 'module' | 'entry' | 'plugins'> => {
const call = fn.mock.calls.find((c) => c[0].name === name);
if (!call) return null;
const { module, entry, plugins } = call[0];
return cleanRoots({ module, entry, plugins: plugins.map((p) => p.constructor.name) });
};
const snap = (name: string) => `__snapshots__/${name}.snap`;
describe('core presets', () => {
beforeEach(() => {
jest.clearAllMocks();
cache.clear();
});
it(
'dev mode',
async () => {
const result = await buildDevStandalone(options);
expect(webpack).toHaveBeenCalled();
const managerConfig = prepareSnap(webpack, 'manager');
expect(managerConfig).toMatchSpecificSnapshot(snap('manager-dev'));
const previewConfig = prepareSnap(webpack, 'preview');
expect(previewConfig).toMatchSpecificSnapshot(snap('preview-dev'));
},
TIMEOUT
);
it(
'production mode',
async () => {
const result = await buildStaticStandalone(options);
expect(webpack).toHaveBeenCalled();
const managerConfig = prepareSnap(webpack, 'manager');
expect(managerConfig).toMatchSpecificSnapshot(snap('manager-prod'));
const previewConfig = prepareSnap(webpack, 'preview');
expect(previewConfig).toMatchSpecificSnapshot(snap('preview-prod'));
},
TIMEOUT
);
});

View File

@ -229,7 +229,7 @@ const startManager = async ({
outputDir,
configDir,
cache,
corePresets: [require.resolve('./manager/manager-preset.js')],
corePresets: [require.resolve(`./manager/manager-preset`)],
...options,
});
@ -253,7 +253,6 @@ const startManager = async ({
}
}
}
if (!managerConfig) {
return {};
}
@ -316,8 +315,8 @@ const startPreview = async ({
configType,
outputDir,
cache,
corePresets: [require.resolve('./preview/preview-preset.js')],
overridePresets: [require.resolve('./preview/custom-webpack-preset.js')],
corePresets: [require.resolve('./preview/preview-preset')],
overridePresets: [require.resolve('./preview/custom-webpack-preset')],
...options,
});

View File

@ -163,7 +163,7 @@ const loadConfig: (
const presetsConfig = [
...corePresets,
require.resolve('../common/babel-cache-preset.js'),
require.resolve(`../common/babel-cache-preset`),
...frameworkPresets,
...loadCustomPresets(options),
...overridePresets,

View File

@ -71,13 +71,9 @@ export default async ({
const { raw, stringified } = loadEnv({ production: true });
const babelLoader = createBabelLoader(babelOptions, framework);
const isProd = configType === 'PRODUCTION';
const entryTemplate = await fse.readFile(
// TODO ANDREW maybe something simpler
path.join(__dirname, '../../../esm/server/preview', 'virtualModuleEntry.template.js'),
{
encoding: 'utf8',
}
);
const entryTemplate = await fse.readFile(path.join(__dirname, 'virtualModuleEntry.template.js'), {
encoding: 'utf8',
});
const storyTemplate = await fse.readFile(path.join(__dirname, 'virtualModuleStory.template.js'), {
encoding: 'utf8',
});
@ -116,6 +112,7 @@ export default async ({
const tsCheckOptions = typescriptOptions.checkOptions || {};
return {
name: 'preview',
mode: isProd ? 'production' : 'development',
bail: isProd,
devtool: '#cheap-module-source-map',