mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
Merge branch 'next' into 14118-update-react-docgen-typescript-plugin
This commit is contained in:
commit
8480e91fa3
@ -155,7 +155,6 @@ export interface BuilderOptions {
|
||||
docsMode: boolean;
|
||||
versionCheck?: VersionCheck;
|
||||
releaseNotesData?: ReleaseNotesData;
|
||||
skipStoriesJson?: boolean;
|
||||
}
|
||||
|
||||
export interface StorybookConfigOptions {
|
||||
@ -238,6 +237,7 @@ export interface StorybookConfig {
|
||||
*/
|
||||
features?: {
|
||||
postcss?: boolean;
|
||||
buildStoriesJson?: boolean;
|
||||
};
|
||||
/**
|
||||
* Tells Storybook where to find stories.
|
||||
|
@ -216,3 +216,220 @@ Object {
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`cra-ts-essentials manager production mode 1`] = `
|
||||
Object {
|
||||
"entry": Array [
|
||||
"ROOT/lib/core-server/src/globals/polyfills.ts",
|
||||
"ROOT/lib/core-client/dist/esm/manager/index.js",
|
||||
"ROOT/addons/docs/dist/esm/register.js",
|
||||
"ROOT/addons/controls/dist/esm/register.js",
|
||||
"ROOT/addons/actions/dist/esm/register.js",
|
||||
"ROOT/addons/backgrounds/dist/esm/register.js",
|
||||
"ROOT/addons/toolbars/dist/esm/register.js",
|
||||
"ROOT/examples/cra-ts-essentials/.storybook/generated-refs.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 {
|
||||
"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-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 {
|
||||
"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-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 {
|
||||
"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)(\\\\?.*)?$/",
|
||||
},
|
||||
],
|
||||
},
|
||||
"plugins": Array [
|
||||
"VirtualModulesPlugin",
|
||||
"HtmlWebpackPlugin",
|
||||
"CaseSensitivePathsPlugin",
|
||||
"DefinePlugin",
|
||||
"DefinePlugin",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
@ -432,3 +432,5 @@ Object {
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`vue-3-cli manager dev mode 1`] = `null`;
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
BuilderOptions,
|
||||
Options,
|
||||
Builder,
|
||||
StorybookConfig,
|
||||
} from '@storybook/core-common';
|
||||
import * as managerBuilder from './manager/builder';
|
||||
|
||||
@ -70,8 +71,9 @@ export async function buildStaticStandalone(options: CLIOptions & LoadOptions &
|
||||
presets,
|
||||
};
|
||||
|
||||
const storiesGlobs = (await presets.apply('stories')) as string[];
|
||||
if (!options.skipStoriesJson) {
|
||||
const features = await presets.apply<StorybookConfig['features']>('features');
|
||||
if (features.buildStoriesJson) {
|
||||
const storiesGlobs = (await presets.apply('stories')) as StorybookConfig['stories'];
|
||||
await extractStoriesJson(
|
||||
path.join(options.outputDir, 'stories.json'),
|
||||
storiesGlobs,
|
||||
|
@ -22,10 +22,13 @@ import { outputStats } from './utils/output-stats';
|
||||
// this only applies to this file
|
||||
jest.setTimeout(10000);
|
||||
|
||||
const skipStoriesJsonPreset = [{ features: { buildStoriesJson: false } }];
|
||||
|
||||
jest.mock('@storybook/builder-webpack5', () => {
|
||||
const actualBuilder = jest.requireActual('@storybook/builder-webpack5');
|
||||
// MUTATION! we couldn't mock webpack5, so we added a level of indirection instead
|
||||
actualBuilder.executor.get = jest.fn();
|
||||
actualBuilder.overridePresets = [...actualBuilder.overridePresets, skipStoriesJsonPreset];
|
||||
return actualBuilder;
|
||||
});
|
||||
|
||||
@ -33,6 +36,7 @@ jest.mock('@storybook/builder-webpack4', () => {
|
||||
const actualBuilder = jest.requireActual('@storybook/builder-webpack4');
|
||||
// MUTATION! we couldn't mock webpack5, so we added a level of indirection instead
|
||||
actualBuilder.executor.get = jest.fn();
|
||||
actualBuilder.overridePresets = [...actualBuilder.overridePresets, skipStoriesJsonPreset];
|
||||
return actualBuilder;
|
||||
});
|
||||
|
||||
@ -133,7 +137,6 @@ describe.each([
|
||||
...baseOptions,
|
||||
...frameworkOptions,
|
||||
configDir: path.resolve(`${__dirname}/../../../examples/${example}/.storybook`),
|
||||
skipStoriesJson: true,
|
||||
};
|
||||
|
||||
describe('manager', () => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import express, { Router } from 'express';
|
||||
import compression from 'compression';
|
||||
|
||||
import { Builder, logConfig, Options } from '@storybook/core-common';
|
||||
import { Builder, logConfig, Options, StorybookConfig } from '@storybook/core-common';
|
||||
|
||||
import { getMiddleware } from './utils/middleware';
|
||||
import { getServerAddresses } from './utils/server-address';
|
||||
@ -36,7 +36,9 @@ export async function storybookDevServer(options: Options) {
|
||||
|
||||
// User's own static files
|
||||
await useStatics(router, options);
|
||||
if (!options.skipStoriesJson) {
|
||||
|
||||
const features = await options.presets.apply<StorybookConfig['features']>('features');
|
||||
if (!features.buildStoriesJson) {
|
||||
await useStoriesJson(router, options);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user