piral-cli-webpack5 1.0.0-pre.1960 → 1.0.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/LICENSE +1 -1
- package/README.md +31 -10
- package/extend-config.js +125 -18
- package/lib/actions.d.ts +2 -2
- package/lib/actions.js +33 -39
- package/lib/actions.js.map +1 -1
- package/lib/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.js +1 -1
- package/lib/enhancers/hmr-webpack-config-enhancer/HotModuleServerPlugin.js.map +1 -0
- package/lib/enhancers/hmr-webpack-config-enhancer/index.d.ts +5 -0
- package/lib/enhancers/hmr-webpack-config-enhancer/index.js +30 -0
- package/lib/enhancers/hmr-webpack-config-enhancer/index.js.map +1 -0
- package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.d.ts +2 -2
- package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.js +1 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.d.ts +2 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js +17 -6
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js.map +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.d.ts +5 -0
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js +53 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/index.d.ts +18 -4
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js +117 -49
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js.map +1 -1
- package/lib/enhancers/piral-instance-webpack-config-enhancer/helpers.js +2 -0
- package/lib/enhancers/piral-instance-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.d.ts +2 -3
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js +6 -7
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js.map +1 -1
- package/lib/helpers.d.ts +2 -1
- package/lib/helpers.js +10 -4
- package/lib/helpers.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/SheetLoader.d.ts +1 -0
- package/lib/plugins/SheetLoader.js +19 -0
- package/lib/plugins/SheetLoader.js.map +1 -0
- package/lib/plugins/SheetPlugin.d.ts +7 -0
- package/lib/plugins/SheetPlugin.js +31 -0
- package/lib/plugins/SheetPlugin.js.map +1 -0
- package/lib/plugins/StylesLoader.d.ts +1 -0
- package/lib/plugins/StylesLoader.js +14 -0
- package/lib/plugins/StylesLoader.js.map +1 -0
- package/lib/plugins/StylesPlugin.d.ts +6 -0
- package/lib/plugins/StylesPlugin.js +34 -0
- package/lib/plugins/StylesPlugin.js.map +1 -0
- package/lib/webpack/bundler-run.d.ts +2 -21
- package/lib/webpack/bundler-run.js +54 -46
- package/lib/webpack/bundler-run.js.map +1 -1
- package/lib/webpack/common.d.ts +8 -0
- package/lib/webpack/common.js +104 -0
- package/lib/webpack/common.js.map +1 -0
- package/lib/webpack/pilet.d.ts +19 -0
- package/lib/webpack/pilet.js +97 -0
- package/lib/webpack/pilet.js.map +1 -0
- package/lib/webpack/piral.d.ts +16 -0
- package/lib/webpack/piral.js +90 -0
- package/lib/webpack/piral.js.map +1 -0
- package/package.json +28 -29
- package/src/actions.ts +33 -20
- package/src/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.ts +1 -1
- package/src/enhancers/hmr-webpack-config-enhancer/index.ts +34 -0
- package/src/enhancers/html5-entry-webpack-config-enhancer/helpers.ts +7 -7
- package/src/enhancers/html5-entry-webpack-config-enhancer/index.ts +31 -19
- package/src/enhancers/pilet-webpack-config-enhancer/helpers.ts +62 -0
- package/src/enhancers/pilet-webpack-config-enhancer/index.ts +187 -59
- package/src/enhancers/piral-instance-webpack-config-enhancer/helpers.ts +2 -0
- package/src/enhancers/piral-instance-webpack-config-enhancer/index.ts +14 -18
- package/src/helpers.ts +15 -5
- package/src/index.ts +1 -1
- package/src/plugins/SheetLoader.ts +16 -0
- package/src/plugins/SheetPlugin.ts +34 -0
- package/src/plugins/StylesLoader.ts +11 -0
- package/src/plugins/StylesPlugin.ts +35 -0
- package/src/webpack/bundler-run.ts +60 -56
- package/src/webpack/common.ts +111 -0
- package/src/webpack/pilet.ts +121 -0
- package/src/webpack/piral.ts +110 -0
- package/src/webpack-hot-middleware/LICENSE +20 -0
- package/src/webpack-hot-middleware/client-overlay.js +99 -0
- package/src/webpack-hot-middleware/client.js +306 -0
- package/src/webpack-hot-middleware/helpers.js +9 -0
- package/src/webpack-hot-middleware/middleware.js +175 -0
- package/src/webpack-hot-middleware/process-update.js +157 -0
- package/lib/configs/HotModuleServerPlugin.js.map +0 -1
- package/lib/configs/SheetLoader.d.ts +0 -1
- package/lib/configs/SheetLoader.js +0 -27
- package/lib/configs/SheetLoader.js.map +0 -1
- package/lib/configs/common.d.ts +0 -6
- package/lib/configs/common.js +0 -115
- package/lib/configs/common.js.map +0 -1
- package/lib/configs/index.d.ts +0 -2
- package/lib/configs/index.js +0 -15
- package/lib/configs/index.js.map +0 -1
- package/lib/configs/pilet.d.ts +0 -3
- package/lib/configs/pilet.js +0 -72
- package/lib/configs/pilet.js.map +0 -1
- package/lib/configs/piral.d.ts +0 -2
- package/lib/configs/piral.js +0 -65
- package/lib/configs/piral.js.map +0 -1
- package/lib/webpack/bundler-calls.d.ts +0 -3
- package/lib/webpack/bundler-calls.js +0 -93
- package/lib/webpack/bundler-calls.js.map +0 -1
- package/lib/webpack/index.d.ts +0 -1
- package/lib/webpack/index.js +0 -14
- package/lib/webpack/index.js.map +0 -1
- package/lib/webpack/run-build-pilet.d.ts +0 -1
- package/lib/webpack/run-build-pilet.js +0 -53
- package/lib/webpack/run-build-pilet.js.map +0 -1
- package/lib/webpack/run-build-piral.d.ts +0 -1
- package/lib/webpack/run-build-piral.js +0 -56
- package/lib/webpack/run-build-piral.js.map +0 -1
- package/lib/webpack/run-debug-mono-piral.d.ts +0 -1
- package/lib/webpack/run-debug-mono-piral.js +0 -61
- package/lib/webpack/run-debug-mono-piral.js.map +0 -1
- package/lib/webpack/run-debug-pilet.d.ts +0 -1
- package/lib/webpack/run-debug-pilet.js +0 -77
- package/lib/webpack/run-debug-pilet.js.map +0 -1
- package/lib/webpack/run-debug-piral.d.ts +0 -1
- package/lib/webpack/run-debug-piral.js +0 -76
- package/lib/webpack/run-debug-piral.js.map +0 -1
- package/src/configs/SheetLoader.ts +0 -12
- package/src/configs/common.ts +0 -118
- package/src/configs/index.ts +0 -2
- package/src/configs/pilet.ts +0 -82
- package/src/configs/piral.ts +0 -73
- package/src/webpack/bundler-calls.ts +0 -107
- package/src/webpack/index.ts +0 -1
- package/src/webpack/run-build-pilet.ts +0 -82
- package/src/webpack/run-build-piral.ts +0 -83
- package/src/webpack/run-debug-mono-piral.ts +0 -76
- package/src/webpack/run-debug-pilet.ts +0 -94
- package/src/webpack/run-debug-piral.ts +0 -95
- /package/lib/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.d.ts +0 -0
|
@@ -1,60 +1,128 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.piletWebpackConfigEnhancer = void 0;
|
|
4
|
+
const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
|
|
4
5
|
const webpack_1 = require("webpack");
|
|
5
6
|
const helpers_1 = require("./helpers");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'react-dom',
|
|
17
|
-
'react-router',
|
|
18
|
-
'react-router-dom',
|
|
19
|
-
'tslib',
|
|
20
|
-
'path-to-regexp',
|
|
21
|
-
];
|
|
7
|
+
const StylesPlugin_1 = require("../../plugins/StylesPlugin");
|
|
8
|
+
const SheetPlugin_1 = require("../../plugins/SheetPlugin");
|
|
9
|
+
const piletCss = 'main.css';
|
|
10
|
+
function piletVxWebpackConfigEnhancer(options, compiler) {
|
|
11
|
+
const { variables, externals } = options;
|
|
12
|
+
(0, helpers_1.withSetPath)(compiler);
|
|
13
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
14
|
+
(0, helpers_1.withExternals)(compiler, externals);
|
|
15
|
+
compiler.plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)));
|
|
16
|
+
return compiler;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const { name, version, piral, externals = getExternals(piral), schema } = options;
|
|
18
|
+
function piletV0WebpackConfigEnhancer(options, compiler) {
|
|
19
|
+
const { name, variables, externals, file, entry } = options;
|
|
26
20
|
const shortName = name.replace(/\W/gi, '');
|
|
27
21
|
const jsonpFunction = `pr_${shortName}`;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
22
|
+
const banner = `//@pilet v:0`;
|
|
23
|
+
(0, helpers_1.withSetPath)(compiler);
|
|
24
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
25
|
+
(0, helpers_1.withExternals)(compiler, externals);
|
|
26
|
+
compiler.plugins.push(new SheetPlugin_1.default(piletCss, name, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
27
|
+
banner,
|
|
28
|
+
entryOnly: true,
|
|
29
|
+
include: file,
|
|
30
|
+
raw: true,
|
|
31
|
+
}));
|
|
32
|
+
compiler.output.uniqueName = `${jsonpFunction}`;
|
|
33
|
+
compiler.output.library = name;
|
|
34
|
+
compiler.output.libraryTarget = 'umd';
|
|
35
|
+
return compiler;
|
|
36
|
+
}
|
|
37
|
+
function piletV1WebpackConfigEnhancer(options, compiler) {
|
|
38
|
+
const { name, variables, externals, file, entry } = options;
|
|
39
|
+
const shortName = name.replace(/\W/gi, '');
|
|
40
|
+
const jsonpFunction = `pr_${shortName}`;
|
|
41
|
+
const banner = `//@pilet v:1(${jsonpFunction})`;
|
|
42
|
+
(0, helpers_1.withSetPath)(compiler);
|
|
43
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
44
|
+
(0, helpers_1.withExternals)(compiler, externals);
|
|
45
|
+
compiler.plugins.push(new SheetPlugin_1.default(piletCss, name, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
46
|
+
banner,
|
|
47
|
+
entryOnly: true,
|
|
48
|
+
include: file,
|
|
49
|
+
raw: true,
|
|
50
|
+
}));
|
|
51
|
+
compiler.output.uniqueName = `${jsonpFunction}`;
|
|
52
|
+
compiler.output.library = name;
|
|
53
|
+
compiler.output.libraryTarget = 'umd';
|
|
54
|
+
compiler.output.auxiliaryComment = {
|
|
55
|
+
commonjs2: `\nfunction define(d,k){(typeof document!=='undefined')&&(document.currentScript.app=k.apply(null,d.map(window.${jsonpFunction})));}define.amd=!0;`,
|
|
56
|
+
};
|
|
57
|
+
return compiler;
|
|
58
|
+
}
|
|
59
|
+
function piletV2WebpackConfigEnhancer(options, compiler) {
|
|
60
|
+
const { name, variables, externals, file, importmap, entry } = options;
|
|
61
|
+
const shortName = name.replace(/\W/gi, '');
|
|
62
|
+
const jsonpFunction = `pr_${shortName}`;
|
|
63
|
+
const plugins = [];
|
|
64
|
+
(0, helpers_1.withExternals)(compiler, externals);
|
|
65
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
66
|
+
const dependencies = (0, helpers_1.getDependencies)(importmap, compiler);
|
|
67
|
+
const banner = `//@pilet v:2(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`;
|
|
68
|
+
plugins.push(new SheetPlugin_1.default(piletCss, name, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
69
|
+
banner,
|
|
70
|
+
entryOnly: true,
|
|
71
|
+
include: file,
|
|
72
|
+
raw: true,
|
|
73
|
+
}), new SystemJSPublicPathWebpackPlugin());
|
|
74
|
+
compiler.plugins = [...compiler.plugins, ...plugins];
|
|
75
|
+
compiler.output.uniqueName = `${jsonpFunction}`;
|
|
76
|
+
compiler.output.library = { type: 'system' };
|
|
77
|
+
return compiler;
|
|
78
|
+
}
|
|
79
|
+
function piletV3WebpackConfigEnhancer(options, compiler) {
|
|
80
|
+
const { name, variables, externals, file, importmap, entry } = options;
|
|
81
|
+
const shortName = name.replace(/\W/gi, '');
|
|
82
|
+
const jsonpFunction = `pr_${shortName}`;
|
|
83
|
+
const plugins = [];
|
|
84
|
+
(0, helpers_1.withExternals)(compiler, externals);
|
|
85
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
86
|
+
const dependencies = (0, helpers_1.getDependencies)(importmap, compiler);
|
|
87
|
+
const banner = `//@pilet v:3(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`;
|
|
88
|
+
plugins.push(new StylesPlugin_1.default(piletCss, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
89
|
+
banner,
|
|
90
|
+
entryOnly: true,
|
|
91
|
+
include: file,
|
|
92
|
+
raw: true,
|
|
93
|
+
}));
|
|
94
|
+
compiler.output.publicPath = '';
|
|
95
|
+
compiler.output.chunkFormat = 'module';
|
|
96
|
+
compiler.plugins = [...compiler.plugins, ...plugins];
|
|
97
|
+
compiler.output.uniqueName = `${jsonpFunction}`;
|
|
98
|
+
compiler.output.library = { type: 'system' };
|
|
99
|
+
compiler.target = 'node';
|
|
100
|
+
return compiler;
|
|
101
|
+
}
|
|
102
|
+
const piletWebpackConfigEnhancer = (details) => (compiler) => {
|
|
103
|
+
const { externals = [], schema, importmap } = details;
|
|
104
|
+
const environment = process.env.NODE_ENV || 'development';
|
|
105
|
+
const options = {
|
|
106
|
+
entry: details.entry,
|
|
107
|
+
externals,
|
|
108
|
+
file: details.filename,
|
|
109
|
+
name: details.name,
|
|
110
|
+
importmap,
|
|
111
|
+
variables: Object.assign(Object.assign({}, (0, helpers_1.getVariables)(details.name, details.version, environment)), details.variables),
|
|
112
|
+
};
|
|
113
|
+
switch (schema) {
|
|
114
|
+
case 'v0':
|
|
115
|
+
return piletV0WebpackConfigEnhancer(options, compiler);
|
|
116
|
+
case 'v1':
|
|
117
|
+
return piletV1WebpackConfigEnhancer(options, compiler);
|
|
118
|
+
case 'v2':
|
|
119
|
+
return piletV2WebpackConfigEnhancer(options, compiler);
|
|
120
|
+
case 'v3':
|
|
121
|
+
return piletV3WebpackConfigEnhancer(options, compiler);
|
|
122
|
+
case 'none':
|
|
123
|
+
default:
|
|
124
|
+
return piletVxWebpackConfigEnhancer(options, compiler);
|
|
52
125
|
}
|
|
53
|
-
compilerOptions.externals = Array.isArray(current)
|
|
54
|
-
? [...current, ...externals]
|
|
55
|
-
: current
|
|
56
|
-
? [current, ...externals]
|
|
57
|
-
: externals;
|
|
58
|
-
return compilerOptions;
|
|
59
126
|
};
|
|
127
|
+
exports.piletWebpackConfigEnhancer = piletWebpackConfigEnhancer;
|
|
60
128
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/pilet-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/pilet-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,4GAA4G;A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,CAC1B,IAAY,EACZ,OAAe,EACf,SAAwB,EACxB,GAAW;IAEX,OAAO;QACL,QAAQ,EAAE,GAAG;QACb,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,YAAY,EAAE;QACrC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACzC,kBAAkB,EAAE,OAAO;QAC3B,eAAe,EAAE,IAAI;QACrB,mBAAmB,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/enhancers/piral-instance-webpack-config-enhancer/helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAC1B,IAAY,EACZ,OAAe,EACf,SAAwB,EACxB,GAAW;IAEX,OAAO;QACL,QAAQ,EAAE,GAAG;QACb,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,YAAY,EAAE;QACrC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACzC,kBAAkB,EAAE,OAAO;QAC3B,eAAe,EAAE,IAAI;QACrB,mBAAmB,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;QACxC,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC;AAhBD,oCAgBC;AAED,SAAgB,cAAc,CAAC,SAA2C;IACxE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAFD,wCAEC;AAED,SAAgB,kBAAkB,CAAC,SAA2C;IAC5E,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7D,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AALD,gDAKC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
1
2
|
export interface PiralInstanceWebpackPluginOptions {
|
|
2
3
|
name: string;
|
|
3
4
|
version: string;
|
|
4
5
|
externals: Array<string>;
|
|
5
6
|
variables?: Record<string, boolean | string>;
|
|
6
|
-
debug?: boolean | string;
|
|
7
|
-
emulator?: boolean | string;
|
|
8
7
|
}
|
|
9
|
-
export declare const piralInstanceWebpackConfigEnhancer: (options: PiralInstanceWebpackPluginOptions) => (compilerOptions:
|
|
8
|
+
export declare const piralInstanceWebpackConfigEnhancer: (options: PiralInstanceWebpackPluginOptions) => (compilerOptions: Configuration) => Configuration;
|
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.piralInstanceWebpackConfigEnhancer = void 0;
|
|
4
4
|
const webpack_1 = require("webpack");
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
|
-
|
|
7
|
-
const { name, version,
|
|
6
|
+
const piralInstanceWebpackConfigEnhancer = (options) => (compilerOptions) => {
|
|
7
|
+
const { name, version, externals } = options;
|
|
8
8
|
const environment = process.env.NODE_ENV || 'development';
|
|
9
|
-
const variables = Object.assign(Object.assign({}, helpers_1.getVariables(name, version, externals, environment)), options.variables);
|
|
10
|
-
|
|
11
|
-
variables
|
|
12
|
-
const plugins = [new webpack_1.DefinePlugin(helpers_1.getDefineVariables(variables))];
|
|
13
|
-
helpers_1.setEnvironment(variables);
|
|
9
|
+
const variables = Object.assign(Object.assign({}, (0, helpers_1.getVariables)(name, version, externals, environment)), options.variables);
|
|
10
|
+
const plugins = [new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables))];
|
|
11
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
14
12
|
compilerOptions.plugins = [...(compilerOptions.plugins || []), ...plugins];
|
|
15
13
|
return compilerOptions;
|
|
16
14
|
};
|
|
15
|
+
exports.piralInstanceWebpackConfigEnhancer = piralInstanceWebpackConfigEnhancer;
|
|
17
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/piral-instance-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/piral-instance-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,uCAA6E;AAStE,MAAM,kCAAkC,GAC7C,CAAC,OAA0C,EAAE,EAAE,CAAC,CAAC,eAA8B,EAAE,EAAE;IACjF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;IAC1D,MAAM,SAAS,mCACV,IAAA,sBAAY,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,GACnD,OAAO,CAAC,SAAS,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,IAAI,sBAAY,CAAC,IAAA,4BAAkB,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAElE,IAAA,wBAAc,EAAC,SAAS,CAAC,CAAC;IAE1B,eAAe,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;IAE3E,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAhBS,QAAA,kCAAkC,sCAgB3C"}
|
package/lib/helpers.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Configuration } from 'webpack';
|
|
2
|
-
|
|
2
|
+
import { DefaultConfiguration } from './webpack/common';
|
|
3
|
+
export declare function extendConfig([webPackConfig, enhancer]: DefaultConfiguration, otherConfigPath: string, overrides?: Configuration): Configuration;
|
package/lib/helpers.js
CHANGED
|
@@ -2,20 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extendConfig = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
-
function extendConfig(webPackConfig, otherConfigPath, overrides = {}) {
|
|
6
|
-
|
|
5
|
+
function extendConfig([webPackConfig, enhancer], otherConfigPath, overrides = {}) {
|
|
6
|
+
const original = webPackConfig;
|
|
7
|
+
if ((0, fs_1.existsSync)(otherConfigPath)) {
|
|
7
8
|
const otherConfig = require(otherConfigPath);
|
|
8
9
|
if (typeof otherConfig === 'function') {
|
|
9
10
|
webPackConfig = otherConfig(webPackConfig);
|
|
10
11
|
}
|
|
11
12
|
else if (typeof otherConfig === 'object') {
|
|
12
|
-
|
|
13
|
+
webPackConfig = Object.assign(Object.assign({}, webPackConfig), otherConfig);
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
15
16
|
console.warn(`Did not recognize the export from "${otherConfigPath}". Skipping.`);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
['entry', 'output', 'optimization'].forEach((s) => {
|
|
20
|
+
if (original[s] !== webPackConfig[s]) {
|
|
21
|
+
console.warn(`You've overwritten the "${s}" section of the Webpack config. Make sure you know what you are doing.`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return enhancer(Object.assign(Object.assign({}, webPackConfig), overrides));
|
|
19
25
|
}
|
|
20
26
|
exports.extendConfig = extendConfig;
|
|
21
27
|
//# sourceMappingURL=helpers.js.map
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;AAIhC,SAAgB,YAAY,CAC1B,CAAC,aAAa,EAAE,QAAQ,CAAuB,EAC/C,eAAuB,EACvB,YAA2B,EAAE;IAE7B,MAAM,QAAQ,GAAG,aAAa,CAAC;IAE/B,IAAI,IAAA,eAAU,EAAC,eAAe,CAAC,EAAE;QAC/B,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;QAE7C,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;YACrC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;SAC5C;aAAM,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YAC1C,aAAa,mCACR,aAAa,GACb,WAAW,CACf,CAAC;SACH;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,sCAAsC,eAAe,cAAc,CAAC,CAAC;SACnF;KACF;IAED,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAChD,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,EAAE;YACpC,OAAO,CAAC,IAAI,CACV,2BAA2B,CAAC,yEAAyE,CACtG,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,iCACV,aAAa,GACb,SAAS,EACZ,CAAC;AACL,CAAC;AAlCD,oCAkCC"}
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const actions = require("./actions");
|
|
4
4
|
const plugin = (cli) => {
|
|
5
|
-
cli.withBundler('
|
|
5
|
+
cli.withBundler('webpack5', actions);
|
|
6
6
|
};
|
|
7
7
|
module.exports = plugin;
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AAGrC,MAAM,MAAM,GAAc,CAAC,GAAG,EAAE,EAAE;IAChC,GAAG,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AAGrC,MAAM,MAAM,GAAc,CAAC,GAAG,EAAE,EAAE;IAChC,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function sheetLoader(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const loader_utils_1 = require("loader-utils");
|
|
4
|
+
function sheetLoader() {
|
|
5
|
+
const { cssName, piletName } = (0, loader_utils_1.getOptions)(this);
|
|
6
|
+
const debug = process.env.NODE_ENV === 'development';
|
|
7
|
+
return [
|
|
8
|
+
`var d=document`,
|
|
9
|
+
`var u=__webpack_public_path__+${JSON.stringify(cssName)}`,
|
|
10
|
+
`var e=d.createElement("link")`,
|
|
11
|
+
`e.setAttribute('data-origin', ${JSON.stringify(piletName)})`,
|
|
12
|
+
`e.type="text/css"`,
|
|
13
|
+
`e.rel="stylesheet"`,
|
|
14
|
+
`e.href=${debug ? 'u+"?_="+Math.random()' : 'u'}`,
|
|
15
|
+
`d.head.appendChild(e)`,
|
|
16
|
+
].join(';');
|
|
17
|
+
}
|
|
18
|
+
exports.default = sheetLoader;
|
|
19
|
+
//# sourceMappingURL=SheetLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetLoader.js","sourceRoot":"","sources":["../../src/plugins/SheetLoader.ts"],"names":[],"mappings":";;AAAA,+CAA0C;AAE1C,SAAwB,WAAW;IACjC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IACrD,OAAO;QACL,gBAAgB;QAChB,iCAAiC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC1D,+BAA+B;QAC/B,iCAAiC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG;QAC7D,mBAAmB;QACnB,oBAAoB;QACpB,UAAU,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,EAAE;QACjD,uBAAuB;KACxB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAbD,8BAaC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const webpack_1 = require("webpack");
|
|
5
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
6
|
+
class SheetPlugin {
|
|
7
|
+
constructor(cssName, piletName, entryName) {
|
|
8
|
+
this.cssName = cssName;
|
|
9
|
+
this.entryName = entryName;
|
|
10
|
+
this.loaderPath = (0, path_1.resolve)(__dirname, `SheetLoader?cssName=${cssName}&piletName=${piletName}!`);
|
|
11
|
+
}
|
|
12
|
+
apply(compiler) {
|
|
13
|
+
const { entry } = compiler.options;
|
|
14
|
+
entry[this.entryName].import = [this.loaderPath, ...entry[this.entryName].import];
|
|
15
|
+
compiler.hooks.compilation.tap('SheetPlugin', (compilation) => {
|
|
16
|
+
if (!compilation.compiler.parentCompilation) {
|
|
17
|
+
compilation.hooks.processAssets.tap({
|
|
18
|
+
name: 'SheetPlugin',
|
|
19
|
+
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
20
|
+
}, (assets) => {
|
|
21
|
+
if (!assets[this.cssName]) {
|
|
22
|
+
const source = new webpack_sources_1.RawSource('');
|
|
23
|
+
compilation.emitAsset(this.cssName, source);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = SheetPlugin;
|
|
31
|
+
//# sourceMappingURL=SheetPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetPlugin.js","sourceRoot":"","sources":["../../src/plugins/SheetPlugin.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,qCAAsC;AACtC,qDAA4C;AAE5C,MAAqB,WAAW;IAG9B,YAAoB,OAAe,EAAE,SAAiB,EAAU,SAAiB;QAA7D,YAAO,GAAP,OAAO,CAAQ;QAA6B,cAAS,GAAT,SAAS,CAAQ;QAC/E,IAAI,CAAC,UAAU,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,uBAAuB,OAAO,cAAc,SAAS,GAAG,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;QAEnC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;QAElF,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,WAAwB,EAAE,EAAE;YACzE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,iBAAiB,EAAE;gBAC3C,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CACjC;oBACE,IAAI,EAAE,aAAa;oBACnB,KAAK,EAAE,qBAAW,CAAC,8BAA8B;iBAClD,EACD,CAAC,MAAM,EAAE,EAAE;oBACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;wBACzB,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC,EAAE,CAAC,CAAC;wBACjC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;qBAC7C;gBACH,CAAC,CACF,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7BD,8BA6BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function stylesLoader(): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const loader_utils_1 = require("loader-utils");
|
|
4
|
+
function stylesLoader() {
|
|
5
|
+
const { cssName, entries } = (0, loader_utils_1.getOptions)(this);
|
|
6
|
+
const debug = process.env.NODE_ENV === 'development';
|
|
7
|
+
return [
|
|
8
|
+
`const u = ${JSON.stringify(cssName)}`,
|
|
9
|
+
`export const styles = [${debug ? 'u+"?_="+Math.random()' : 'u'}]`,
|
|
10
|
+
...entries.split(',').map((entry) => `export * from ${JSON.stringify(entry)}`),
|
|
11
|
+
].join(';');
|
|
12
|
+
}
|
|
13
|
+
exports.default = stylesLoader;
|
|
14
|
+
//# sourceMappingURL=StylesLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StylesLoader.js","sourceRoot":"","sources":["../../src/plugins/StylesLoader.ts"],"names":[],"mappings":";;AAAA,+CAA0C;AAE1C,SAAwB,YAAY;IAClC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IACrD,OAAO;QACL,aAAa,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACtC,0BAA0B,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,GAAG;QAClE,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;KAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AARD,+BAQC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const webpack_1 = require("webpack");
|
|
5
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
6
|
+
class StylesPlugin {
|
|
7
|
+
constructor(cssName, entryName) {
|
|
8
|
+
this.cssName = cssName;
|
|
9
|
+
this.entryName = entryName;
|
|
10
|
+
}
|
|
11
|
+
apply(compiler) {
|
|
12
|
+
const { entry } = compiler.options;
|
|
13
|
+
const entries = entry[this.entryName].import;
|
|
14
|
+
const query = `cssName=${this.cssName}&entries=${entries.join(',')}!`;
|
|
15
|
+
const setPath = (0, path_1.resolve)(__dirname, '..', 'set-path');
|
|
16
|
+
const loaderPath = (0, path_1.resolve)(__dirname, `StylesLoader?${query}`);
|
|
17
|
+
entry[this.entryName].import = [setPath, loaderPath];
|
|
18
|
+
compiler.hooks.compilation.tap('StylesPlugin', (compilation) => {
|
|
19
|
+
if (!compilation.compiler.parentCompilation) {
|
|
20
|
+
compilation.hooks.processAssets.tap({
|
|
21
|
+
name: 'StylesPlugin',
|
|
22
|
+
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
23
|
+
}, (assets) => {
|
|
24
|
+
if (!assets[this.cssName]) {
|
|
25
|
+
const source = new webpack_sources_1.RawSource('');
|
|
26
|
+
compilation.emitAsset(this.cssName, source);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = StylesPlugin;
|
|
34
|
+
//# sourceMappingURL=StylesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StylesPlugin.js","sourceRoot":"","sources":["../../src/plugins/StylesPlugin.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,qCAAsC;AACtC,qDAA4C;AAE5C,MAAqB,YAAY;IAC/B,YAAoB,OAAe,EAAU,SAAiB;QAA1C,YAAO,GAAP,OAAO,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAElE,KAAK,CAAC,QAAQ;QACZ,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;QAEnC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;QAC7C,MAAM,KAAK,GAAG,WAAW,IAAI,CAAC,OAAO,YAAY,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACtE,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,gBAAgB,KAAK,EAAE,CAAC,CAAC;QAE/D,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAErD,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,WAAwB,EAAE,EAAE;YAC1E,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,iBAAiB,EAAE;gBAC3C,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CACjC;oBACE,IAAI,EAAE,cAAc;oBACpB,KAAK,EAAE,qBAAW,CAAC,8BAA8B;iBAClD,EACD,CAAC,MAAM,EAAE,EAAE;oBACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;wBACzB,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC,EAAE,CAAC,CAAC;wBACjC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;qBAC7C;gBACH,CAAC,CACF,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,+BA8BC"}
|
|
@@ -1,22 +1,3 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import type { LogLevels } from 'piral-cli';
|
|
3
|
-
|
|
4
|
-
outFile: string;
|
|
5
|
-
outDir: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function runWebpack(wpConfig: webpack.Configuration, logLevel: LogLevels): {
|
|
8
|
-
bundle: () => Promise<BuildResult>;
|
|
9
|
-
on(ev: string, listener: () => void): void;
|
|
10
|
-
off(ev: string, listener: () => void): void;
|
|
11
|
-
options: {
|
|
12
|
-
outDir: string;
|
|
13
|
-
};
|
|
14
|
-
mainBundle: {
|
|
15
|
-
name: string;
|
|
16
|
-
requireRef: any;
|
|
17
|
-
entryAsset: {
|
|
18
|
-
hash: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
2
|
+
import type { LogLevels, BundleHandlerResponse } from 'piral-cli';
|
|
3
|
+
export declare function runWebpack(wpConfig: webpack.Configuration, logLevel: LogLevels): BundleHandlerResponse;
|
|
@@ -6,8 +6,13 @@ const path_1 = require("path");
|
|
|
6
6
|
const events_1 = require("events");
|
|
7
7
|
function getOutput(stats) {
|
|
8
8
|
const { outputPath, entrypoints } = stats.toJson();
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
for (const name of Object.keys(entrypoints)) {
|
|
10
|
+
const assets = entrypoints[name].assets;
|
|
11
|
+
const firstAsset = assets.find((m) => m.name.endsWith('.js') || m.name.endsWith('.mjs'));
|
|
12
|
+
if (firstAsset) {
|
|
13
|
+
return (0, path_1.resolve)(outputPath, firstAsset.name);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
function getPreset(logLevel) {
|
|
13
18
|
switch (logLevel) {
|
|
@@ -28,65 +33,68 @@ function getPreset(logLevel) {
|
|
|
28
33
|
function runWebpack(wpConfig, logLevel) {
|
|
29
34
|
const eventEmitter = new events_1.EventEmitter();
|
|
30
35
|
const outDir = wpConfig.output.path;
|
|
31
|
-
const
|
|
36
|
+
const bundle = {
|
|
37
|
+
outFile: '',
|
|
38
|
+
outDir,
|
|
32
39
|
name: '',
|
|
40
|
+
hash: '',
|
|
33
41
|
requireRef: undefined,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
};
|
|
43
|
+
const updateBundle = (stats) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const file = getOutput(stats);
|
|
46
|
+
bundle.name = (0, path_1.basename)(file);
|
|
47
|
+
bundle.requireRef = (_a = stats.compilation.outputOptions) === null || _a === void 0 ? void 0 : _a.uniqueName;
|
|
48
|
+
bundle.hash = stats.hash;
|
|
49
|
+
bundle.outFile = `/${(0, path_1.basename)(file)}`;
|
|
50
|
+
bundle.outDir = (0, path_1.dirname)(file);
|
|
37
51
|
};
|
|
38
52
|
wpConfig.plugins.push({
|
|
39
53
|
apply(compiler) {
|
|
40
54
|
compiler.hooks.beforeCompile.tap('piral-cli', () => {
|
|
41
|
-
eventEmitter.emit('
|
|
55
|
+
eventEmitter.emit('start');
|
|
42
56
|
});
|
|
43
57
|
compiler.hooks.done.tap('piral-cli', (stats) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
mainBundle.requireRef = (_a = stats.compilation.outputOptions) === null || _a === void 0 ? void 0 : _a.uniqueName;
|
|
47
|
-
mainBundle.entryAsset.hash = stats.hash;
|
|
48
|
-
eventEmitter.emit('bundled');
|
|
58
|
+
updateBundle(stats);
|
|
59
|
+
eventEmitter.emit('end', bundle);
|
|
49
60
|
});
|
|
50
61
|
},
|
|
51
62
|
});
|
|
52
|
-
const bundle = () => new Promise((resolve, reject) => {
|
|
53
|
-
const preset = {
|
|
54
|
-
current: undefined,
|
|
55
|
-
};
|
|
56
|
-
const process = webpack(wpConfig, (err, stats) => {
|
|
57
|
-
if (err) {
|
|
58
|
-
console.error(err);
|
|
59
|
-
reject(err);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.log(stats.toString(Object.assign(Object.assign({}, preset.current), { colors: true })));
|
|
63
|
-
if (stats.hasErrors()) {
|
|
64
|
-
reject(stats.toJson(preset.current));
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const file = getOutput(stats);
|
|
68
|
-
resolve({
|
|
69
|
-
outFile: `/${path_1.basename(file)}`,
|
|
70
|
-
outDir: path_1.dirname(file),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const compilation = process.createCompilation();
|
|
76
|
-
preset.current = compilation.createStatsOptions(getPreset(logLevel));
|
|
77
|
-
});
|
|
78
63
|
return {
|
|
79
|
-
bundle
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
bundle() {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const preset = {
|
|
67
|
+
current: undefined,
|
|
68
|
+
};
|
|
69
|
+
const process = webpack(wpConfig, (err, stats) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
console.error(err);
|
|
72
|
+
reject(err);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.log(stats.toString(Object.assign(Object.assign({}, preset.current), { colors: true })));
|
|
76
|
+
if (stats.hasErrors()) {
|
|
77
|
+
reject(stats.toJson(preset.current));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
updateBundle(stats);
|
|
81
|
+
resolve(bundle);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (process) {
|
|
86
|
+
// process is undefined in case of an error
|
|
87
|
+
const compilation = process.createCompilation();
|
|
88
|
+
preset.current = compilation.createStatsOptions(getPreset(logLevel));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
82
91
|
},
|
|
83
|
-
|
|
84
|
-
eventEmitter.
|
|
92
|
+
onStart(cb) {
|
|
93
|
+
eventEmitter.on('start', cb);
|
|
85
94
|
},
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
onEnd(cb) {
|
|
96
|
+
eventEmitter.on('end', cb);
|
|
88
97
|
},
|
|
89
|
-
mainBundle,
|
|
90
98
|
};
|
|
91
99
|
}
|
|
92
100
|
exports.runWebpack = runWebpack;
|