@modern-js/storybook-builder 0.0.0-next-20231114124526 → 0.0.0-next-20231115182236
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.
@@ -89,7 +89,6 @@ const pluginStorybook = (cwd, options) => {
|
|
89
89
|
await applyCsfPlugin(config, options);
|
90
90
|
};
|
91
91
|
if ("modifyWebpackConfig" in api) {
|
92
|
-
addonAdapter(api, options);
|
93
92
|
api.modifyWebpackConfig(modifyConfig);
|
94
93
|
api.modifyWebpackChain(async (chain) => {
|
95
94
|
await (0, import_docgen.applyDocgenWebpack)(chain, options);
|
@@ -331,56 +330,6 @@ async function watchStories(patterns, cwd, writeModule) {
|
|
331
330
|
]);
|
332
331
|
return watcher;
|
333
332
|
}
|
334
|
-
async function addonAdapter(api, options) {
|
335
|
-
const { presets } = options;
|
336
|
-
api.modifyBuilderConfig(async (finalConfig) => {
|
337
|
-
var _finalConfig, _finalConfig_tools;
|
338
|
-
const babelOptions = await presets.apply("babel", {}, {
|
339
|
-
...options
|
340
|
-
});
|
341
|
-
var _tools;
|
342
|
-
(_tools = (_finalConfig = finalConfig).tools) !== null && _tools !== void 0 ? _tools : _finalConfig.tools = {};
|
343
|
-
var _babel;
|
344
|
-
(_babel = (_finalConfig_tools = finalConfig.tools).babel) !== null && _babel !== void 0 ? _babel : _finalConfig_tools.babel = {};
|
345
|
-
finalConfig.tools.babel = (config) => {
|
346
|
-
const getPluginName = (plugin) => Array.isArray(plugin) ? plugin[0] : plugin;
|
347
|
-
const getOptions = (plugin) => Array.isArray(plugin) ? plugin[1] : null;
|
348
|
-
const replaceOrInsert = (plugin, plugins) => {
|
349
|
-
const pluginName = getPluginName(plugin);
|
350
|
-
const append = [];
|
351
|
-
for (let i = 0; i < plugins.length; i++) {
|
352
|
-
if (getPluginName(plugins[i]) === pluginName) {
|
353
|
-
if (getOptions(plugin)) {
|
354
|
-
import_utils.logger.info("Detected duplicated babel plugin, overrides with the new one");
|
355
|
-
plugins[i] = plugin;
|
356
|
-
}
|
357
|
-
} else {
|
358
|
-
append.push(plugin);
|
359
|
-
}
|
360
|
-
}
|
361
|
-
plugins.push(...append);
|
362
|
-
};
|
363
|
-
const currentPlugins = config.plugins || [];
|
364
|
-
for (const plugin of babelOptions.plugins || []) {
|
365
|
-
replaceOrInsert(plugin, currentPlugins);
|
366
|
-
}
|
367
|
-
return {
|
368
|
-
...config,
|
369
|
-
...babelOptions,
|
370
|
-
plugins: currentPlugins,
|
371
|
-
presets: config.presets,
|
372
|
-
overrides: [
|
373
|
-
...config.overrides || [],
|
374
|
-
...babelOptions.overrides || []
|
375
|
-
]
|
376
|
-
};
|
377
|
-
};
|
378
|
-
});
|
379
|
-
api.modifyWebpackConfig(async (config) => {
|
380
|
-
const finalDefaultConfig = await presets.apply("webpackFinal", config, options);
|
381
|
-
return finalDefaultConfig;
|
382
|
-
});
|
383
|
-
}
|
384
333
|
// Annotate the CommonJS export names for ESM import in node:
|
385
334
|
0 && (module.exports = {
|
386
335
|
finalize,
|
@@ -1,11 +1,5 @@
|
|
1
1
|
import { isAbsolute, join, resolve } from "path";
|
2
|
-
import {
|
3
|
-
slash,
|
4
|
-
watch,
|
5
|
-
globby,
|
6
|
-
applyOptionsChain,
|
7
|
-
logger
|
8
|
-
} from "@modern-js/utils";
|
2
|
+
import { slash, watch, globby, applyOptionsChain } from "@modern-js/utils";
|
9
3
|
import {
|
10
4
|
mergeBuilderConfig
|
11
5
|
} from "@modern-js/builder-shared";
|
@@ -79,7 +73,6 @@ const pluginStorybook = (cwd, options) => {
|
|
79
73
|
await applyCsfPlugin(config, options);
|
80
74
|
};
|
81
75
|
if ("modifyWebpackConfig" in api) {
|
82
|
-
addonAdapter(api, options);
|
83
76
|
api.modifyWebpackConfig(modifyConfig);
|
84
77
|
api.modifyWebpackChain(async (chain) => {
|
85
78
|
await applyDocgenWebpack(chain, options);
|
@@ -353,58 +346,6 @@ async function watchStories(patterns, cwd, writeModule) {
|
|
353
346
|
);
|
354
347
|
return watcher;
|
355
348
|
}
|
356
|
-
async function addonAdapter(api, options) {
|
357
|
-
const { presets } = options;
|
358
|
-
api.modifyBuilderConfig(async (finalConfig) => {
|
359
|
-
var _a, _b, _c;
|
360
|
-
const babelOptions = await presets.apply("babel", {}, { ...options });
|
361
|
-
(_a = finalConfig.tools) != null ? _a : finalConfig.tools = {};
|
362
|
-
(_c = (_b = finalConfig.tools).babel) != null ? _c : _b.babel = {};
|
363
|
-
finalConfig.tools.babel = (config) => {
|
364
|
-
const getPluginName = (plugin) => Array.isArray(plugin) ? plugin[0] : plugin;
|
365
|
-
const getOptions = (plugin) => Array.isArray(plugin) ? plugin[1] : null;
|
366
|
-
const replaceOrInsert = (plugin, plugins) => {
|
367
|
-
const pluginName = getPluginName(plugin);
|
368
|
-
const append = [];
|
369
|
-
for (let i = 0; i < plugins.length; i++) {
|
370
|
-
if (getPluginName(plugins[i]) === pluginName) {
|
371
|
-
if (getOptions(plugin)) {
|
372
|
-
logger.info(
|
373
|
-
"Detected duplicated babel plugin, overrides with the new one"
|
374
|
-
);
|
375
|
-
plugins[i] = plugin;
|
376
|
-
}
|
377
|
-
} else {
|
378
|
-
append.push(plugin);
|
379
|
-
}
|
380
|
-
}
|
381
|
-
plugins.push(...append);
|
382
|
-
};
|
383
|
-
const currentPlugins = config.plugins || [];
|
384
|
-
for (const plugin of babelOptions.plugins || []) {
|
385
|
-
replaceOrInsert(plugin, currentPlugins);
|
386
|
-
}
|
387
|
-
return {
|
388
|
-
...config,
|
389
|
-
...babelOptions,
|
390
|
-
plugins: currentPlugins,
|
391
|
-
presets: config.presets,
|
392
|
-
overrides: [
|
393
|
-
...config.overrides || [],
|
394
|
-
...babelOptions.overrides || []
|
395
|
-
]
|
396
|
-
};
|
397
|
-
};
|
398
|
-
});
|
399
|
-
api.modifyWebpackConfig(async (config) => {
|
400
|
-
const finalDefaultConfig = await presets.apply(
|
401
|
-
"webpackFinal",
|
402
|
-
config,
|
403
|
-
options
|
404
|
-
);
|
405
|
-
return finalDefaultConfig;
|
406
|
-
});
|
407
|
-
}
|
408
349
|
export {
|
409
350
|
finalize,
|
410
351
|
pluginStorybook
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modern-js/storybook-builder",
|
3
|
-
"version": "0.0.0-next-
|
3
|
+
"version": "0.0.0-next-20231115182236",
|
4
4
|
"description": "modern.js support for storybook",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -17,19 +17,19 @@
|
|
17
17
|
],
|
18
18
|
"exports": {
|
19
19
|
".": {
|
20
|
-
"jsnext:source": "./src/index.ts",
|
21
20
|
"types": "./dist/types/index.d.ts",
|
21
|
+
"jsnext:source": "./src/index.ts",
|
22
22
|
"default": "./dist/cjs/index.js"
|
23
23
|
},
|
24
24
|
"./preset": "./dist/esm/preset.js",
|
25
25
|
"./addons": {
|
26
|
-
"jsnext:source": "./src/addons/preset/preview.ts",
|
27
26
|
"types": "./dist/types/addons/preset/preview.d.ts",
|
27
|
+
"jsnext:source": "./src/addons/preset/preview.ts",
|
28
28
|
"default": "./dist/esm/addons/preset/preview.js"
|
29
29
|
},
|
30
30
|
"./types": {
|
31
|
-
"jsnext:source": "./src/types.ts",
|
32
31
|
"types": "./dist/types/types.d.ts",
|
32
|
+
"jsnext:source": "./src/types.ts",
|
33
33
|
"default": "./dist/cjs/types.js"
|
34
34
|
},
|
35
35
|
"./templates/preview.ejs": "./templates/preview.ejs",
|
@@ -71,11 +71,11 @@
|
|
71
71
|
"serve-static": "^1.14.1",
|
72
72
|
"tinypool": "^0.8.0",
|
73
73
|
"webpack-hot-middleware": "^2.25.4",
|
74
|
-
"@modern-js/builder": "0.0.0-next-
|
75
|
-
"@modern-js/builder-shared": "0.0.0-next-
|
76
|
-
"@modern-js/
|
77
|
-
"@modern-js/
|
78
|
-
"@modern-js/utils": "0.0.0-next-
|
74
|
+
"@modern-js/builder": "0.0.0-next-20231115182236",
|
75
|
+
"@modern-js/builder-shared": "0.0.0-next-20231115182236",
|
76
|
+
"@modern-js/core": "0.0.0-next-20231115182236",
|
77
|
+
"@modern-js/runtime": "0.0.0-next-20231115182236",
|
78
|
+
"@modern-js/utils": "0.0.0-next-20231115182236"
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
81
|
"@storybook/types": "^7.5.1",
|
@@ -83,10 +83,10 @@
|
|
83
83
|
"@types/serve-static": "^1.13.10",
|
84
84
|
"@types/webpack-hot-middleware": "^2.25.6",
|
85
85
|
"typescript": "^5.2.2",
|
86
|
-
"@modern-js/builder-
|
87
|
-
"@modern-js/builder-
|
88
|
-
"@
|
89
|
-
"@
|
86
|
+
"@modern-js/builder-rspack-provider": "0.0.0-next-20231115182236",
|
87
|
+
"@modern-js/builder-webpack-provider": "0.0.0-next-20231115182236",
|
88
|
+
"@modern-js/core": "0.0.0-next-20231115182236",
|
89
|
+
"@scripts/build": "0.0.0-next-20231115182236"
|
90
90
|
},
|
91
91
|
"publishConfig": {
|
92
92
|
"registry": "https://registry.npmjs.org/",
|
@@ -27,13 +27,13 @@ window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore
|
|
27
27
|
|
28
28
|
preview.initialize({ importFn, getProjectAnnotations });
|
29
29
|
|
30
|
-
if (
|
31
|
-
|
30
|
+
if (module.hot) {
|
31
|
+
module.hot.accept('./{{storiesFilename}}', () => {
|
32
32
|
// importFn has changed so we need to patch the new one in
|
33
33
|
preview.onStoriesChanged({ importFn });
|
34
34
|
});
|
35
35
|
|
36
|
-
|
36
|
+
module.hot.accept([
|
37
37
|
{{#each previewAnnotations}}'{{this}}',
|
38
38
|
{{/each}}
|
39
39
|
], () => {
|