@storybook/core-webpack 7.0.0-alpha.4 → 7.0.0-alpha.41
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/index.d.ts +53 -0
- package/dist/index.js +42 -0
- package/dist/index.mjs +42 -0
- package/package.json +28 -10
- package/LICENSE +0 -21
- package/dist/cjs/check-webpack-version.js +0 -34
- package/dist/cjs/index.js +0 -57
- package/dist/cjs/load-custom-webpack-config.js +0 -18
- package/dist/cjs/merge-webpack-config.js +0 -65
- package/dist/cjs/types.js +0 -5
- package/dist/esm/check-webpack-version.js +0 -20
- package/dist/esm/index.js +0 -4
- package/dist/esm/load-custom-webpack-config.js +0 -4
- package/dist/esm/merge-webpack-config.js +0 -58
- package/dist/esm/types.js +0 -1
- package/dist/types/check-webpack-version.d.ts +0 -3
- package/dist/types/index.d.ts +0 -4
- package/dist/types/load-custom-webpack-config.d.ts +0 -1
- package/dist/types/merge-webpack-config.d.ts +0 -2
- package/dist/types/types.d.ts +0 -30
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { StorybookConfig as StorybookConfig$1, Options, NormalizedStoriesSpecifier } from '@storybook/core-common';
|
|
2
|
+
export { BuilderResult, Options, Preset, TypescriptOptions } from '@storybook/core-common';
|
|
3
|
+
|
|
4
|
+
declare type RulesConfig = any;
|
|
5
|
+
declare type ModuleConfig = {
|
|
6
|
+
rules?: RulesConfig[];
|
|
7
|
+
};
|
|
8
|
+
declare type ResolveConfig = {
|
|
9
|
+
extensions?: string[];
|
|
10
|
+
mainFields?: (string | string[])[] | undefined;
|
|
11
|
+
alias?: any;
|
|
12
|
+
};
|
|
13
|
+
interface WebpackConfiguration {
|
|
14
|
+
plugins?: any[];
|
|
15
|
+
module?: ModuleConfig;
|
|
16
|
+
resolve?: ResolveConfig;
|
|
17
|
+
optimization?: any;
|
|
18
|
+
devtool?: false | string;
|
|
19
|
+
}
|
|
20
|
+
declare type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1 & {
|
|
21
|
+
/**
|
|
22
|
+
* Modify or return a custom Webpack config after the Storybook's default configuration
|
|
23
|
+
* has run (mostly used by addons).
|
|
24
|
+
*/
|
|
25
|
+
webpack?: (config: TWebpackConfiguration, options: Options) => TWebpackConfiguration | Promise<TWebpackConfiguration>;
|
|
26
|
+
/**
|
|
27
|
+
* Modify or return a custom Webpack config after every addon has run.
|
|
28
|
+
*/
|
|
29
|
+
webpackFinal?: (config: TWebpackConfiguration, options: Options) => TWebpackConfiguration | Promise<TWebpackConfiguration>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare const loadCustomWebpackConfig: (configDir: string) => any;
|
|
33
|
+
|
|
34
|
+
declare const checkWebpackVersion: (webpack: {
|
|
35
|
+
version?: string;
|
|
36
|
+
}, specifier: string, caption: string) => void;
|
|
37
|
+
|
|
38
|
+
declare function mergeConfigs(config: WebpackConfiguration, customConfig: WebpackConfiguration): WebpackConfiguration;
|
|
39
|
+
|
|
40
|
+
declare function webpackIncludeRegexp(specifier: NormalizedStoriesSpecifier): RegExp;
|
|
41
|
+
declare function toImportFnPart(specifier: NormalizedStoriesSpecifier): string;
|
|
42
|
+
declare function toImportFn(stories: NormalizedStoriesSpecifier[], { needPipelinedImport }?: {
|
|
43
|
+
needPipelinedImport?: boolean;
|
|
44
|
+
}): string;
|
|
45
|
+
|
|
46
|
+
declare const toRequireContext: (specifier: NormalizedStoriesSpecifier) => {
|
|
47
|
+
path: string;
|
|
48
|
+
recursive: boolean;
|
|
49
|
+
match: RegExp;
|
|
50
|
+
};
|
|
51
|
+
declare const toRequireContextString: (specifier: NormalizedStoriesSpecifier) => string;
|
|
52
|
+
|
|
53
|
+
export { ModuleConfig, ResolveConfig, RulesConfig, StorybookConfig, WebpackConfiguration, checkWebpackVersion, loadCustomWebpackConfig, mergeConfigs, toImportFn, toImportFnPart, toRequireContext, toRequireContextString, webpackIncludeRegexp };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";var h=Object.create;var n=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var S=(e,o)=>{for(var i in o)n(e,i,{get:o[i],enumerable:!0})},l=(e,o,i,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of R(o))!y.call(e,t)&&t!==i&&n(e,t,{get:()=>o[t],enumerable:!(r=v(o,t))||r.enumerable});return e};var $=(e,o,i)=>(i=e!=null?h(k(e)):{},l(o||!e||!e.__esModule?n(i,"default",{value:e,enumerable:!0}):i,e)),w=e=>l(n({},"__esModule",{value:!0}),e);var O={};S(O,{checkWebpackVersion:()=>F,loadCustomWebpackConfig:()=>P,mergeConfigs:()=>T,toImportFn:()=>j,toImportFnPart:()=>d,toRequireContext:()=>b,toRequireContextString:()=>A,webpackIncludeRegexp:()=>g});module.exports=w(O);var u=$(require("path")),a=require("@storybook/core-common"),z=["webpack.config","webpackfile"],P=e=>(0,a.serverRequire)(z.map(o=>u.default.resolve(e,o)));var p=require("@storybook/node-logger"),m=require("ts-dedent"),F=(e,o,i)=>{if(!e.version){p.logger.info("Skipping webpack version check, no version available");return}e.version!==o&&p.logger.warn(m.dedent`
|
|
2
|
+
Unexpected webpack version in ${i}:
|
|
3
|
+
- Received '${e.version}'
|
|
4
|
+
- Expected '${o}'
|
|
5
|
+
|
|
6
|
+
If you're using Webpack 5 in SB6.2 and upgrading, consider: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#webpack-5-manager-build
|
|
7
|
+
|
|
8
|
+
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
9
|
+
`)};function I(e=[],o=[]){return[...e,...o]}function M(e=[],o=[]){return[...e,...o]}function E({extensions:e=[]},{extensions:o=[]}){return[...e,...o]}function N({alias:e={}},{alias:o={}}){return{...e,...o}}function q(e,o){return{...e,...o,rules:M(e.rules||[],o.rules||[])}}function W({resolve:e={}},{resolve:o={}}){return{...e,...o,alias:N(e,o),extensions:E(e,o)}}function G({optimization:e={}},{optimization:o={}}){return{...e,...o}}function T(e,o){return{...o,...e,devtool:o.devtool||e.devtool,plugins:I(e.plugins,o.plugins),module:q(e.module||{},o.module||{}),resolve:W(e,o),optimization:G(e,o)}}var s=require("ts-dedent"),f=require("@storybook/core-common");function c(){let e=Promise.resolve();return async o=>{await e;let i=o();return e=e.then(async()=>{await i}),i}}function g(e){let{directory:o,files:i}=e,r=o.replace(/^(\.+\/)+/,"/"),t=[".",".."].includes(o)?i:`${r}/${i}`,C=(0,f.globToRegexp)(t);return new RegExp(C.source.replace(/^\^/,""))}function d(e){let{directory:o,importPathMatcher:i}=e;return s.dedent`
|
|
10
|
+
async (path) => {
|
|
11
|
+
if (!${i}.exec(path)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const pathRemainder = path.substring(${o.length+1});
|
|
16
|
+
return import(
|
|
17
|
+
/* webpackChunkName: "[request]" */
|
|
18
|
+
/* webpackInclude: ${g(e)} */
|
|
19
|
+
'${o}/' + pathRemainder
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
`}function j(e,{needPipelinedImport:o}={}){let i="const pipeline = (x) => x();";return o&&(i=`
|
|
24
|
+
const importPipeline = ${c};
|
|
25
|
+
const pipeline = importPipeline();
|
|
26
|
+
`),s.dedent`
|
|
27
|
+
${i}
|
|
28
|
+
|
|
29
|
+
const importers = [
|
|
30
|
+
${e.map(d).join(`,
|
|
31
|
+
`)}
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export async function importFn(path) {
|
|
35
|
+
for (let i = 0; i < importers.length; i++) {
|
|
36
|
+
const moduleExports = await pipeline(() => importers[i](path));
|
|
37
|
+
if (moduleExports) {
|
|
38
|
+
return moduleExports;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`}var x=require("@storybook/core-common"),b=e=>{let{directory:o,files:i}=e,r=(0,x.globToRegexp)(`./${i}`);return{path:o,recursive:i.includes("**")||i.split("/").length>1,match:r}},A=e=>{let{path:o,recursive:i,match:r}=b(e);return`require.context('${o}', ${i}, ${r})`};0&&(module.exports={checkWebpackVersion,loadCustomWebpackConfig,mergeConfigs,toImportFn,toImportFnPart,toRequireContext,toRequireContextString,webpackIncludeRegexp});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import u from"path";import{serverRequire as c}from"@storybook/core-common";var m=["webpack.config","webpackfile"],P=o=>c(m.map(e=>u.resolve(o,e)));import{logger as p}from"@storybook/node-logger";import{dedent as f}from"ts-dedent";var I=(o,e,i)=>{if(!o.version){p.info("Skipping webpack version check, no version available");return}o.version!==e&&p.warn(f`
|
|
2
|
+
Unexpected webpack version in ${i}:
|
|
3
|
+
- Received '${o.version}'
|
|
4
|
+
- Expected '${e}'
|
|
5
|
+
|
|
6
|
+
If you're using Webpack 5 in SB6.2 and upgrading, consider: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#webpack-5-manager-build
|
|
7
|
+
|
|
8
|
+
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
9
|
+
`)};function g(o=[],e=[]){return[...o,...e]}function d(o=[],e=[]){return[...o,...e]}function C({extensions:o=[]},{extensions:e=[]}){return[...o,...e]}function b({alias:o={}},{alias:e={}}){return{...o,...e}}function x(o,e){return{...o,...e,rules:d(o.rules||[],e.rules||[])}}function k({resolve:o={}},{resolve:e={}}){return{...o,...e,alias:b(o,e),extensions:C(o,e)}}function y({optimization:o={}},{optimization:e={}}){return{...o,...e}}function E(o,e){return{...e,...o,devtool:e.devtool||o.devtool,plugins:g(o.plugins,e.plugins),module:x(o.module||{},e.module||{}),resolve:k(o,e),optimization:y(o,e)}}import{dedent as a}from"ts-dedent";import{globToRegexp as v}from"@storybook/core-common";function s(){let o=Promise.resolve();return async e=>{await o;let i=e();return o=o.then(async()=>{await i}),i}}function R(o){let{directory:e,files:i}=o,t=e.replace(/^(\.+\/)+/,"/"),n=[".",".."].includes(e)?i:`${t}/${i}`,l=v(n);return new RegExp(l.source.replace(/^\^/,""))}function h(o){let{directory:e,importPathMatcher:i}=o;return a`
|
|
10
|
+
async (path) => {
|
|
11
|
+
if (!${i}.exec(path)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const pathRemainder = path.substring(${e.length+1});
|
|
16
|
+
return import(
|
|
17
|
+
/* webpackChunkName: "[request]" */
|
|
18
|
+
/* webpackInclude: ${R(o)} */
|
|
19
|
+
'${e}/' + pathRemainder
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
`}function j(o,{needPipelinedImport:e}={}){let i="const pipeline = (x) => x();";return e&&(i=`
|
|
24
|
+
const importPipeline = ${s};
|
|
25
|
+
const pipeline = importPipeline();
|
|
26
|
+
`),a`
|
|
27
|
+
${i}
|
|
28
|
+
|
|
29
|
+
const importers = [
|
|
30
|
+
${o.map(h).join(`,
|
|
31
|
+
`)}
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export async function importFn(path) {
|
|
35
|
+
for (let i = 0; i < importers.length; i++) {
|
|
36
|
+
const moduleExports = await pipeline(() => importers[i](path));
|
|
37
|
+
if (moduleExports) {
|
|
38
|
+
return moduleExports;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`}import{globToRegexp as S}from"@storybook/core-common";var w=o=>{let{directory:e,files:i}=o,t=S(`./${i}`);return{path:e,recursive:i.includes("**")||i.split("/").length>1,match:t}},L=o=>{let{path:e,recursive:i,match:t}=w(o);return`require.context('${e}', ${i}, ${t})`};export{I as checkWebpackVersion,P as loadCustomWebpackConfig,E as mergeConfigs,j as toImportFn,h as toImportFnPart,w as toRequireContext,L as toRequireContextString,R as webpackIncludeRegexp};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/core-webpack",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.41",
|
|
4
4
|
"description": "Storybook framework-agnostic API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -19,9 +19,17 @@
|
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/index.js",
|
|
31
|
+
"module": "dist/index.mjs",
|
|
32
|
+
"types": "dist/index.d.ts",
|
|
25
33
|
"files": [
|
|
26
34
|
"dist/**/*",
|
|
27
35
|
"types/**/*",
|
|
@@ -30,17 +38,27 @@
|
|
|
30
38
|
"*.d.ts"
|
|
31
39
|
],
|
|
32
40
|
"scripts": {
|
|
33
|
-
"
|
|
41
|
+
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
|
42
|
+
"prep": "../../../scripts/prepare/bundle.ts"
|
|
34
43
|
},
|
|
35
44
|
"dependencies": {
|
|
36
|
-
"@storybook/core-common": "7.0.0-alpha.
|
|
37
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
38
|
-
"@types/node": "^
|
|
39
|
-
"core-js": "^3.8.2",
|
|
45
|
+
"@storybook/core-common": "7.0.0-alpha.41",
|
|
46
|
+
"@storybook/node-logger": "7.0.0-alpha.41",
|
|
47
|
+
"@types/node": "^16.0.0",
|
|
40
48
|
"ts-dedent": "^2.0.0"
|
|
41
49
|
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"typescript": "~4.6.3",
|
|
52
|
+
"webpack": "5"
|
|
53
|
+
},
|
|
42
54
|
"publishConfig": {
|
|
43
55
|
"access": "public"
|
|
44
56
|
},
|
|
45
|
-
"
|
|
57
|
+
"bundler": {
|
|
58
|
+
"entries": [
|
|
59
|
+
"./src/index.ts"
|
|
60
|
+
],
|
|
61
|
+
"platform": "node"
|
|
62
|
+
},
|
|
63
|
+
"gitHead": "7ec6f916eb875bd2e3cf3aa6b1afcd1fe25d1637"
|
|
46
64
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.checkWebpackVersion = void 0;
|
|
7
|
-
|
|
8
|
-
var _nodeLogger = require("@storybook/node-logger");
|
|
9
|
-
|
|
10
|
-
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const checkWebpackVersion = (webpack, specifier, caption) => {
|
|
15
|
-
if (!webpack.version) {
|
|
16
|
-
_nodeLogger.logger.info('Skipping webpack version check, no version available');
|
|
17
|
-
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (webpack.version !== specifier) {
|
|
22
|
-
_nodeLogger.logger.warn((0, _tsDedent.default)`
|
|
23
|
-
Unexpected webpack version in ${caption}:
|
|
24
|
-
- Received '${webpack.version}'
|
|
25
|
-
- Expected '${specifier}'
|
|
26
|
-
|
|
27
|
-
If you're using Webpack 5 in SB6.2 and upgrading, consider: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#webpack-5-manager-build
|
|
28
|
-
|
|
29
|
-
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
30
|
-
`);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.checkWebpackVersion = checkWebpackVersion;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _types = require("./types");
|
|
8
|
-
|
|
9
|
-
Object.keys(_types).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _types[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _loadCustomWebpackConfig = require("./load-custom-webpack-config");
|
|
21
|
-
|
|
22
|
-
Object.keys(_loadCustomWebpackConfig).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _loadCustomWebpackConfig[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _loadCustomWebpackConfig[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _checkWebpackVersion = require("./check-webpack-version");
|
|
34
|
-
|
|
35
|
-
Object.keys(_checkWebpackVersion).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _checkWebpackVersion[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _checkWebpackVersion[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _mergeWebpackConfig = require("./merge-webpack-config");
|
|
47
|
-
|
|
48
|
-
Object.keys(_mergeWebpackConfig).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] === _mergeWebpackConfig[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _mergeWebpackConfig[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadCustomWebpackConfig = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _coreCommon = require("@storybook/core-common");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const webpackConfigs = ['webpack.config', 'webpackfile'];
|
|
15
|
-
|
|
16
|
-
const loadCustomWebpackConfig = configDir => (0, _coreCommon.serverRequire)(webpackConfigs.map(configName => _path.default.resolve(configDir, configName)));
|
|
17
|
-
|
|
18
|
-
exports.loadCustomWebpackConfig = loadCustomWebpackConfig;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mergeConfigs = mergeConfigs;
|
|
7
|
-
|
|
8
|
-
function mergePluginsField(defaultPlugins = [], customPlugins = []) {
|
|
9
|
-
return [...defaultPlugins, ...customPlugins];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function mergeRulesField(defaultRules = [], customRules = []) {
|
|
13
|
-
return [...defaultRules, ...customRules];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function mergeExtensionsField({
|
|
17
|
-
extensions: defaultExtensions = []
|
|
18
|
-
}, {
|
|
19
|
-
extensions: customExtensions = []
|
|
20
|
-
}) {
|
|
21
|
-
return [...defaultExtensions, ...customExtensions];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function mergeAliasField({
|
|
25
|
-
alias: defaultAlias = {}
|
|
26
|
-
}, {
|
|
27
|
-
alias: customAlias = {}
|
|
28
|
-
}) {
|
|
29
|
-
return Object.assign({}, defaultAlias, customAlias);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function mergeModuleField(a, b) {
|
|
33
|
-
return Object.assign({}, a, b, {
|
|
34
|
-
rules: mergeRulesField(a.rules || [], b.rules || [])
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function mergeResolveField({
|
|
39
|
-
resolve: defaultResolve = {}
|
|
40
|
-
}, {
|
|
41
|
-
resolve: customResolve = {}
|
|
42
|
-
}) {
|
|
43
|
-
return Object.assign({}, defaultResolve, customResolve, {
|
|
44
|
-
alias: mergeAliasField(defaultResolve, customResolve),
|
|
45
|
-
extensions: mergeExtensionsField(defaultResolve, customResolve)
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function mergeOptimizationField({
|
|
50
|
-
optimization: defaultOptimization = {}
|
|
51
|
-
}, {
|
|
52
|
-
optimization: customOptimization = {}
|
|
53
|
-
}) {
|
|
54
|
-
return Object.assign({}, defaultOptimization, customOptimization);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function mergeConfigs(config, customConfig) {
|
|
58
|
-
return Object.assign({}, customConfig, config, {
|
|
59
|
-
devtool: customConfig.devtool || config.devtool,
|
|
60
|
-
plugins: mergePluginsField(config.plugins, customConfig.plugins),
|
|
61
|
-
module: mergeModuleField(config.module || {}, customConfig.module || {}),
|
|
62
|
-
resolve: mergeResolveField(config, customConfig),
|
|
63
|
-
optimization: mergeOptimizationField(config, customConfig)
|
|
64
|
-
});
|
|
65
|
-
}
|
package/dist/cjs/types.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { logger } from '@storybook/node-logger';
|
|
2
|
-
import dedent from 'ts-dedent';
|
|
3
|
-
export const checkWebpackVersion = (webpack, specifier, caption) => {
|
|
4
|
-
if (!webpack.version) {
|
|
5
|
-
logger.info('Skipping webpack version check, no version available');
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (webpack.version !== specifier) {
|
|
10
|
-
logger.warn(dedent`
|
|
11
|
-
Unexpected webpack version in ${caption}:
|
|
12
|
-
- Received '${webpack.version}'
|
|
13
|
-
- Expected '${specifier}'
|
|
14
|
-
|
|
15
|
-
If you're using Webpack 5 in SB6.2 and upgrading, consider: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#webpack-5-manager-build
|
|
16
|
-
|
|
17
|
-
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
18
|
-
`);
|
|
19
|
-
}
|
|
20
|
-
};
|
package/dist/esm/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { serverRequire } from '@storybook/core-common';
|
|
3
|
-
const webpackConfigs = ['webpack.config', 'webpackfile'];
|
|
4
|
-
export const loadCustomWebpackConfig = configDir => serverRequire(webpackConfigs.map(configName => path.resolve(configDir, configName)));
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
function mergePluginsField(defaultPlugins = [], customPlugins = []) {
|
|
2
|
-
return [...defaultPlugins, ...customPlugins];
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function mergeRulesField(defaultRules = [], customRules = []) {
|
|
6
|
-
return [...defaultRules, ...customRules];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function mergeExtensionsField({
|
|
10
|
-
extensions: defaultExtensions = []
|
|
11
|
-
}, {
|
|
12
|
-
extensions: customExtensions = []
|
|
13
|
-
}) {
|
|
14
|
-
return [...defaultExtensions, ...customExtensions];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function mergeAliasField({
|
|
18
|
-
alias: defaultAlias = {}
|
|
19
|
-
}, {
|
|
20
|
-
alias: customAlias = {}
|
|
21
|
-
}) {
|
|
22
|
-
return Object.assign({}, defaultAlias, customAlias);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function mergeModuleField(a, b) {
|
|
26
|
-
return Object.assign({}, a, b, {
|
|
27
|
-
rules: mergeRulesField(a.rules || [], b.rules || [])
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function mergeResolveField({
|
|
32
|
-
resolve: defaultResolve = {}
|
|
33
|
-
}, {
|
|
34
|
-
resolve: customResolve = {}
|
|
35
|
-
}) {
|
|
36
|
-
return Object.assign({}, defaultResolve, customResolve, {
|
|
37
|
-
alias: mergeAliasField(defaultResolve, customResolve),
|
|
38
|
-
extensions: mergeExtensionsField(defaultResolve, customResolve)
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function mergeOptimizationField({
|
|
43
|
-
optimization: defaultOptimization = {}
|
|
44
|
-
}, {
|
|
45
|
-
optimization: customOptimization = {}
|
|
46
|
-
}) {
|
|
47
|
-
return Object.assign({}, defaultOptimization, customOptimization);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function mergeConfigs(config, customConfig) {
|
|
51
|
-
return Object.assign({}, customConfig, config, {
|
|
52
|
-
devtool: customConfig.devtool || config.devtool,
|
|
53
|
-
plugins: mergePluginsField(config.plugins, customConfig.plugins),
|
|
54
|
-
module: mergeModuleField(config.module || {}, customConfig.module || {}),
|
|
55
|
-
resolve: mergeResolveField(config, customConfig),
|
|
56
|
-
optimization: mergeOptimizationField(config, customConfig)
|
|
57
|
-
});
|
|
58
|
-
}
|
package/dist/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const loadCustomWebpackConfig: (configDir: string) => any;
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Options, StorybookConfig as BaseStorybookConfig } from '@storybook/core-common';
|
|
2
|
-
export type { Options, Preset, BuilderResult, TypescriptOptions } from '@storybook/core-common';
|
|
3
|
-
export declare type RulesConfig = any;
|
|
4
|
-
export declare type ModuleConfig = {
|
|
5
|
-
rules?: RulesConfig[];
|
|
6
|
-
};
|
|
7
|
-
export declare type ResolveConfig = {
|
|
8
|
-
extensions?: string[];
|
|
9
|
-
mainFields?: string[] | string[][];
|
|
10
|
-
alias?: any;
|
|
11
|
-
};
|
|
12
|
-
export interface CommonWebpackConfiguration {
|
|
13
|
-
plugins?: any[];
|
|
14
|
-
module?: ModuleConfig;
|
|
15
|
-
resolve?: ResolveConfig;
|
|
16
|
-
optimization?: any;
|
|
17
|
-
devtool?: boolean | string;
|
|
18
|
-
}
|
|
19
|
-
export interface StorybookWebpackConfig<TConfiguration = CommonWebpackConfiguration> {
|
|
20
|
-
/**
|
|
21
|
-
* Modify or return a custom Webpack config after the Storybook's default configuration
|
|
22
|
-
* has run (mostly used by addons).
|
|
23
|
-
*/
|
|
24
|
-
webpack?: (config: TConfiguration, options: Options) => TConfiguration | Promise<TConfiguration>;
|
|
25
|
-
/**
|
|
26
|
-
* Modify or return a custom Webpack config after every addon has run.
|
|
27
|
-
*/
|
|
28
|
-
webpackFinal?: (config: TConfiguration, options: Options) => TConfiguration | Promise<TConfiguration>;
|
|
29
|
-
}
|
|
30
|
-
export declare type StorybookConfig<TWebpackConfiguration = CommonWebpackConfiguration> = BaseStorybookConfig & StorybookWebpackConfig<TWebpackConfiguration>;
|