@storybook/builder-webpack5 9.2.0-alpha.2 → 10.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/_node-chunks/chunk-7AGS6CMF.js +50 -0
- package/dist/_node-chunks/chunk-7H4S5AJT.js +85 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1032 -1
- package/dist/loaders/export-order-loader.js +58 -1
- package/dist/presets/custom-webpack-preset.js +154 -1
- package/dist/presets/preview-preset.js +279 -2
- package/package.json +26 -45
- package/dist/chunk-LGGOBZAG.mjs +0 -3
- package/dist/index.mjs +0 -19
- package/dist/loaders/export-order-loader.d.ts +0 -5
- package/dist/loaders/export-order-loader.mjs +0 -9
- package/dist/presets/custom-webpack-preset.d.ts +0 -10
- package/dist/presets/preview-preset.d.ts +0 -7
|
@@ -1 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_lton03yky7 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_lton03yky7 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_lton03yky7 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_lton03yky7.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_lton03yky7.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_lton03yky7.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "../_node-chunks/chunk-7AGS6CMF.js";
|
|
15
|
+
|
|
16
|
+
// src/loaders/export-order-loader.ts
|
|
17
|
+
import assert from "node:assert";
|
|
18
|
+
import { init as initCjsParser, parse as parseCjs } from "cjs-module-lexer";
|
|
19
|
+
import { parse as parseEs } from "es-module-lexer";
|
|
20
|
+
import MagicString from "magic-string";
|
|
21
|
+
async function loader(source, map, meta) {
|
|
22
|
+
const callback = this.async();
|
|
23
|
+
try {
|
|
24
|
+
const magicString = new MagicString(source);
|
|
25
|
+
if (!source.includes("__namedExportsOrder")) {
|
|
26
|
+
try {
|
|
27
|
+
const parseResult = await parseEs(source);
|
|
28
|
+
const namedExportsOrder = (parseResult[1] || []).map((e) => source.substring(e.s, e.e)).filter((e) => e !== "default");
|
|
29
|
+
assert(
|
|
30
|
+
namedExportsOrder.length > 0,
|
|
31
|
+
"No named exports found. Very likely that this is not a ES module."
|
|
32
|
+
);
|
|
33
|
+
magicString.append(
|
|
34
|
+
`;export const __namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
|
|
35
|
+
);
|
|
36
|
+
} catch {
|
|
37
|
+
await initCjsParser();
|
|
38
|
+
const namedExportsOrder = (parseCjs(source).exports || []).filter(
|
|
39
|
+
(e) => e !== "default" && e !== "__esModule"
|
|
40
|
+
);
|
|
41
|
+
assert(
|
|
42
|
+
namedExportsOrder.length > 0,
|
|
43
|
+
"No named exports found. Very likely that this is not a CJS module."
|
|
44
|
+
);
|
|
45
|
+
magicString.append(
|
|
46
|
+
`;module.exports.__namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return callback(null, magicString.toString(), map, meta);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
return callback(null, source, map, meta);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
__name(loader, "loader");
|
|
56
|
+
export {
|
|
57
|
+
loader as default
|
|
58
|
+
};
|
|
@@ -1 +1,154 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_lton03yky7 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_lton03yky7 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_lton03yky7 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_lton03yky7.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_lton03yky7.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_lton03yky7.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "../_node-chunks/chunk-7AGS6CMF.js";
|
|
15
|
+
|
|
16
|
+
// src/presets/custom-webpack-preset.ts
|
|
17
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
18
|
+
import { loadCustomWebpackConfig } from "@storybook/core-webpack";
|
|
19
|
+
import webpackModule from "webpack";
|
|
20
|
+
|
|
21
|
+
// src/preview/base-webpack.config.ts
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { logger } from "storybook/internal/node-logger";
|
|
24
|
+
async function createDefaultWebpackConfig(storybookBaseConfig, options) {
|
|
25
|
+
if (options.presetsList?.some(
|
|
26
|
+
(preset) => /@storybook(\/|\\)preset-create-react-app/.test(
|
|
27
|
+
typeof preset === "string" ? preset : preset.name
|
|
28
|
+
)
|
|
29
|
+
)) {
|
|
30
|
+
return storybookBaseConfig;
|
|
31
|
+
}
|
|
32
|
+
const hasPostcssAddon = options.presetsList?.some(
|
|
33
|
+
(preset) => /@storybook(\/|\\)addon-postcss/.test(typeof preset === "string" ? preset : preset.name)
|
|
34
|
+
);
|
|
35
|
+
let cssLoaders = {};
|
|
36
|
+
if (!hasPostcssAddon) {
|
|
37
|
+
logger.info(`=> Using implicit CSS loaders`);
|
|
38
|
+
cssLoaders = {
|
|
39
|
+
test: /\.css$/,
|
|
40
|
+
sideEffects: true,
|
|
41
|
+
use: [
|
|
42
|
+
// TODO: Decide if we want to keep style-loader & css-loader in core
|
|
43
|
+
// Trying to apply style-loader or css-loader to files that already have been
|
|
44
|
+
// processed by them causes webpack to crash, so no one else can add similar
|
|
45
|
+
// loader configurations to the `.css` extension.
|
|
46
|
+
fileURLToPath(import.meta.resolve("style-loader")),
|
|
47
|
+
{
|
|
48
|
+
loader: fileURLToPath(import.meta.resolve("css-loader")),
|
|
49
|
+
options: {
|
|
50
|
+
importLoaders: 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const isProd = storybookBaseConfig.mode !== "development";
|
|
57
|
+
return {
|
|
58
|
+
...storybookBaseConfig,
|
|
59
|
+
module: {
|
|
60
|
+
...storybookBaseConfig.module,
|
|
61
|
+
rules: [
|
|
62
|
+
...storybookBaseConfig.module?.rules || [],
|
|
63
|
+
cssLoaders,
|
|
64
|
+
{
|
|
65
|
+
test: /\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
|
|
66
|
+
type: "asset/resource",
|
|
67
|
+
generator: {
|
|
68
|
+
filename: isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
|
|
73
|
+
type: "asset",
|
|
74
|
+
parser: {
|
|
75
|
+
dataUrlCondition: {
|
|
76
|
+
maxSize: 1e4
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
generator: {
|
|
80
|
+
filename: isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
// any imports from './some-file.md?raw' will be imported as raw string
|
|
85
|
+
// see https://webpack.js.org/guides/asset-modules/#replacing-inline-loader-syntax
|
|
86
|
+
// used to support import raw .md files in MDX
|
|
87
|
+
resourceQuery: /raw/,
|
|
88
|
+
type: "asset/source"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
resolve: {
|
|
93
|
+
...storybookBaseConfig.resolve,
|
|
94
|
+
// see https://github.com/webpack/webpack/issues/17692#issuecomment-1866272674 for the docs
|
|
95
|
+
conditionNames: [
|
|
96
|
+
...storybookBaseConfig.resolve?.conditionNames ?? [],
|
|
97
|
+
"storybook",
|
|
98
|
+
"stories",
|
|
99
|
+
"test",
|
|
100
|
+
"..."
|
|
101
|
+
],
|
|
102
|
+
fallback: {
|
|
103
|
+
crypto: false,
|
|
104
|
+
assert: false,
|
|
105
|
+
...storybookBaseConfig.resolve?.fallback
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
__name(createDefaultWebpackConfig, "createDefaultWebpackConfig");
|
|
111
|
+
|
|
112
|
+
// src/presets/custom-webpack-preset.ts
|
|
113
|
+
var swc = /* @__PURE__ */ __name((config) => {
|
|
114
|
+
return {
|
|
115
|
+
...config,
|
|
116
|
+
env: {
|
|
117
|
+
...config?.env ?? {},
|
|
118
|
+
targets: config?.env?.targets ?? {
|
|
119
|
+
chrome: 100,
|
|
120
|
+
safari: 15,
|
|
121
|
+
firefox: 91
|
|
122
|
+
},
|
|
123
|
+
// Transpiles the broken syntax to the closest non-broken modern syntax.
|
|
124
|
+
// E.g. it won't transpile parameter destructuring in Safari
|
|
125
|
+
// which would break how we detect if the mount context property is used in the play function.
|
|
126
|
+
bugfixes: config?.env?.bugfixes ?? true
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}, "swc");
|
|
130
|
+
async function webpack(config, options) {
|
|
131
|
+
const { configDir, configType, presets } = options;
|
|
132
|
+
const coreOptions = await presets.apply("core");
|
|
133
|
+
let defaultConfig = config;
|
|
134
|
+
if (!coreOptions?.disableWebpackDefaults) {
|
|
135
|
+
defaultConfig = await createDefaultWebpackConfig(config, options);
|
|
136
|
+
}
|
|
137
|
+
const finalDefaultConfig = await presets.apply("webpackFinal", defaultConfig, options);
|
|
138
|
+
const customConfig = await loadCustomWebpackConfig(configDir);
|
|
139
|
+
if (typeof customConfig === "function") {
|
|
140
|
+
logger2.info("=> Loading custom Webpack config (full-control mode).");
|
|
141
|
+
return customConfig({ config: finalDefaultConfig, mode: configType });
|
|
142
|
+
}
|
|
143
|
+
logger2.info("=> Using default Webpack5 setup");
|
|
144
|
+
return finalDefaultConfig;
|
|
145
|
+
}
|
|
146
|
+
__name(webpack, "webpack");
|
|
147
|
+
var webpackInstance = /* @__PURE__ */ __name(async () => webpackModule, "webpackInstance");
|
|
148
|
+
var webpackVersion = /* @__PURE__ */ __name(async () => "5", "webpackVersion");
|
|
149
|
+
export {
|
|
150
|
+
swc,
|
|
151
|
+
webpack,
|
|
152
|
+
webpackInstance,
|
|
153
|
+
webpackVersion
|
|
154
|
+
};
|
|
@@ -1,6 +1,283 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_lton03yky7 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_lton03yky7 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_lton03yky7 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_lton03yky7.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_lton03yky7.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_lton03yky7.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
getVirtualModules
|
|
14
|
+
} from "../_node-chunks/chunk-7H4S5AJT.js";
|
|
15
|
+
import {
|
|
16
|
+
__name
|
|
17
|
+
} from "../_node-chunks/chunk-7AGS6CMF.js";
|
|
18
|
+
|
|
19
|
+
// src/presets/preview-preset.ts
|
|
20
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
21
|
+
|
|
22
|
+
// src/preview/iframe-webpack.config.ts
|
|
23
|
+
import { join, resolve } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
import {
|
|
26
|
+
getBuilderOptions,
|
|
27
|
+
isPreservingSymlinks,
|
|
28
|
+
normalizeStories,
|
|
29
|
+
stringifyProcessEnvs
|
|
30
|
+
} from "storybook/internal/common";
|
|
31
|
+
import { globalsNameReferenceMap } from "storybook/internal/preview/globals";
|
|
32
|
+
import CaseSensitivePathsPlugin from "case-sensitive-paths-webpack-plugin";
|
|
33
|
+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
|
34
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
35
|
+
import TerserWebpackPlugin from "terser-webpack-plugin";
|
|
36
|
+
import { dedent } from "ts-dedent";
|
|
37
|
+
import webpackModule from "webpack";
|
|
38
|
+
import VirtualModulePlugin from "webpack-virtual-modules";
|
|
39
|
+
var { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin } = webpackModule;
|
|
40
|
+
var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
41
|
+
const {
|
|
42
|
+
outputDir = join(".", "public"),
|
|
43
|
+
quiet,
|
|
44
|
+
packageJson,
|
|
45
|
+
configType,
|
|
46
|
+
presets,
|
|
47
|
+
previewUrl,
|
|
48
|
+
typescriptOptions,
|
|
49
|
+
features
|
|
50
|
+
} = options;
|
|
51
|
+
const isProd = configType === "PRODUCTION";
|
|
52
|
+
const workingDir = process.cwd();
|
|
53
|
+
const [
|
|
54
|
+
coreOptions,
|
|
55
|
+
frameworkOptions,
|
|
56
|
+
envs,
|
|
57
|
+
logLevel,
|
|
58
|
+
headHtmlSnippet,
|
|
59
|
+
bodyHtmlSnippet,
|
|
60
|
+
template,
|
|
61
|
+
docsOptions,
|
|
62
|
+
entries2,
|
|
63
|
+
nonNormalizedStories,
|
|
64
|
+
modulesCount,
|
|
65
|
+
build,
|
|
66
|
+
tagsOptions
|
|
67
|
+
] = await Promise.all([
|
|
68
|
+
presets.apply("core"),
|
|
69
|
+
presets.apply("frameworkOptions"),
|
|
70
|
+
presets.apply("env"),
|
|
71
|
+
presets.apply("logLevel", void 0),
|
|
72
|
+
presets.apply("previewHead"),
|
|
73
|
+
presets.apply("previewBody"),
|
|
74
|
+
presets.apply("previewMainTemplate"),
|
|
75
|
+
presets.apply("docs"),
|
|
76
|
+
presets.apply("entries", []),
|
|
77
|
+
presets.apply("stories", []),
|
|
78
|
+
options.cache?.get("modulesCount", 1e3),
|
|
79
|
+
options.presets.apply("build"),
|
|
80
|
+
presets.apply("tags", {})
|
|
81
|
+
]);
|
|
82
|
+
const stories = normalizeStories(nonNormalizedStories, {
|
|
83
|
+
configDir: options.configDir,
|
|
84
|
+
workingDir
|
|
85
|
+
});
|
|
86
|
+
const builderOptions = await getBuilderOptions(options);
|
|
87
|
+
const shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipCompiler;
|
|
88
|
+
const tsCheckOptions = typescriptOptions.checkOptions || {};
|
|
89
|
+
const cacheConfig = builderOptions.fsCache ? { cache: { type: "filesystem" } } : {};
|
|
90
|
+
const lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
|
91
|
+
lazyCompilation: { entries: false }
|
|
92
|
+
} : {};
|
|
93
|
+
if (!template) {
|
|
94
|
+
throw new Error(dedent`
|
|
2
95
|
Storybook's Webpack5 builder requires a template to be specified.
|
|
3
96
|
Somehow you've ended up with a falsy value for the template option.
|
|
4
97
|
|
|
5
98
|
Please file an issue at https://github.com/storybookjs/storybook with a reproduction.
|
|
6
|
-
`);
|
|
99
|
+
`);
|
|
100
|
+
}
|
|
101
|
+
const externals = globalsNameReferenceMap;
|
|
102
|
+
if (build?.test?.disableBlocks) {
|
|
103
|
+
externals["@storybook/addon-docs/blocks"] = "__STORYBOOK_BLOCKS_EMPTY_MODULE__";
|
|
104
|
+
}
|
|
105
|
+
const { virtualModules: virtualModuleMapping, entries: dynamicEntries } = await getVirtualModules(options);
|
|
106
|
+
return {
|
|
107
|
+
name: "preview",
|
|
108
|
+
mode: isProd ? "production" : "development",
|
|
109
|
+
bail: isProd,
|
|
110
|
+
devtool: options.build?.test?.disableSourcemaps ? false : "cheap-module-source-map",
|
|
111
|
+
entry: [...entries2 ?? [], ...dynamicEntries],
|
|
112
|
+
output: {
|
|
113
|
+
path: resolve(process.cwd(), outputDir),
|
|
114
|
+
filename: isProd ? "[name].[contenthash:8].iframe.bundle.js" : "[name].iframe.bundle.js",
|
|
115
|
+
publicPath: ""
|
|
116
|
+
},
|
|
117
|
+
stats: {
|
|
118
|
+
preset: "none",
|
|
119
|
+
logging: "error"
|
|
120
|
+
},
|
|
121
|
+
watchOptions: {
|
|
122
|
+
ignored: /node_modules/
|
|
123
|
+
},
|
|
124
|
+
externals,
|
|
125
|
+
ignoreWarnings: [
|
|
126
|
+
{
|
|
127
|
+
message: /export '\S+' was not found in 'global'/
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
message: /export '\S+' was not found in '@storybook\/global'/
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
plugins: [
|
|
134
|
+
Object.keys(virtualModuleMapping).length > 0 ? new VirtualModulePlugin(virtualModuleMapping) : null,
|
|
135
|
+
new HtmlWebpackPlugin({
|
|
136
|
+
filename: `iframe.html`,
|
|
137
|
+
// FIXME: `none` isn't a known option
|
|
138
|
+
chunksSortMode: "none",
|
|
139
|
+
alwaysWriteToDisk: true,
|
|
140
|
+
inject: false,
|
|
141
|
+
template,
|
|
142
|
+
templateParameters: {
|
|
143
|
+
version: packageJson?.version,
|
|
144
|
+
globals: {
|
|
145
|
+
CONFIG_TYPE: configType,
|
|
146
|
+
LOGLEVEL: logLevel,
|
|
147
|
+
FRAMEWORK_OPTIONS: frameworkOptions,
|
|
148
|
+
CHANNEL_OPTIONS: coreOptions.channelOptions,
|
|
149
|
+
FEATURES: features,
|
|
150
|
+
PREVIEW_URL: previewUrl,
|
|
151
|
+
STORIES: stories.map((specifier) => ({
|
|
152
|
+
...specifier,
|
|
153
|
+
importPathMatcher: specifier.importPathMatcher.source
|
|
154
|
+
})),
|
|
155
|
+
DOCS_OPTIONS: docsOptions,
|
|
156
|
+
TAGS_OPTIONS: tagsOptions,
|
|
157
|
+
...build?.test?.disableBlocks ? { __STORYBOOK_BLOCKS_EMPTY_MODULE__: {} } : {}
|
|
158
|
+
},
|
|
159
|
+
headHtmlSnippet,
|
|
160
|
+
bodyHtmlSnippet
|
|
161
|
+
},
|
|
162
|
+
minify: {
|
|
163
|
+
collapseWhitespace: true,
|
|
164
|
+
removeComments: true,
|
|
165
|
+
removeRedundantAttributes: true,
|
|
166
|
+
removeScriptTypeAttributes: false,
|
|
167
|
+
removeStyleLinkTypeAttributes: true,
|
|
168
|
+
useShortDoctype: true
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
new DefinePlugin({
|
|
172
|
+
...stringifyProcessEnvs(envs),
|
|
173
|
+
NODE_ENV: JSON.stringify(
|
|
174
|
+
features?.developmentModeForBuild && isProd ? "development" : process.env.NODE_ENV
|
|
175
|
+
)
|
|
176
|
+
}),
|
|
177
|
+
isProd ? null : new HotModuleReplacementPlugin(),
|
|
178
|
+
new CaseSensitivePathsPlugin(),
|
|
179
|
+
quiet ? null : new ProgressPlugin({ modulesCount }),
|
|
180
|
+
shouldCheckTs ? new ForkTsCheckerWebpackPlugin(tsCheckOptions) : null
|
|
181
|
+
].filter(Boolean),
|
|
182
|
+
module: {
|
|
183
|
+
// Disable warning for dynamic requires
|
|
184
|
+
unknownContextCritical: false,
|
|
185
|
+
rules: [
|
|
186
|
+
{
|
|
187
|
+
test: /\.stories\.([tj])sx?$|(stories|story)\.mdx$/,
|
|
188
|
+
exclude: /node_modules/,
|
|
189
|
+
enforce: "post",
|
|
190
|
+
use: [
|
|
191
|
+
{
|
|
192
|
+
loader: fileURLToPath(
|
|
193
|
+
import.meta.resolve("@storybook/builder-webpack5/loaders/export-order-loader")
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
test: /\.m?js$/,
|
|
200
|
+
type: "javascript/auto"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
test: /\.m?js$/,
|
|
204
|
+
resolve: {
|
|
205
|
+
fullySpecified: false
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
test: /\.md$/,
|
|
210
|
+
type: "asset/source"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
resolve: {
|
|
215
|
+
extensions: [".mjs", ".js", ".jsx", ".ts", ".tsx", ".json", ".cjs"],
|
|
216
|
+
modules: ["node_modules"].concat(envs.NODE_PATH || []),
|
|
217
|
+
mainFields: ["browser", "module", "main"].filter(Boolean),
|
|
218
|
+
// Set webpack to resolve symlinks based on whether the user has asked node to.
|
|
219
|
+
// This feels like it should be default out-of-the-box in webpack :shrug:
|
|
220
|
+
symlinks: !isPreservingSymlinks()
|
|
221
|
+
},
|
|
222
|
+
optimization: {
|
|
223
|
+
splitChunks: {
|
|
224
|
+
chunks: "all"
|
|
225
|
+
},
|
|
226
|
+
runtimeChunk: true,
|
|
227
|
+
sideEffects: true,
|
|
228
|
+
usedExports: options.build?.test?.disableTreeShaking ? false : isProd,
|
|
229
|
+
moduleIds: "named",
|
|
230
|
+
...isProd ? {
|
|
231
|
+
minimize: true,
|
|
232
|
+
minimizer: options.build?.test?.esbuildMinify ? [
|
|
233
|
+
new TerserWebpackPlugin({
|
|
234
|
+
parallel: true,
|
|
235
|
+
minify: TerserWebpackPlugin.esbuildMinify,
|
|
236
|
+
terserOptions: {
|
|
237
|
+
sourcemap: !options.build?.test?.disableSourcemaps,
|
|
238
|
+
treeShaking: !options.build?.test?.disableTreeShaking
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
] : [
|
|
242
|
+
new TerserWebpackPlugin({
|
|
243
|
+
parallel: true,
|
|
244
|
+
terserOptions: {
|
|
245
|
+
sourceMap: !options.build?.test?.disableSourcemaps,
|
|
246
|
+
mangle: false,
|
|
247
|
+
keep_fnames: true
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
} : {}
|
|
252
|
+
},
|
|
253
|
+
performance: {
|
|
254
|
+
hints: isProd ? "warning" : false
|
|
255
|
+
},
|
|
256
|
+
...cacheConfig,
|
|
257
|
+
experiments: { ...lazyCompilationConfig }
|
|
258
|
+
};
|
|
259
|
+
}, "default");
|
|
260
|
+
|
|
261
|
+
// src/presets/preview-preset.ts
|
|
262
|
+
var webpack = /* @__PURE__ */ __name(async (_, options) => iframe_webpack_config_default(options), "webpack");
|
|
263
|
+
var entries = /* @__PURE__ */ __name(async (_, options) => {
|
|
264
|
+
let result = [];
|
|
265
|
+
if (options.configType === "DEVELOPMENT") {
|
|
266
|
+
result = result.concat(
|
|
267
|
+
`${fileURLToPath2(
|
|
268
|
+
import.meta.resolve("webpack-hot-middleware/client.js")
|
|
269
|
+
)}?reload=true&quiet=false&overlay=${JSON.stringify({
|
|
270
|
+
errors: true,
|
|
271
|
+
warnings: false,
|
|
272
|
+
runtimeErrors: false
|
|
273
|
+
})}&noInfo=${options.quiet}`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
}, "entries");
|
|
278
|
+
var previewMainTemplate = /* @__PURE__ */ __name(() => fileURLToPath2(import.meta.resolve("@storybook/builder-webpack5/templates/preview.ejs")), "previewMainTemplate");
|
|
279
|
+
export {
|
|
280
|
+
entries,
|
|
281
|
+
previewMainTemplate,
|
|
282
|
+
webpack
|
|
283
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/builder-webpack5",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Storybook
|
|
3
|
+
"version": "10.0.0-beta.0",
|
|
4
|
+
"description": "A Storybook builder to dev and build with Webpack",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"storybook"
|
|
6
|
+
"storybook",
|
|
7
|
+
"storybook-builder",
|
|
8
|
+
"webpack",
|
|
9
|
+
"builder",
|
|
10
|
+
"bundler",
|
|
11
|
+
"component",
|
|
12
|
+
"components"
|
|
7
13
|
],
|
|
8
14
|
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/builders/builder-webpack5",
|
|
9
15
|
"bugs": {
|
|
@@ -19,37 +25,21 @@
|
|
|
19
25
|
"url": "https://opencollective.com/storybook"
|
|
20
26
|
},
|
|
21
27
|
"license": "MIT",
|
|
28
|
+
"type": "module",
|
|
22
29
|
"exports": {
|
|
23
30
|
".": {
|
|
24
31
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"
|
|
26
|
-
"import": "./dist/index.mjs",
|
|
27
|
-
"require": "./dist/index.js"
|
|
32
|
+
"default": "./dist/index.js"
|
|
28
33
|
},
|
|
29
|
-
"./
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
"./presets/preview-preset": {
|
|
35
|
-
"types": "./dist/presets/preview-preset.d.ts",
|
|
36
|
-
"node": "./dist/presets/preview-preset.js",
|
|
37
|
-
"require": "./dist/presets/preview-preset.js"
|
|
38
|
-
},
|
|
39
|
-
"./loaders/export-order-loader": {
|
|
40
|
-
"types": "./dist/loaders/export-order-loader.d.ts",
|
|
41
|
-
"node": "./dist/loaders/export-order-loader.js",
|
|
42
|
-
"require": "./dist/loaders/export-order-loader.js"
|
|
43
|
-
},
|
|
44
|
-
"./templates/virtualModuleModernEntry.js": "./templates/virtualModuleModernEntry.js",
|
|
34
|
+
"./loaders/export-order-loader": "./dist/loaders/export-order-loader.js",
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
"./presets/custom-webpack-preset": "./dist/presets/custom-webpack-preset.js",
|
|
37
|
+
"./presets/preview-preset": "./dist/presets/preview-preset.js",
|
|
45
38
|
"./templates/preview.ejs": "./templates/preview.ejs",
|
|
46
39
|
"./templates/virtualModuleEntry.template.js": "./templates/virtualModuleEntry.template.js",
|
|
47
|
-
"./templates/
|
|
48
|
-
"./
|
|
40
|
+
"./templates/virtualModuleModernEntry.js": "./templates/virtualModuleModernEntry.js",
|
|
41
|
+
"./templates/virtualModuleStory.template.js": "./templates/virtualModuleStory.template.js"
|
|
49
42
|
},
|
|
50
|
-
"main": "dist/index.js",
|
|
51
|
-
"module": "dist/index.mjs",
|
|
52
|
-
"types": "dist/index.d.ts",
|
|
53
43
|
"files": [
|
|
54
44
|
"dist/**/*",
|
|
55
45
|
"templates/**/*",
|
|
@@ -59,20 +49,20 @@
|
|
|
59
49
|
"!src/**/*"
|
|
60
50
|
],
|
|
61
51
|
"scripts": {
|
|
62
|
-
"check": "jiti ../../../scripts/
|
|
63
|
-
"prep": "jiti ../../../scripts/
|
|
52
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
53
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
64
54
|
},
|
|
65
55
|
"dependencies": {
|
|
66
|
-
"@storybook/core-webpack": "
|
|
56
|
+
"@storybook/core-webpack": "10.0.0-beta.0",
|
|
67
57
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
68
58
|
"cjs-module-lexer": "^1.2.3",
|
|
69
|
-
"css-loader": "^
|
|
59
|
+
"css-loader": "^7.1.2",
|
|
70
60
|
"es-module-lexer": "^1.5.0",
|
|
71
|
-
"fork-ts-checker-webpack-plugin": "^
|
|
61
|
+
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
72
62
|
"html-webpack-plugin": "^5.5.0",
|
|
73
63
|
"magic-string": "^0.30.5",
|
|
74
|
-
"style-loader": "^
|
|
75
|
-
"terser-webpack-plugin": "^5.3.
|
|
64
|
+
"style-loader": "^4.0.0",
|
|
65
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
76
66
|
"ts-dedent": "^2.0.0",
|
|
77
67
|
"webpack": "5",
|
|
78
68
|
"webpack-dev-middleware": "^6.1.2",
|
|
@@ -89,7 +79,7 @@
|
|
|
89
79
|
"typescript": "^5.8.3"
|
|
90
80
|
},
|
|
91
81
|
"peerDependencies": {
|
|
92
|
-
"storybook": "^
|
|
82
|
+
"storybook": "^10.0.0-beta.0"
|
|
93
83
|
},
|
|
94
84
|
"peerDependenciesMeta": {
|
|
95
85
|
"typescript": {
|
|
@@ -99,14 +89,5 @@
|
|
|
99
89
|
"publishConfig": {
|
|
100
90
|
"access": "public"
|
|
101
91
|
},
|
|
102
|
-
"
|
|
103
|
-
"entries": [
|
|
104
|
-
"./src/index.ts",
|
|
105
|
-
"./src/presets/custom-webpack-preset.ts",
|
|
106
|
-
"./src/presets/preview-preset.ts",
|
|
107
|
-
"./src/loaders/export-order-loader.ts"
|
|
108
|
-
],
|
|
109
|
-
"platform": "node"
|
|
110
|
-
},
|
|
111
|
-
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
|
|
92
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16"
|
|
112
93
|
}
|
package/dist/chunk-LGGOBZAG.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var __commonJS=(cb,mod)=>function(){return mod||(0, cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));
|
|
2
|
-
|
|
3
|
-
export { __commonJS, __require, __toESM };
|