@modern-js/storybook-builder 0.0.0-next-20231114124526 → 0.0.0-next-20231114141546
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/dist/cjs/plugin-storybook.js +23 -11
- package/dist/esm/plugin-storybook.js +20 -10
- package/package.json +10 -10
@@ -334,15 +334,14 @@ async function watchStories(patterns, cwd, writeModule) {
|
|
334
334
|
async function addonAdapter(api, options) {
|
335
335
|
const { presets } = options;
|
336
336
|
api.modifyBuilderConfig(async (finalConfig) => {
|
337
|
-
var _finalConfig
|
337
|
+
var _finalConfig;
|
338
338
|
const babelOptions = await presets.apply("babel", {}, {
|
339
339
|
...options
|
340
340
|
});
|
341
341
|
var _tools;
|
342
342
|
(_tools = (_finalConfig = finalConfig).tools) !== null && _tools !== void 0 ? _tools : _finalConfig.tools = {};
|
343
|
-
|
344
|
-
|
345
|
-
finalConfig.tools.babel = (config) => {
|
343
|
+
const userConfig = finalConfig.tools.babel;
|
344
|
+
finalConfig.tools.babel = (config, utils) => {
|
346
345
|
const getPluginName = (plugin) => Array.isArray(plugin) ? plugin[0] : plugin;
|
347
346
|
const getOptions = (plugin) => Array.isArray(plugin) ? plugin[1] : null;
|
348
347
|
const replaceOrInsert = (plugin, plugins) => {
|
@@ -351,7 +350,7 @@ async function addonAdapter(api, options) {
|
|
351
350
|
for (let i = 0; i < plugins.length; i++) {
|
352
351
|
if (getPluginName(plugins[i]) === pluginName) {
|
353
352
|
if (getOptions(plugin)) {
|
354
|
-
import_utils.logger.info(
|
353
|
+
import_utils.logger.info(`Detected duplicated babel plugin or presets: ${pluginName}, overrides with the new one`);
|
355
354
|
plugins[i] = plugin;
|
356
355
|
}
|
357
356
|
} else {
|
@@ -361,21 +360,34 @@ async function addonAdapter(api, options) {
|
|
361
360
|
plugins.push(...append);
|
362
361
|
};
|
363
362
|
const currentPlugins = config.plugins || [];
|
363
|
+
const currentPresets = config.presets || [];
|
364
364
|
for (const plugin of babelOptions.plugins || []) {
|
365
365
|
replaceOrInsert(plugin, currentPlugins);
|
366
366
|
}
|
367
|
-
|
367
|
+
for (const preset of babelOptions.presets || []) {
|
368
|
+
replaceOrInsert(preset, currentPresets);
|
369
|
+
}
|
370
|
+
const finalConfig2 = {
|
368
371
|
...config,
|
369
372
|
...babelOptions,
|
370
373
|
plugins: currentPlugins,
|
371
|
-
presets:
|
372
|
-
overrides: [
|
373
|
-
...config.overrides || [],
|
374
|
-
...babelOptions.overrides || []
|
375
|
-
]
|
374
|
+
presets: currentPresets
|
376
375
|
};
|
376
|
+
if (typeof userConfig === "function") {
|
377
|
+
return userConfig(finalConfig2, utils);
|
378
|
+
} else if (typeof userConfig === "object") {
|
379
|
+
return {
|
380
|
+
...finalConfig2,
|
381
|
+
...userConfig
|
382
|
+
};
|
383
|
+
} else {
|
384
|
+
return finalConfig2;
|
385
|
+
}
|
377
386
|
};
|
378
387
|
});
|
388
|
+
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
389
|
+
chain.module.rule(CHAIN_ID.RULE.JS);
|
390
|
+
});
|
379
391
|
api.modifyWebpackConfig(async (config) => {
|
380
392
|
const finalDefaultConfig = await presets.apply("webpackFinal", config, options);
|
381
393
|
return finalDefaultConfig;
|
@@ -356,11 +356,11 @@ async function watchStories(patterns, cwd, writeModule) {
|
|
356
356
|
async function addonAdapter(api, options) {
|
357
357
|
const { presets } = options;
|
358
358
|
api.modifyBuilderConfig(async (finalConfig) => {
|
359
|
-
var _a
|
359
|
+
var _a;
|
360
360
|
const babelOptions = await presets.apply("babel", {}, { ...options });
|
361
361
|
(_a = finalConfig.tools) != null ? _a : finalConfig.tools = {};
|
362
|
-
|
363
|
-
finalConfig.tools.babel = (config) => {
|
362
|
+
const userConfig = finalConfig.tools.babel;
|
363
|
+
finalConfig.tools.babel = (config, utils) => {
|
364
364
|
const getPluginName = (plugin) => Array.isArray(plugin) ? plugin[0] : plugin;
|
365
365
|
const getOptions = (plugin) => Array.isArray(plugin) ? plugin[1] : null;
|
366
366
|
const replaceOrInsert = (plugin, plugins) => {
|
@@ -370,7 +370,7 @@ async function addonAdapter(api, options) {
|
|
370
370
|
if (getPluginName(plugins[i]) === pluginName) {
|
371
371
|
if (getOptions(plugin)) {
|
372
372
|
logger.info(
|
373
|
-
|
373
|
+
`Detected duplicated babel plugin or presets: ${pluginName}, overrides with the new one`
|
374
374
|
);
|
375
375
|
plugins[i] = plugin;
|
376
376
|
}
|
@@ -381,21 +381,31 @@ async function addonAdapter(api, options) {
|
|
381
381
|
plugins.push(...append);
|
382
382
|
};
|
383
383
|
const currentPlugins = config.plugins || [];
|
384
|
+
const currentPresets = config.presets || [];
|
384
385
|
for (const plugin of babelOptions.plugins || []) {
|
385
386
|
replaceOrInsert(plugin, currentPlugins);
|
386
387
|
}
|
387
|
-
|
388
|
+
for (const preset of babelOptions.presets || []) {
|
389
|
+
replaceOrInsert(preset, currentPresets);
|
390
|
+
}
|
391
|
+
const finalConfig2 = {
|
388
392
|
...config,
|
389
393
|
...babelOptions,
|
390
394
|
plugins: currentPlugins,
|
391
|
-
presets:
|
392
|
-
overrides: [
|
393
|
-
...config.overrides || [],
|
394
|
-
...babelOptions.overrides || []
|
395
|
-
]
|
395
|
+
presets: currentPresets
|
396
396
|
};
|
397
|
+
if (typeof userConfig === "function") {
|
398
|
+
return userConfig(finalConfig2, utils);
|
399
|
+
} else if (typeof userConfig === "object") {
|
400
|
+
return { ...finalConfig2, ...userConfig };
|
401
|
+
} else {
|
402
|
+
return finalConfig2;
|
403
|
+
}
|
397
404
|
};
|
398
405
|
});
|
406
|
+
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
407
|
+
chain.module.rule(CHAIN_ID.RULE.JS);
|
408
|
+
});
|
399
409
|
api.modifyWebpackConfig(async (config) => {
|
400
410
|
const finalDefaultConfig = await presets.apply(
|
401
411
|
"webpackFinal",
|
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-20231114141546",
|
4
4
|
"description": "modern.js support for storybook",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -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
|
76
|
-
"@modern-js/runtime": "0.0.0-next-
|
77
|
-
"@modern-js/
|
78
|
-
"@modern-js/
|
74
|
+
"@modern-js/builder-shared": "0.0.0-next-20231114141546",
|
75
|
+
"@modern-js/builder": "0.0.0-next-20231114141546",
|
76
|
+
"@modern-js/runtime": "0.0.0-next-20231114141546",
|
77
|
+
"@modern-js/utils": "0.0.0-next-20231114141546",
|
78
|
+
"@modern-js/core": "0.0.0-next-20231114141546"
|
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-webpack-provider": "0.0.0-next-
|
87
|
-
"@modern-js/builder-rspack-provider": "0.0.0-next-
|
88
|
-
"@
|
89
|
-
"@
|
86
|
+
"@modern-js/builder-webpack-provider": "0.0.0-next-20231114141546",
|
87
|
+
"@modern-js/builder-rspack-provider": "0.0.0-next-20231114141546",
|
88
|
+
"@modern-js/core": "0.0.0-next-20231114141546",
|
89
|
+
"@scripts/build": "0.0.0-next-20231114141546"
|
90
90
|
},
|
91
91
|
"publishConfig": {
|
92
92
|
"registry": "https://registry.npmjs.org/",
|