@storybook/angular 6.4.0-beta.8 → 6.4.0-rc.10
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/ts3.4/builders/build-storybook/index.d.ts +4 -1
- package/dist/ts3.4/builders/start-storybook/index.d.ts +4 -1
- package/dist/ts3.4/client/preview/config.d.ts +2 -0
- package/dist/ts3.4/client/preview/decorateStory.d.ts +1 -0
- package/dist/ts3.4/server/angular-cli-webpack-12.2.x.d.ts +1 -0
- package/dist/ts3.4/server/angular-cli-webpack-13.x.x.d.ts +1 -0
- package/dist/ts3.4/server/angular-cli-webpack-older.d.ts +72 -0
- package/dist/ts3.4/server/angular-devkit-build-webpack.d.ts +1 -1
- package/dist/ts3.4/server/framework-preset-angular-cli.d.ts +2 -72
- package/dist/ts3.4/server/framework-preset-angular-ivy.d.ts +3 -3
- package/dist/ts3.4/server/options.d.ts +12 -1
- package/dist/ts3.4/server/preset.d.ts +3 -0
- package/dist/ts3.9/builders/build-storybook/index.d.ts +4 -1
- package/dist/ts3.9/builders/build-storybook/index.js +15 -14
- package/dist/ts3.9/builders/build-storybook/schema.json +54 -14
- package/dist/ts3.9/builders/start-storybook/index.d.ts +4 -1
- package/dist/ts3.9/builders/start-storybook/index.js +21 -14
- package/dist/ts3.9/builders/start-storybook/schema.json +54 -14
- package/dist/ts3.9/client/preview/config.d.ts +2 -0
- package/dist/ts3.9/client/preview/config.js +3 -0
- package/dist/ts3.9/client/preview/decorateStory.d.ts +1 -0
- package/dist/ts3.9/client/preview/decorateStory.js +2 -0
- package/dist/ts3.9/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +32 -0
- package/dist/ts3.9/server/angular-cli-webpack-12.2.x.d.ts +1 -0
- package/dist/ts3.9/server/angular-cli-webpack-12.2.x.js +93 -0
- package/dist/ts3.9/server/angular-cli-webpack-13.x.x.d.ts +1 -0
- package/dist/ts3.9/server/angular-cli-webpack-13.x.x.js +93 -0
- package/dist/ts3.9/server/angular-cli-webpack-older.d.ts +72 -0
- package/dist/ts3.9/server/angular-cli-webpack-older.js +156 -0
- package/dist/ts3.9/server/angular-devkit-build-webpack.d.ts +1 -1
- package/dist/ts3.9/server/angular-devkit-build-webpack.js +18 -8
- package/dist/ts3.9/server/framework-preset-angular-cli.d.ts +2 -72
- package/dist/ts3.9/server/framework-preset-angular-cli.js +119 -86
- package/dist/ts3.9/server/framework-preset-angular-ivy.d.ts +3 -3
- package/dist/ts3.9/server/framework-preset-angular-ivy.js +45 -10
- package/dist/ts3.9/server/options.d.ts +12 -1
- package/dist/ts3.9/server/options.js +1 -5
- package/dist/ts3.9/server/preset.d.ts +3 -0
- package/dist/ts3.9/server/preset.js +21 -0
- package/dist/ts3.9/server/utils/filter-out-styling-rules.d.ts +1 -1
- package/package.json +19 -12
- package/preset.js +1 -7
- package/standalone.d.ts +8 -0
- package/types-7-0.d.ts +1 -0
|
@@ -12,6 +12,33 @@
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
+
"no-confs-project": {
|
|
16
|
+
"root": "",
|
|
17
|
+
"architect": {
|
|
18
|
+
"target-build": {
|
|
19
|
+
"options": {
|
|
20
|
+
"tsConfig": "src/tsconfig.app.json",
|
|
21
|
+
"assets": []
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"no-target-conf-project": {
|
|
27
|
+
"root": "",
|
|
28
|
+
"architect": {
|
|
29
|
+
"target-build": {
|
|
30
|
+
"options": {
|
|
31
|
+
"tsConfig": "src/tsconfig.app.json",
|
|
32
|
+
"assets": []
|
|
33
|
+
},
|
|
34
|
+
"configurations": {
|
|
35
|
+
"other-conf": {
|
|
36
|
+
"styles": ["src/styles.css"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
15
42
|
"target-project": {
|
|
16
43
|
"root": "",
|
|
17
44
|
"architect": {
|
|
@@ -19,6 +46,11 @@
|
|
|
19
46
|
"options": {
|
|
20
47
|
"tsConfig": "src/tsconfig.app.json",
|
|
21
48
|
"assets": []
|
|
49
|
+
},
|
|
50
|
+
"configurations": {
|
|
51
|
+
"target-conf": {
|
|
52
|
+
"styles": ["src/styles.css"]
|
|
53
|
+
}
|
|
22
54
|
}
|
|
23
55
|
}
|
|
24
56
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getWebpackConfig(baseConfig: any, { builderOptions, builderContext }: any): Promise<any>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
49
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
50
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
51
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
52
|
+
r[k] = a[j];
|
|
53
|
+
return r;
|
|
54
|
+
};
|
|
55
|
+
// Private angular devkit stuff
|
|
56
|
+
var generateI18nBrowserWebpackConfigFromContext = require('@angular-devkit/build-angular/src/utils/webpack-browser-config').generateI18nBrowserWebpackConfigFromContext;
|
|
57
|
+
var _a = require('@angular-devkit/build-angular/src/webpack/configs'), getCommonConfig = _a.getCommonConfig, getStylesConfig = _a.getStylesConfig, getTypeScriptConfig = _a.getTypeScriptConfig;
|
|
58
|
+
var filterOutStylingRules = require('./utils/filter-out-styling-rules').filterOutStylingRules;
|
|
59
|
+
/**
|
|
60
|
+
* Extract webpack config from angular-cli 12.2.x
|
|
61
|
+
* ⚠️ This file is in JavaScript to not use TypeScript. Because current storybook TypeScript version is not compatible with Angular CLI.
|
|
62
|
+
* FIXME: Try another way with TypeScript on future storybook version (7 maybe 🤞)
|
|
63
|
+
*
|
|
64
|
+
* @param {*} baseConfig Previous webpack config from storybook
|
|
65
|
+
* @param {*} options { builderOptions, builderContext }
|
|
66
|
+
*/
|
|
67
|
+
exports.getWebpackConfig = function (baseConfig, _a) {
|
|
68
|
+
var builderOptions = _a.builderOptions, builderContext = _a.builderContext;
|
|
69
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
+
var cliConfig, entry, rulesExcludingStyles, module, plugins, resolve;
|
|
71
|
+
var _b, _c, _d;
|
|
72
|
+
return __generator(this, function (_e) {
|
|
73
|
+
switch (_e.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, generateI18nBrowserWebpackConfigFromContext(__assign(__assign({
|
|
75
|
+
// Default options
|
|
76
|
+
index: 'noop-index', main: 'noop-main', outputPath: 'noop-out' }, builderOptions), {
|
|
77
|
+
// Fixed options
|
|
78
|
+
optimization: false, namedChunks: false, progress: false, buildOptimizer: false, aot: false }), builderContext, function (wco) { return [getCommonConfig(wco), getStylesConfig(wco), getTypeScriptConfig(wco)]; })];
|
|
79
|
+
case 1:
|
|
80
|
+
cliConfig = (_e.sent()).config;
|
|
81
|
+
entry = __spreadArrays(baseConfig.entry, ((_b = cliConfig.entry.styles) !== null && _b !== void 0 ? _b : []), ((_c = cliConfig.entry.polyfills) !== null && _c !== void 0 ? _c : []));
|
|
82
|
+
rulesExcludingStyles = filterOutStylingRules(baseConfig);
|
|
83
|
+
module = __assign(__assign({}, baseConfig.module), { rules: __spreadArrays(cliConfig.module.rules, rulesExcludingStyles) });
|
|
84
|
+
plugins = __spreadArrays(((_d = cliConfig.plugins) !== null && _d !== void 0 ? _d : []), baseConfig.plugins);
|
|
85
|
+
resolve = __assign(__assign({}, baseConfig.resolve), { modules: Array.from(new Set(__spreadArrays(baseConfig.resolve.modules, cliConfig.resolve.modules))) });
|
|
86
|
+
return [2 /*return*/, __assign(__assign({}, baseConfig), { entry: entry,
|
|
87
|
+
module: module,
|
|
88
|
+
plugins: plugins,
|
|
89
|
+
resolve: resolve, resolveLoader: cliConfig.resolveLoader })];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getWebpackConfig(baseConfig: any, { builderOptions, builderContext }: any): Promise<any>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
49
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
50
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
51
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
52
|
+
r[k] = a[j];
|
|
53
|
+
return r;
|
|
54
|
+
};
|
|
55
|
+
// Private angular devkit stuff
|
|
56
|
+
var generateI18nBrowserWebpackConfigFromContext = require('@angular-devkit/build-angular/src/utils/webpack-browser-config').generateI18nBrowserWebpackConfigFromContext;
|
|
57
|
+
var _a = require('@angular-devkit/build-angular/src/webpack/configs'), getCommonConfig = _a.getCommonConfig, getStylesConfig = _a.getStylesConfig, getTypescriptWorkerPlugin = _a.getTypescriptWorkerPlugin;
|
|
58
|
+
var filterOutStylingRules = require('./utils/filter-out-styling-rules').filterOutStylingRules;
|
|
59
|
+
/**
|
|
60
|
+
* Extract webpack config from angular-cli 13.x.x
|
|
61
|
+
* ⚠️ This file is in JavaScript to not use TypeScript. Because current storybook TypeScript version is not compatible with Angular CLI.
|
|
62
|
+
* FIXME: Try another way with TypeScript on future storybook version (7 maybe 🤞)
|
|
63
|
+
*
|
|
64
|
+
* @param {*} baseConfig Previous webpack config from storybook
|
|
65
|
+
* @param {*} options { builderOptions, builderContext }
|
|
66
|
+
*/
|
|
67
|
+
exports.getWebpackConfig = function (baseConfig, _a) {
|
|
68
|
+
var builderOptions = _a.builderOptions, builderContext = _a.builderContext;
|
|
69
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
+
var cliConfig, entry, rulesExcludingStyles, module, plugins, resolve;
|
|
71
|
+
var _b, _c, _d;
|
|
72
|
+
return __generator(this, function (_e) {
|
|
73
|
+
switch (_e.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, generateI18nBrowserWebpackConfigFromContext(__assign(__assign({
|
|
75
|
+
// Default options
|
|
76
|
+
index: 'noop-index', main: 'noop-main', outputPath: 'noop-out' }, builderOptions), {
|
|
77
|
+
// Fixed options
|
|
78
|
+
optimization: false, namedChunks: false, progress: false, buildOptimizer: false, aot: false }), builderContext, function (wco) { return [getCommonConfig(wco), getStylesConfig(wco), getTypescriptWorkerPlugin(wco)]; })];
|
|
79
|
+
case 1:
|
|
80
|
+
cliConfig = (_e.sent()).config;
|
|
81
|
+
entry = __spreadArrays(baseConfig.entry, ((_b = cliConfig.entry.styles) !== null && _b !== void 0 ? _b : []), ((_c = cliConfig.entry.polyfills) !== null && _c !== void 0 ? _c : []));
|
|
82
|
+
rulesExcludingStyles = filterOutStylingRules(baseConfig);
|
|
83
|
+
module = __assign(__assign({}, baseConfig.module), { rules: __spreadArrays(cliConfig.module.rules, rulesExcludingStyles) });
|
|
84
|
+
plugins = __spreadArrays(((_d = cliConfig.plugins) !== null && _d !== void 0 ? _d : []), baseConfig.plugins);
|
|
85
|
+
resolve = __assign(__assign({}, baseConfig.resolve), { modules: Array.from(new Set(__spreadArrays(baseConfig.resolve.modules, cliConfig.resolve.modules))) });
|
|
86
|
+
return [2 /*return*/, __assign(__assign({}, baseConfig), { entry: entry,
|
|
87
|
+
module: module,
|
|
88
|
+
plugins: plugins,
|
|
89
|
+
resolve: resolve, resolveLoader: cliConfig.resolveLoader })];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
|
|
3
|
+
import { PresetOptions } from './options';
|
|
4
|
+
/**
|
|
5
|
+
* Old way currently support version lower than 12.2.x
|
|
6
|
+
*/
|
|
7
|
+
export declare function getWebpackConfig(baseConfig: webpack.Configuration, options: PresetOptions): Promise<webpack.Configuration | {
|
|
8
|
+
entry: any[];
|
|
9
|
+
module: {
|
|
10
|
+
rules: webpack.RuleSetRule[];
|
|
11
|
+
noParse?: RegExp | RegExp[] | ((content: string) => boolean);
|
|
12
|
+
unknownContextRequest?: string;
|
|
13
|
+
unknownContextRecursive?: boolean;
|
|
14
|
+
unknownContextRegExp?: RegExp;
|
|
15
|
+
unknownContextCritical?: boolean;
|
|
16
|
+
exprContextRequest?: string;
|
|
17
|
+
exprContextRegExp?: RegExp;
|
|
18
|
+
exprContextRecursive?: boolean;
|
|
19
|
+
exprContextCritical?: boolean;
|
|
20
|
+
wrappedContextRegExp?: RegExp;
|
|
21
|
+
wrappedContextRecursive?: boolean;
|
|
22
|
+
wrappedContextCritical?: boolean;
|
|
23
|
+
strictExportPresence?: boolean;
|
|
24
|
+
};
|
|
25
|
+
plugins: webpack.Plugin[];
|
|
26
|
+
resolve: {
|
|
27
|
+
modules: string[];
|
|
28
|
+
plugins: TsconfigPathsPlugin[];
|
|
29
|
+
descriptionFiles?: string[];
|
|
30
|
+
mainFields?: string[] | string[][];
|
|
31
|
+
aliasFields?: string[] | string[][];
|
|
32
|
+
mainFiles?: string[];
|
|
33
|
+
extensions?: string[];
|
|
34
|
+
enforceExtension?: boolean;
|
|
35
|
+
alias?: {
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
};
|
|
38
|
+
unsafeCache?: boolean | {};
|
|
39
|
+
cachePredicate?(data: {
|
|
40
|
+
path: string;
|
|
41
|
+
request: string;
|
|
42
|
+
}): boolean;
|
|
43
|
+
symlinks?: boolean;
|
|
44
|
+
cacheWithContext?: boolean;
|
|
45
|
+
roots?: string[];
|
|
46
|
+
};
|
|
47
|
+
resolveLoader: webpack.ResolveLoader;
|
|
48
|
+
mode?: "development" | "production" | "none";
|
|
49
|
+
name?: string;
|
|
50
|
+
context?: string;
|
|
51
|
+
devtool?: webpack.Options.Devtool;
|
|
52
|
+
output?: webpack.Output;
|
|
53
|
+
externals?: string | RegExp | webpack.ExternalsObjectElement | webpack.ExternalsFunctionElement | webpack.ExternalsElement[];
|
|
54
|
+
target?: "node" | "web" | "webworker" | "async-node" | "node-webkit" | "atom" | "electron" | "electron-renderer" | "electron-preload" | "electron-main" | ((compiler?: any) => void);
|
|
55
|
+
bail?: boolean;
|
|
56
|
+
profile?: boolean;
|
|
57
|
+
cache?: boolean | object;
|
|
58
|
+
watch?: boolean;
|
|
59
|
+
watchOptions?: webpack.ICompiler.WatchOptions;
|
|
60
|
+
node?: false | webpack.Node;
|
|
61
|
+
amd?: {
|
|
62
|
+
[moduleName: string]: boolean;
|
|
63
|
+
};
|
|
64
|
+
recordsPath?: string;
|
|
65
|
+
recordsInputPath?: string;
|
|
66
|
+
recordsOutputPath?: string;
|
|
67
|
+
stats?: webpack.Stats.ToStringOptions;
|
|
68
|
+
performance?: false | webpack.Options.Performance;
|
|
69
|
+
parallelism?: number;
|
|
70
|
+
optimization?: webpack.Options.Optimization;
|
|
71
|
+
devServer?: import("webpack-dev-server").Configuration;
|
|
72
|
+
}>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
50
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
51
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
52
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
53
|
+
r[k] = a[j];
|
|
54
|
+
return r;
|
|
55
|
+
};
|
|
56
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.getWebpackConfig = void 0;
|
|
61
|
+
var node_logger_1 = require("@storybook/node-logger");
|
|
62
|
+
var tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
63
|
+
var architect_1 = require("@angular-devkit/architect");
|
|
64
|
+
var angular_read_workspace_1 = require("./angular-read-workspace");
|
|
65
|
+
var angular_devkit_build_webpack_1 = require("./angular-devkit-build-webpack");
|
|
66
|
+
var filter_out_styling_rules_1 = require("./utils/filter-out-styling-rules");
|
|
67
|
+
/**
|
|
68
|
+
* Old way currently support version lower than 12.2.x
|
|
69
|
+
*/
|
|
70
|
+
function getWebpackConfig(baseConfig, options) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var dirToSearch, workspaceConfig, error_1, project, target, confName, browserTarget, fondProject, angularCliWebpackConfig, error_2;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
dirToSearch = process.cwd();
|
|
77
|
+
_a.label = 1;
|
|
78
|
+
case 1:
|
|
79
|
+
_a.trys.push([1, 3, , 4]);
|
|
80
|
+
return [4 /*yield*/, angular_read_workspace_1.readAngularWorkspaceConfig(dirToSearch)];
|
|
81
|
+
case 2:
|
|
82
|
+
workspaceConfig = _a.sent();
|
|
83
|
+
return [3 /*break*/, 4];
|
|
84
|
+
case 3:
|
|
85
|
+
error_1 = _a.sent();
|
|
86
|
+
node_logger_1.logger.error("=> Could not find angular workspace config (angular.json) on this path \"" + dirToSearch + "\"");
|
|
87
|
+
node_logger_1.logger.info("=> Fail to load angular-cli config. Using base config");
|
|
88
|
+
return [2 /*return*/, baseConfig];
|
|
89
|
+
case 4:
|
|
90
|
+
try {
|
|
91
|
+
// Default behavior when `angularBrowserTarget` are not explicitly defined to null
|
|
92
|
+
if (options.angularBrowserTarget !== null) {
|
|
93
|
+
browserTarget = options.angularBrowserTarget
|
|
94
|
+
? architect_1.targetFromTargetString(options.angularBrowserTarget)
|
|
95
|
+
: {
|
|
96
|
+
configuration: undefined,
|
|
97
|
+
project: angular_read_workspace_1.getDefaultProjectName(workspaceConfig),
|
|
98
|
+
target: 'build',
|
|
99
|
+
};
|
|
100
|
+
fondProject = angular_read_workspace_1.findAngularProjectTarget(workspaceConfig, browserTarget.project, browserTarget.target);
|
|
101
|
+
project = fondProject.project;
|
|
102
|
+
target = fondProject.target;
|
|
103
|
+
confName = browserTarget.configuration;
|
|
104
|
+
node_logger_1.logger.info("=> Using angular project \"" + browserTarget.project + ":" + browserTarget.target + (confName ? ":" + confName : '') + "\" for configuring Storybook");
|
|
105
|
+
}
|
|
106
|
+
// Start storybook when only tsConfig is provided.
|
|
107
|
+
if (options.angularBrowserTarget === null && options.tsConfig) {
|
|
108
|
+
node_logger_1.logger.info("=> Using default angular project with \"tsConfig:" + options.tsConfig + "\"");
|
|
109
|
+
project = { root: '', extensions: {}, targets: undefined };
|
|
110
|
+
target = { builder: '', options: { tsConfig: options.tsConfig } };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
node_logger_1.logger.error("=> Could not find angular project: " + error.message);
|
|
115
|
+
node_logger_1.logger.info("=> Fail to load angular-cli config. Using base config");
|
|
116
|
+
return [2 /*return*/, baseConfig];
|
|
117
|
+
}
|
|
118
|
+
_a.label = 5;
|
|
119
|
+
case 5:
|
|
120
|
+
_a.trys.push([5, 7, , 8]);
|
|
121
|
+
return [4 /*yield*/, angular_devkit_build_webpack_1.extractAngularCliWebpackConfig(dirToSearch, project, target, confName)];
|
|
122
|
+
case 6:
|
|
123
|
+
angularCliWebpackConfig = _a.sent();
|
|
124
|
+
node_logger_1.logger.info("=> Using angular-cli webpack config");
|
|
125
|
+
return [3 /*break*/, 8];
|
|
126
|
+
case 7:
|
|
127
|
+
error_2 = _a.sent();
|
|
128
|
+
node_logger_1.logger.error("=> Could not get angular cli webpack config");
|
|
129
|
+
throw error_2;
|
|
130
|
+
case 8: return [2 /*return*/, mergeAngularCliWebpackConfig(angularCliWebpackConfig, baseConfig)];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
exports.getWebpackConfig = getWebpackConfig;
|
|
136
|
+
function mergeAngularCliWebpackConfig(_a, baseConfig) {
|
|
137
|
+
var cliCommonWebpackConfig = _a.cliCommonWebpackConfig, cliStyleWebpackConfig = _a.cliStyleWebpackConfig, tsConfigPath = _a.tsConfigPath;
|
|
138
|
+
// Don't use storybooks styling rules because we have to use rules created by @angular-devkit/build-angular
|
|
139
|
+
// because @angular-devkit/build-angular created rules have include/exclude for global style files.
|
|
140
|
+
var rulesExcludingStyles = filter_out_styling_rules_1.filterOutStylingRules(baseConfig);
|
|
141
|
+
// styleWebpackConfig.entry adds global style files to the webpack context
|
|
142
|
+
var entry = __spreadArrays(baseConfig.entry, Object.values(cliStyleWebpackConfig.entry).reduce(function (acc, item) { return acc.concat(item); }, []));
|
|
143
|
+
var module = __assign(__assign({}, baseConfig.module), { rules: __spreadArrays(cliStyleWebpackConfig.module.rules, rulesExcludingStyles) });
|
|
144
|
+
// We use cliCommonConfig plugins to serve static assets files.
|
|
145
|
+
var plugins = __spreadArrays(cliStyleWebpackConfig.plugins, cliCommonWebpackConfig.plugins, baseConfig.plugins);
|
|
146
|
+
var resolve = __assign(__assign({}, baseConfig.resolve), { modules: Array.from(new Set(__spreadArrays(baseConfig.resolve.modules, cliCommonWebpackConfig.resolve.modules))), plugins: [
|
|
147
|
+
new tsconfig_paths_webpack_plugin_1.default({
|
|
148
|
+
configFile: tsConfigPath,
|
|
149
|
+
mainFields: ['browser', 'module', 'main'],
|
|
150
|
+
}),
|
|
151
|
+
] });
|
|
152
|
+
return __assign(__assign({}, baseConfig), { entry: entry,
|
|
153
|
+
module: module,
|
|
154
|
+
plugins: plugins,
|
|
155
|
+
resolve: resolve, resolveLoader: cliCommonWebpackConfig.resolveLoader });
|
|
156
|
+
}
|
|
@@ -27,4 +27,4 @@ export declare type AngularCliWebpackConfig = {
|
|
|
27
27
|
* Uses angular cli to extract webpack configuration.
|
|
28
28
|
* The `AngularCliWebpackConfig` type lists the parts used by storybook
|
|
29
29
|
*/
|
|
30
|
-
export declare function extractAngularCliWebpackConfig(dirToSearch: string, project: workspaces.ProjectDefinition, target: workspaces.TargetDefinition): Promise<AngularCliWebpackConfig>;
|
|
30
|
+
export declare function extractAngularCliWebpackConfig(dirToSearch: string, project: workspaces.ProjectDefinition, target: workspaces.TargetDefinition, confName?: string): Promise<AngularCliWebpackConfig>;
|
|
@@ -122,12 +122,22 @@ var importAngularCliReadTsconfigUtil = function () {
|
|
|
122
122
|
}
|
|
123
123
|
throw new Error('ReadTsconfig not found in "@angular-devkit/build-angular"');
|
|
124
124
|
};
|
|
125
|
-
var buildWebpackConfigOptions = function (dirToSearch, project, target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
-
var
|
|
127
|
-
return __generator(this, function (
|
|
128
|
-
switch (
|
|
125
|
+
var buildWebpackConfigOptions = function (dirToSearch, project, target, confName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
var conf, projectBuildOptions, requiredOptions, workspaceRootNormalized, projectRootNormalized, sourceRootNormalized, tsConfigPath, tsConfig, ts, scriptTarget, buildOptions;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
129
|
case 0:
|
|
130
|
-
|
|
130
|
+
conf = {};
|
|
131
|
+
if (confName) {
|
|
132
|
+
if (!target.configurations) {
|
|
133
|
+
throw new Error('Missing "configurations" section in project target');
|
|
134
|
+
}
|
|
135
|
+
if (!target.configurations[confName]) {
|
|
136
|
+
throw new Error("Missing required configuration in project target. Check \"" + confName + "\"");
|
|
137
|
+
}
|
|
138
|
+
conf = target.configurations[confName];
|
|
139
|
+
}
|
|
140
|
+
projectBuildOptions = __assign(__assign({}, target.options), conf);
|
|
131
141
|
requiredOptions = ['tsConfig'];
|
|
132
142
|
if (!requiredOptions.every(function (key) { return !!projectBuildOptions[key]; })) {
|
|
133
143
|
throw new Error("Missing required options in project target. Check \"" + requiredOptions.join(', ') + "\"");
|
|
@@ -141,7 +151,7 @@ var buildWebpackConfigOptions = function (dirToSearch, project, target) { return
|
|
|
141
151
|
tsConfig = importAngularCliReadTsconfigUtil().readTsconfig(tsConfigPath);
|
|
142
152
|
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('typescript')); })];
|
|
143
153
|
case 1:
|
|
144
|
-
ts =
|
|
154
|
+
ts = _a.sent();
|
|
145
155
|
scriptTarget = tsConfig.options.target || ts.ScriptTarget.ES5;
|
|
146
156
|
buildOptions = __assign(__assign({
|
|
147
157
|
// Default options
|
|
@@ -166,7 +176,7 @@ var buildWebpackConfigOptions = function (dirToSearch, project, target) { return
|
|
|
166
176
|
* Uses angular cli to extract webpack configuration.
|
|
167
177
|
* The `AngularCliWebpackConfig` type lists the parts used by storybook
|
|
168
178
|
*/
|
|
169
|
-
function extractAngularCliWebpackConfig(dirToSearch, project, target) {
|
|
179
|
+
function extractAngularCliWebpackConfig(dirToSearch, project, target, confName) {
|
|
170
180
|
var _a;
|
|
171
181
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
182
|
var _b, getCommonConfig, getStylesConfig, webpackConfigOptions, cliCommonConfig, cliStyleConfig;
|
|
@@ -174,7 +184,7 @@ function extractAngularCliWebpackConfig(dirToSearch, project, target) {
|
|
|
174
184
|
switch (_c.label) {
|
|
175
185
|
case 0:
|
|
176
186
|
_b = importAngularCliWebpackConfigGenerator(), getCommonConfig = _b.getCommonConfig, getStylesConfig = _b.getStylesConfig;
|
|
177
|
-
return [4 /*yield*/, buildWebpackConfigOptions(dirToSearch, project, target)];
|
|
187
|
+
return [4 /*yield*/, buildWebpackConfigOptions(dirToSearch, project, target, confName)];
|
|
178
188
|
case 1:
|
|
179
189
|
webpackConfigOptions = _c.sent();
|
|
180
190
|
cliCommonConfig = getCommonConfig(webpackConfigOptions);
|
|
@@ -1,73 +1,3 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export declare type Options = CoreOptions & {
|
|
5
|
-
angularBrowserTarget?: string;
|
|
6
|
-
tsConfig?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function webpackFinal(baseConfig: webpack.Configuration, options: Options): Promise<webpack.Configuration | {
|
|
9
|
-
entry: any[];
|
|
10
|
-
module: {
|
|
11
|
-
rules: webpack.RuleSetRule[];
|
|
12
|
-
noParse?: RegExp | RegExp[] | ((content: string) => boolean);
|
|
13
|
-
unknownContextRequest?: string;
|
|
14
|
-
unknownContextRecursive?: boolean;
|
|
15
|
-
unknownContextRegExp?: RegExp;
|
|
16
|
-
unknownContextCritical?: boolean;
|
|
17
|
-
exprContextRequest?: string;
|
|
18
|
-
exprContextRegExp?: RegExp;
|
|
19
|
-
exprContextRecursive?: boolean;
|
|
20
|
-
exprContextCritical?: boolean;
|
|
21
|
-
wrappedContextRegExp?: RegExp;
|
|
22
|
-
wrappedContextRecursive?: boolean;
|
|
23
|
-
wrappedContextCritical?: boolean;
|
|
24
|
-
strictExportPresence?: boolean;
|
|
25
|
-
};
|
|
26
|
-
plugins: webpack.Plugin[];
|
|
27
|
-
resolve: {
|
|
28
|
-
modules: string[];
|
|
29
|
-
plugins: TsconfigPathsPlugin[];
|
|
30
|
-
descriptionFiles?: string[];
|
|
31
|
-
mainFields?: string[] | string[][];
|
|
32
|
-
aliasFields?: string[] | string[][];
|
|
33
|
-
mainFiles?: string[];
|
|
34
|
-
extensions?: string[];
|
|
35
|
-
enforceExtension?: boolean;
|
|
36
|
-
alias?: {
|
|
37
|
-
[key: string]: string;
|
|
38
|
-
};
|
|
39
|
-
unsafeCache?: boolean | {};
|
|
40
|
-
cachePredicate?(data: {
|
|
41
|
-
path: string;
|
|
42
|
-
request: string;
|
|
43
|
-
}): boolean;
|
|
44
|
-
symlinks?: boolean;
|
|
45
|
-
cacheWithContext?: boolean;
|
|
46
|
-
roots?: string[];
|
|
47
|
-
};
|
|
48
|
-
resolveLoader: webpack.ResolveLoader;
|
|
49
|
-
mode?: "development" | "production" | "none";
|
|
50
|
-
name?: string;
|
|
51
|
-
context?: string;
|
|
52
|
-
devtool?: webpack.Options.Devtool;
|
|
53
|
-
output?: webpack.Output;
|
|
54
|
-
externals?: string | RegExp | webpack.ExternalsObjectElement | webpack.ExternalsFunctionElement | webpack.ExternalsElement[];
|
|
55
|
-
target?: "node" | "web" | "webworker" | "async-node" | "node-webkit" | "atom" | "electron" | "electron-renderer" | "electron-preload" | "electron-main" | ((compiler?: any) => void);
|
|
56
|
-
bail?: boolean;
|
|
57
|
-
profile?: boolean;
|
|
58
|
-
cache?: boolean | object;
|
|
59
|
-
watch?: boolean;
|
|
60
|
-
watchOptions?: webpack.ICompiler.WatchOptions;
|
|
61
|
-
node?: false | webpack.Node;
|
|
62
|
-
amd?: {
|
|
63
|
-
[moduleName: string]: boolean;
|
|
64
|
-
};
|
|
65
|
-
recordsPath?: string;
|
|
66
|
-
recordsInputPath?: string;
|
|
67
|
-
recordsOutputPath?: string;
|
|
68
|
-
stats?: webpack.Stats.ToStringOptions;
|
|
69
|
-
performance?: false | webpack.Options.Performance;
|
|
70
|
-
parallelism?: number;
|
|
71
|
-
optimization?: webpack.Options.Optimization;
|
|
72
|
-
devServer?: import("webpack-dev-server").Configuration;
|
|
73
|
-
}>;
|
|
2
|
+
import { PresetOptions } from './options';
|
|
3
|
+
export declare function webpackFinal(baseConfig: webpack.Configuration, options: PresetOptions): Promise<webpack.Configuration>;
|