piral-cli-webpack5 0.13.7 → 0.14.0-alpha.3154
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/README.md +20 -0
- package/extend-config.js +51 -14
- package/lib/actions.js +6 -40
- package/lib/actions.js.map +1 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js +5 -5
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js.map +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.d.ts +6 -0
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js +68 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/index.d.ts +15 -2
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js +86 -59
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js.map +1 -1
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js +3 -3
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js.map +1 -1
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/{configs → plugins}/SheetPlugin.d.ts +3 -1
- package/lib/plugins/SheetPlugin.js +38 -0
- package/lib/plugins/SheetPlugin.js.map +1 -0
- package/lib/webpack/bundler-run.d.ts +2 -21
- package/lib/webpack/bundler-run.js +43 -45
- package/lib/webpack/bundler-run.js.map +1 -1
- package/lib/{configs → webpack}/common.d.ts +0 -0
- package/lib/{configs → webpack}/common.js +6 -7
- package/lib/webpack/common.js.map +1 -0
- package/lib/webpack/pilet.d.ts +19 -0
- package/lib/{configs → webpack}/pilet.js +30 -9
- package/lib/webpack/pilet.js.map +1 -0
- package/lib/webpack/piral.d.ts +16 -0
- package/lib/{configs → webpack}/piral.js +27 -9
- package/lib/webpack/piral.js.map +1 -0
- package/package.json +9 -9
- package/src/actions.ts +6 -21
- package/src/enhancers/pilet-webpack-config-enhancer/helpers.ts +75 -0
- package/src/enhancers/pilet-webpack-config-enhancer/index.ts +140 -68
- package/src/helpers.ts +1 -1
- package/src/index.ts +1 -1
- package/src/plugins/SheetPlugin.ts +37 -0
- package/src/webpack/bundler-run.ts +49 -57
- package/src/{configs → webpack}/common.ts +3 -4
- package/src/{configs → webpack}/pilet.ts +42 -4
- package/src/{configs → webpack}/piral.ts +32 -1
- package/lib/configs/SheetPlugin.js +0 -23
- package/lib/configs/SheetPlugin.js.map +0 -1
- 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.map +0 -1
- package/lib/configs/piral.d.ts +0 -2
- 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/SheetPlugin.ts +0 -21
- package/src/configs/index.ts +0 -2
- package/src/webpack/bundler-calls.ts +0 -107
- package/src/webpack/index.ts +0 -1
- package/src/webpack/run-build-pilet.ts +0 -81
- package/src/webpack/run-build-piral.ts +0 -82
- package/src/webpack/run-debug-mono-piral.ts +0 -65
- package/src/webpack/run-debug-pilet.ts +0 -93
- package/src/webpack/run-debug-piral.ts +0 -84
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const webpack_inject_plugin_1 = require("webpack-inject-plugin");
|
|
4
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
5
|
+
function sheetLoader(cssName, name) {
|
|
6
|
+
return () => {
|
|
7
|
+
const debug = process.env.NODE_ENV === 'development';
|
|
8
|
+
return [
|
|
9
|
+
`var d=document`,
|
|
10
|
+
`var u=__webpack_public_path__+${JSON.stringify(cssName)}`,
|
|
11
|
+
`var e=d.createElement("link")`,
|
|
12
|
+
`e.setAttribute('data-origin', ${JSON.stringify(name)})`,
|
|
13
|
+
`e.type="text/css"`,
|
|
14
|
+
`e.rel="stylesheet"`,
|
|
15
|
+
`e.href=${debug ? 'u+"?_="+Math.random()' : 'u'}`,
|
|
16
|
+
`d.head.appendChild(e)`,
|
|
17
|
+
].join(';');
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
class SheetPlugin extends webpack_inject_plugin_1.default {
|
|
21
|
+
constructor(cssName, name) {
|
|
22
|
+
super(sheetLoader(cssName, name));
|
|
23
|
+
this.cssName = cssName;
|
|
24
|
+
}
|
|
25
|
+
apply(compiler) {
|
|
26
|
+
super.apply(compiler);
|
|
27
|
+
compiler.hooks.compilation.tap('SheetPlugin', (compilation) => {
|
|
28
|
+
compilation.hooks.afterProcessAssets.tap('SheetPlugin', (module) => {
|
|
29
|
+
if (!compilation.assets[this.cssName] && Object.keys(module).length > 0) {
|
|
30
|
+
const source = new webpack_sources_1.RawSource('');
|
|
31
|
+
compilation.emitAsset(this.cssName, source);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = SheetPlugin;
|
|
38
|
+
//# sourceMappingURL=SheetPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetPlugin.js","sourceRoot":"","sources":["../../src/plugins/SheetPlugin.ts"],"names":[],"mappings":";;AAAA,iEAAiD;AACjD,qDAA4C;AAE5C,SAAS,WAAW,CAAC,OAAe,EAAE,IAAY;IAChD,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;QACrD,OAAO;YACL,gBAAgB;YAChB,iCAAiC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;YAC1D,+BAA+B;YAC/B,iCAAiC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;YACxD,mBAAmB;YACnB,oBAAoB;YACpB,UAAU,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,EAAE;YACjD,uBAAuB;SACxB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,MAAqB,WAAY,SAAQ,+BAAY;IACnD,YAAoB,OAAe,EAAE,IAAY;QAC/C,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QADhB,YAAO,GAAP,OAAO,CAAQ;IAEnC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEtB,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,EAAE;YAC5D,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE;gBACjE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;oBACvE,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC,EAAE,CAAC,CAAC;oBACjC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;iBAC7C;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjBD,8BAiBC"}
|
|
@@ -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,10 @@ 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
|
+
return (0, path_1.resolve)(outputPath, assets[0].name);
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
14
|
function getPreset(logLevel) {
|
|
13
15
|
switch (logLevel) {
|
|
@@ -28,65 +30,61 @@ function getPreset(logLevel) {
|
|
|
28
30
|
function runWebpack(wpConfig, logLevel) {
|
|
29
31
|
const eventEmitter = new events_1.EventEmitter();
|
|
30
32
|
const outDir = wpConfig.output.path;
|
|
31
|
-
const
|
|
33
|
+
const bundle = {
|
|
34
|
+
outFile: '',
|
|
35
|
+
outDir,
|
|
32
36
|
name: '',
|
|
37
|
+
hash: '',
|
|
33
38
|
requireRef: undefined,
|
|
34
|
-
entryAsset: {
|
|
35
|
-
hash: '',
|
|
36
|
-
},
|
|
37
39
|
};
|
|
38
40
|
wpConfig.plugins.push({
|
|
39
41
|
apply(compiler) {
|
|
40
42
|
compiler.hooks.beforeCompile.tap('piral-cli', () => {
|
|
41
|
-
eventEmitter.emit('
|
|
43
|
+
eventEmitter.emit('start');
|
|
42
44
|
});
|
|
43
45
|
compiler.hooks.done.tap('piral-cli', (stats) => {
|
|
44
46
|
var _a;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
eventEmitter.emit('
|
|
47
|
+
bundle.name = getOutput(stats);
|
|
48
|
+
bundle.requireRef = (_a = stats.compilation.outputOptions) === null || _a === void 0 ? void 0 : _a.uniqueName;
|
|
49
|
+
bundle.hash = stats.hash;
|
|
50
|
+
eventEmitter.emit('end', bundle);
|
|
49
51
|
});
|
|
50
52
|
},
|
|
51
53
|
});
|
|
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
54
|
return {
|
|
79
|
-
bundle
|
|
80
|
-
|
|
81
|
-
|
|
55
|
+
bundle() {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const preset = {
|
|
58
|
+
current: undefined,
|
|
59
|
+
};
|
|
60
|
+
const process = webpack(wpConfig, (err, stats) => {
|
|
61
|
+
if (err) {
|
|
62
|
+
console.error(err);
|
|
63
|
+
reject(err);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.log(stats.toString(Object.assign(Object.assign({}, preset.current), { colors: true })));
|
|
67
|
+
if (stats.hasErrors()) {
|
|
68
|
+
reject(stats.toJson(preset.current));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const file = getOutput(stats);
|
|
72
|
+
bundle.outFile = `/${(0, path_1.basename)(file)}`;
|
|
73
|
+
bundle.outDir = (0, path_1.dirname)(file);
|
|
74
|
+
resolve(bundle);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const compilation = process.createCompilation();
|
|
79
|
+
preset.current = compilation.createStatsOptions(getPreset(logLevel));
|
|
80
|
+
});
|
|
82
81
|
},
|
|
83
|
-
|
|
84
|
-
eventEmitter.
|
|
82
|
+
onStart(cb) {
|
|
83
|
+
eventEmitter.on('start', cb);
|
|
85
84
|
},
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
onEnd(cb) {
|
|
86
|
+
eventEmitter.on('end', cb);
|
|
88
87
|
},
|
|
89
|
-
mainBundle,
|
|
90
88
|
};
|
|
91
89
|
}
|
|
92
90
|
exports.runWebpack = runWebpack;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler-run.js","sourceRoot":"","sources":["../../src/webpack/bundler-run.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,+BAAkD;AAClD,mCAAsC;
|
|
1
|
+
{"version":3,"file":"bundler-run.js","sourceRoot":"","sources":["../../src/webpack/bundler-run.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,+BAAkD;AAClD,mCAAsC;AAGtC,SAAS,SAAS,CAAC,KAAoB;IACrC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IAEnD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC3C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACxC,OAAO,IAAA,cAAO,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;KAC5C;AACH,CAAC;AAED,SAAS,SAAS,CAAC,QAAmB;IACpC,QAAQ,QAAQ,EAAE;QAChB,KAAK,CAAC,EAAE,oBAAoB;YAC1B,OAAO,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,iBAAiB;YACvB,OAAO,aAAa,CAAC;QACvB,KAAK,CAAC,EAAE,mBAAmB;YACzB,OAAO,iBAAiB,CAAC;QAC3B,KAAK,CAAC,CAAC,CAAC,mBAAmB;QAC3B,KAAK,CAAC,EAAE,iBAAiB;YACvB,OAAO,SAAS,CAAC;QACnB,KAAK,CAAC,CAAC,CAAC,gBAAgB;QACxB;YACE,OAAO,QAAQ,CAAC;KACnB;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,QAA+B,EAAE,QAAmB;IAC7E,MAAM,YAAY,GAAG,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AO,CAAC,GAAG,CACT,KAAK,CAAC,QAAQ,iCACT,MAAM,CAAC,OAAO,KACjB,MAAM,EAAE,IAAI,IACZ,CACH,CAAC;wBAEF,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE;4BACrB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;yBACtC;6BAAM;4BACL,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;4BAC9B,MAAM,CAAC,OAAO,GAAG,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;4BACtC,MAAM,CAAC,MAAM,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;4BAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;yBACjB;qBACF;gBACH,CAAC,CAAC,CAAC;gBAEH,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;gBAChD,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE;YACR,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,CAAC,EAAE;YACN,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC;AAnED,gCAmEC"}
|
|
File without changes
|
|
@@ -4,8 +4,7 @@ exports.getRules = exports.getPlugins = exports.getVariables = exports.extension
|
|
|
4
4
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
5
5
|
const utils_1 = require("piral-cli/utils");
|
|
6
6
|
const webpack_1 = require("webpack");
|
|
7
|
-
const
|
|
8
|
-
const SheetPlugin_1 = require("./SheetPlugin");
|
|
7
|
+
const SheetPlugin_1 = require("../plugins/SheetPlugin");
|
|
9
8
|
const piletCss = 'main.css';
|
|
10
9
|
function getStyleLoaders(production) {
|
|
11
10
|
if (production) {
|
|
@@ -29,21 +28,21 @@ function getPlugins(plugins, showProgress, production, pilet) {
|
|
|
29
28
|
filename: pilet ? piletCss : '[name].[fullhash:6].css',
|
|
30
29
|
chunkFilename: '[id].[chunkhash:6].css',
|
|
31
30
|
}),
|
|
32
|
-
new import_maps_webpack_plugin_1.ImportMapsWebpackPlugin(),
|
|
33
31
|
];
|
|
34
32
|
if (showProgress) {
|
|
35
33
|
otherPlugins.push(new webpack_1.ProgressPlugin((percent, msg) => {
|
|
36
34
|
if (percent !== undefined) {
|
|
37
|
-
utils_1.progress(`${~~(percent * 100)}% : ${msg}`);
|
|
35
|
+
(0, utils_1.progress)(`${~~(percent * 100)}% : ${msg}`);
|
|
38
36
|
if (percent === 1) {
|
|
39
|
-
utils_1.logReset();
|
|
40
|
-
utils_1.log('generalInfo_0000', 'Bundling finished.');
|
|
37
|
+
(0, utils_1.logReset)();
|
|
38
|
+
(0, utils_1.log)('generalInfo_0000', 'Bundling finished.');
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}));
|
|
44
42
|
}
|
|
45
43
|
if (production && pilet) {
|
|
46
|
-
|
|
44
|
+
const name = process.env.BUILD_PCKG_NAME;
|
|
45
|
+
otherPlugins.push(new SheetPlugin_1.default(piletCss, name));
|
|
47
46
|
}
|
|
48
47
|
return plugins.concat(otherPlugins);
|
|
49
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/webpack/common.ts"],"names":[],"mappings":";;;AAAA,gEAAgE;AAChE,2CAA0D;AAC1D,qCAA4F;AAC5F,wDAAiD;AAEjD,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B,SAAS,eAAe,CAAC,UAAmB;IAC1C,IAAI,UAAU,EAAE;QACd,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;KACtC;SAAM;QACL,O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E,CAAC,WAAW,EAAE,QAAQ,CAAC;SAC7B;QACD;YACE,IAAI,EAAE,aAAa;YACnB,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;SAChD;QACD;YACE,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;YAC3C,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,KAAK;SACf;KACF,CAAC;AACJ,CAAC;AAvDD,4BAuDC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PiletSchemaVersion, SharedDependency } from 'piral-cli';
|
|
2
|
+
export declare const create: (config: {
|
|
3
|
+
root: string;
|
|
4
|
+
piral: string;
|
|
5
|
+
entryModule: string;
|
|
6
|
+
targetDir: string;
|
|
7
|
+
outDir: string;
|
|
8
|
+
outFile: string;
|
|
9
|
+
externals: string[];
|
|
10
|
+
importmap: SharedDependency[];
|
|
11
|
+
version: PiletSchemaVersion;
|
|
12
|
+
develop: boolean;
|
|
13
|
+
sourceMaps: boolean;
|
|
14
|
+
contentHash: boolean;
|
|
15
|
+
minify: boolean;
|
|
16
|
+
logLevel: import("piral-cli").LogLevels;
|
|
17
|
+
watch: boolean;
|
|
18
|
+
args: any;
|
|
19
|
+
}) => Promise<import("piral-cli").BundleHandlerResponse>;
|
|
@@ -9,42 +9,51 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.create = void 0;
|
|
13
13
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
14
14
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
15
15
|
const common_1 = require("./common");
|
|
16
16
|
const pilet_webpack_config_enhancer_1 = require("../enhancers/pilet-webpack-config-enhancer");
|
|
17
|
-
|
|
17
|
+
const path_1 = require("path");
|
|
18
|
+
const bundler_run_1 = require("./bundler-run");
|
|
19
|
+
const constants_1 = require("../constants");
|
|
20
|
+
const helpers_1 = require("../helpers");
|
|
21
|
+
function getConfig(template, dist, filename, externals, importmap = [], piral, schema, develop = false, sourceMaps = true, contentHash = true, minimize = true, publicPath = '/', progress = false) {
|
|
18
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
23
|
const production = !develop;
|
|
20
24
|
const name = process.env.BUILD_PCKG_NAME;
|
|
21
25
|
const version = process.env.BUILD_PCKG_VERSION;
|
|
22
|
-
const
|
|
26
|
+
const entry = filename.replace(/\.js$/i, '');
|
|
27
|
+
const enhance = (0, pilet_webpack_config_enhancer_1.piletWebpackConfigEnhancer)({
|
|
23
28
|
name,
|
|
24
29
|
piral,
|
|
25
30
|
version,
|
|
31
|
+
entry,
|
|
26
32
|
externals,
|
|
33
|
+
importmap,
|
|
27
34
|
schema,
|
|
28
|
-
|
|
35
|
+
filename,
|
|
36
|
+
variables: (0, common_1.getVariables)(),
|
|
29
37
|
});
|
|
30
38
|
return [
|
|
31
39
|
{
|
|
32
40
|
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
33
41
|
mode: develop ? 'development' : 'production',
|
|
42
|
+
target: 'web',
|
|
34
43
|
entry: {
|
|
35
|
-
|
|
44
|
+
[entry]: [template],
|
|
36
45
|
},
|
|
37
46
|
output: {
|
|
38
47
|
publicPath,
|
|
39
48
|
path: dist,
|
|
40
|
-
filename,
|
|
49
|
+
filename: '[name].js',
|
|
41
50
|
chunkFilename: contentHash ? '[chunkhash:8].js' : undefined,
|
|
42
51
|
},
|
|
43
52
|
resolve: {
|
|
44
53
|
extensions: common_1.extensions,
|
|
45
54
|
},
|
|
46
55
|
module: {
|
|
47
|
-
rules: common_1.getRules(production),
|
|
56
|
+
rules: (0, common_1.getRules)(production),
|
|
48
57
|
},
|
|
49
58
|
optimization: {
|
|
50
59
|
minimize,
|
|
@@ -64,11 +73,23 @@ function getPiletConfig(template, dist, filename, externals, piral, schema, deve
|
|
|
64
73
|
new OptimizeCSSAssetsPlugin({}),
|
|
65
74
|
],
|
|
66
75
|
},
|
|
67
|
-
plugins: common_1.getPlugins([], progress, production, true),
|
|
76
|
+
plugins: (0, common_1.getPlugins)([], progress, production, true),
|
|
68
77
|
},
|
|
69
78
|
enhance,
|
|
70
79
|
];
|
|
71
80
|
});
|
|
72
81
|
}
|
|
73
|
-
|
|
82
|
+
const handler = {
|
|
83
|
+
create(options) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const otherConfigPath = (0, path_1.resolve)(options.root, constants_1.defaultWebpackConfig);
|
|
86
|
+
const baseConfig = yield getConfig(options.entryModule, options.outDir, options.outFile, options.externals, options.importmap, options.piral, options.version, options.develop, options.sourceMaps, options.contentHash, options.minify);
|
|
87
|
+
const wpConfig = (0, helpers_1.extendConfig)(baseConfig, otherConfigPath, {
|
|
88
|
+
watch: options.watch,
|
|
89
|
+
});
|
|
90
|
+
return (0, bundler_run_1.runWebpack)(wpConfig, options.logLevel);
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
exports.create = handler.create;
|
|
74
95
|
//# sourceMappingURL=pilet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pilet.js","sourceRoot":"","sources":["../../src/webpack/pilet.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,sDAAsD;AACtD,8EAA8E;AAE9E,qCAAgG;AAChG,8FAAwF;AACxF,+BAA+B;AAC/B,+CAA2C;AAC3C,4CAAoD;AACpD,wCAA0C;AAE1C,SAAe,SAAS,CACtB,QAAgB,EAChB,IAAY,EACZ,QAAgB,EAChB,SAAwB,EACxB,YAAqC,EAAE,EACvC,KAAa,EACb,MAA0B,EAC1B,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,IAAI,EACjB,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG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gCACb,GAAG,EAAE,IAAI;gCACT,MAAM,EAAE;oCACN,QAAQ,EAAE,SAAS;iCACpB;gCACD,MAAM,EAAE;oCACN,QAAQ,EAAE,CAAC,eAAe,CAAC;iCAC5B;6BACF;yBACF,CAAC;wBACF,IAAI,uBAAuB,CAAC,EAAE,CAAC;qBAChC;iBACF;gBAED,OAAO,EAAE,IAAA,mBAAU,EAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC;aACpD;YACD,OAAO;SACR,CAAC;IACJ,CAAC;CAAA;AAED,MAAM,OAAO,GAAsB;IAC3B,MAAM,CAAC,OAAO;;YAClB,MAAM,eAAe,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,EAAE,gCAAoB,CAAC,CAAC;YACpE,MAAM,UAAU,GAAG,MAAM,SAAS,CAChC,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,MAAM,CACf,CAAC;YACF,MAAM,QAAQ,GAAG,IAAA,sBAAY,EAAC,UAAU,EAAE,eAAe,EAAE;gBACzD,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAC;YAEH,OAAO,IAAA,wBAAU,EAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChD,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const create: (config: {
|
|
2
|
+
root: string;
|
|
3
|
+
entryFiles: string;
|
|
4
|
+
outDir: string;
|
|
5
|
+
outFile: string;
|
|
6
|
+
externals: string[];
|
|
7
|
+
emulator: boolean;
|
|
8
|
+
sourceMaps: boolean;
|
|
9
|
+
contentHash: boolean;
|
|
10
|
+
minify: boolean;
|
|
11
|
+
publicUrl: string;
|
|
12
|
+
hmr: boolean;
|
|
13
|
+
logLevel: import("piral-cli").LogLevels;
|
|
14
|
+
watch: boolean;
|
|
15
|
+
args: any;
|
|
16
|
+
}) => Promise<import("piral-cli").BundleHandlerResponse>;
|
|
@@ -9,26 +9,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.create = void 0;
|
|
13
13
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
14
14
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
15
|
+
const utils_1 = require("piral-cli/utils");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const bundler_run_1 = require("./bundler-run");
|
|
15
18
|
const common_1 = require("./common");
|
|
16
19
|
const html5_entry_webpack_config_enhancer_1 = require("../enhancers/html5-entry-webpack-config-enhancer");
|
|
17
20
|
const piral_instance_webpack_config_enhancer_1 = require("../enhancers/piral-instance-webpack-config-enhancer");
|
|
18
21
|
const hmr_webpack_config_enhancer_1 = require("../enhancers/hmr-webpack-config-enhancer");
|
|
19
|
-
|
|
22
|
+
const constants_1 = require("../constants");
|
|
23
|
+
const helpers_1 = require("../helpers");
|
|
24
|
+
function getConfig(template, dist, externals, develop = false, sourceMaps = true, contentHash = true, minimize = true, publicPath = '/', hmr = 0, progress = false) {
|
|
20
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
26
|
const production = !develop;
|
|
22
27
|
const name = process.env.BUILD_PCKG_NAME;
|
|
23
28
|
const version = process.env.BUILD_PCKG_VERSION;
|
|
24
29
|
const enhance = (options) => [
|
|
25
|
-
hmr_webpack_config_enhancer_1.hmrWebpackConfigEnhancer({ port: hmr }),
|
|
26
|
-
html5_entry_webpack_config_enhancer_1.html5EntryWebpackConfigEnhancer({}),
|
|
27
|
-
piral_instance_webpack_config_enhancer_1.piralInstanceWebpackConfigEnhancer({
|
|
30
|
+
(0, hmr_webpack_config_enhancer_1.hmrWebpackConfigEnhancer)({ port: hmr }),
|
|
31
|
+
(0, html5_entry_webpack_config_enhancer_1.html5EntryWebpackConfigEnhancer)({}),
|
|
32
|
+
(0, piral_instance_webpack_config_enhancer_1.piralInstanceWebpackConfigEnhancer)({
|
|
28
33
|
name,
|
|
29
34
|
version,
|
|
30
35
|
externals,
|
|
31
|
-
variables: common_1.getVariables(),
|
|
36
|
+
variables: (0, common_1.getVariables)(),
|
|
32
37
|
}),
|
|
33
38
|
].reduceRight((acc, val) => val(acc), options);
|
|
34
39
|
return [
|
|
@@ -46,7 +51,7 @@ function getPiralConfig(template, dist, externals, develop = false, sourceMaps =
|
|
|
46
51
|
extensions: common_1.extensions,
|
|
47
52
|
},
|
|
48
53
|
module: {
|
|
49
|
-
rules: common_1.getRules(production),
|
|
54
|
+
rules: (0, common_1.getRules)(production),
|
|
50
55
|
},
|
|
51
56
|
optimization: {
|
|
52
57
|
minimize,
|
|
@@ -60,11 +65,24 @@ function getPiralConfig(template, dist, externals, develop = false, sourceMaps =
|
|
|
60
65
|
new OptimizeCSSAssetsPlugin({}),
|
|
61
66
|
],
|
|
62
67
|
},
|
|
63
|
-
plugins: common_1.getPlugins([], progress, production, false),
|
|
68
|
+
plugins: (0, common_1.getPlugins)([], progress, production, false),
|
|
64
69
|
},
|
|
65
70
|
enhance,
|
|
66
71
|
];
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
const handler = {
|
|
75
|
+
create(options) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const otherConfigPath = (0, path_1.resolve)(options.root, constants_1.defaultWebpackConfig);
|
|
78
|
+
const hmrPort = options.hmr ? yield (0, utils_1.getFreePort)(62123) : 0;
|
|
79
|
+
const baseConfig = yield getConfig(options.entryFiles, options.outDir, options.externals, options.emulator, options.sourceMaps, options.contentHash, options.minify, options.publicUrl, hmrPort);
|
|
80
|
+
const wpConfig = (0, helpers_1.extendConfig)(baseConfig, otherConfigPath, {
|
|
81
|
+
watch: options.watch,
|
|
82
|
+
});
|
|
83
|
+
return (0, bundler_run_1.runWebpack)(wpConfig, options.logLevel);
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
exports.create = handler.create;
|
|
70
88
|
//# sourceMappingURL=piral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"piral.js","sourceRoot":"","sources":["../../src/webpack/piral.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sDAAsD;AACtD,8EAA8E;AAC9E,2CAA8C;AAC9C,+BAA+B;AAC/B,+CAA2C;AAC3C,qCAAgG;AAChG,0GAAmG;AACnG,gHAAyG;AACzG,0FAAoF;AACpF,4CAAoD;AACpD,wCAA0C;AAE1C,SAAe,SAAS,CACtB,QAAgB,EAChB,IAAY,EACZ,SAAwB,EACxB,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,IAAI,EACjB,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,IAAI,EACf,UAAU,GAAG,GAAG,EAChB,GAAG,GAAG,CAAC,EACP,QAAQ,GAAG,KAAK;;QAEhB,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAE/C,MAAM,OAAO,GAAG,CAAC,OAA8B,EAAE,EAAE,CACjD;YACE,IAAA,sDAAwB,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;YACvC,IAAA,qEAA+B,EAAC,EAAE,CAAC;YACnC,IAAA,2EAAkC,EAAC;gBACjC,IAAI;gBACJ,OAAO;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C,OAAO,CAAC,IAAI,EAAE,gCAAoB,CAAC,CAAC;YACpE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,UAAU,GAAG,MAAM,SAAS,CAChC,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,OAAO,CACR,CAAC;YACF,MAAM,QAAQ,GAAG,IAAA,sBAAY,EAAC,UAAU,EAAE,eAAe,EAAE;gBACzD,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAC;YAEH,OAAO,IAAA,wBAAU,EAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChD,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli-webpack5",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-alpha.3154",
|
|
4
4
|
"description": "Provides debug and build capabilities for pilets and Piral instances using Webpack v5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral-cli",
|
|
@@ -48,35 +48,35 @@
|
|
|
48
48
|
"@types/node": "^13.9.0",
|
|
49
49
|
"@types/terser-webpack-plugin": "^5.0.0",
|
|
50
50
|
"@types/yargs": "^15.0.4",
|
|
51
|
-
"piral-cli": "^0.
|
|
51
|
+
"piral-cli": "^0.14.0-alpha.3154",
|
|
52
52
|
"strip-ansi": "^3.0.0",
|
|
53
53
|
"typescript": "^4.0.2"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@babel/core": "^7.
|
|
57
|
-
"@babel/preset-env": "^7.
|
|
58
|
-
"@babel/preset-react": "^7.
|
|
56
|
+
"@babel/core": "^7.15.8",
|
|
57
|
+
"@babel/preset-env": "^7.15.8",
|
|
58
|
+
"@babel/preset-react": "^7.14.5",
|
|
59
59
|
"ansi-html": "0.0.7",
|
|
60
60
|
"babel-loader": "^8.1.0",
|
|
61
|
-
"cheerio": "^1.0.0-rc.
|
|
61
|
+
"cheerio": "^1.0.0-rc.10",
|
|
62
62
|
"css-loader": "^5.0.0",
|
|
63
63
|
"express": "^4.17.1",
|
|
64
64
|
"file-loader": "^6.1.1",
|
|
65
65
|
"html-entities": "^1.2.0",
|
|
66
66
|
"html-webpack-plugin": "^5.2.0",
|
|
67
|
-
"import-maps-webpack-plugin": "^0.6.6",
|
|
68
67
|
"mini-css-extract-plugin": "^1.1.1",
|
|
69
68
|
"optimize-css-assets-webpack-plugin": "^6.0.1",
|
|
70
|
-
"parcel-codegen-loader": "^0.
|
|
69
|
+
"parcel-codegen-loader": "^0.8.0",
|
|
71
70
|
"querystring": "^0.2.0",
|
|
72
71
|
"sass": "^1.32.12",
|
|
73
72
|
"sass-loader": "^10.0.3",
|
|
74
73
|
"source-map-loader": "^1.1.1",
|
|
75
74
|
"style-loader": "^2.0.0",
|
|
75
|
+
"systemjs-webpack-interop": "^2.3.7",
|
|
76
76
|
"terser-webpack-plugin": "^5.0.0",
|
|
77
77
|
"ts-loader": "^8.0.6",
|
|
78
78
|
"webpack": "^5.1.3",
|
|
79
79
|
"webpack-inject-plugin": "^1.5.5"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "bc6cc60a59e6a8b1a154d187883cb794e8609939"
|
|
82
82
|
}
|
package/src/actions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolve } from 'path';
|
|
2
2
|
import {
|
|
3
3
|
DebugPiletBundlerDefinition,
|
|
4
4
|
DebugPiralBundlerDefinition,
|
|
@@ -8,36 +8,21 @@ import {
|
|
|
8
8
|
} from 'piral-cli';
|
|
9
9
|
|
|
10
10
|
export const debugPiral: DebugPiralBundlerDefinition = {
|
|
11
|
-
|
|
12
|
-
const bundler = await callDynamic('debug-piral', args);
|
|
13
|
-
return bundler;
|
|
14
|
-
},
|
|
11
|
+
path: resolve(__dirname, 'webpack', 'piral.js'),
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
export const watchPiral: WatchPiralBundlerDefinition = {
|
|
18
|
-
|
|
19
|
-
const bundler = await callStatic('debug-mono-piral', args);
|
|
20
|
-
return bundler;
|
|
21
|
-
},
|
|
15
|
+
path: resolve(__dirname, 'webpack', 'piral.js'),
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
export const buildPiral: BuildPiralBundlerDefinition = {
|
|
25
|
-
|
|
26
|
-
const bundler = await callStatic('build-piral', args);
|
|
27
|
-
return bundler.bundle;
|
|
28
|
-
},
|
|
19
|
+
path: resolve(__dirname, 'webpack', 'piral.js'),
|
|
29
20
|
};
|
|
30
21
|
|
|
31
22
|
export const debugPilet: DebugPiletBundlerDefinition = {
|
|
32
|
-
|
|
33
|
-
const bundler = await callDynamic('debug-pilet', args);
|
|
34
|
-
return bundler;
|
|
35
|
-
},
|
|
23
|
+
path: resolve(__dirname, 'webpack', 'pilet.js'),
|
|
36
24
|
};
|
|
37
25
|
|
|
38
26
|
export const buildPilet: BuildPiletBundlerDefinition = {
|
|
39
|
-
|
|
40
|
-
const bundler = await callStatic('build-pilet', args);
|
|
41
|
-
return bundler.bundle;
|
|
42
|
-
},
|
|
27
|
+
path: resolve(__dirname, 'webpack', 'pilet.js'),
|
|
43
28
|
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { SharedDependency } from 'piral-cli';
|
|
3
|
+
import { Configuration } from 'webpack';
|
|
4
|
+
|
|
1
5
|
export function getVariables(name: string, version: string, env: string): Record<string, string> {
|
|
2
6
|
return {
|
|
3
7
|
NODE_ENV: env,
|
|
@@ -18,3 +22,74 @@ export function getDefineVariables(variables: Record<string, string>) {
|
|
|
18
22
|
return obj;
|
|
19
23
|
}, {});
|
|
20
24
|
}
|
|
25
|
+
|
|
26
|
+
export function getExternals(piral: string) {
|
|
27
|
+
const shellPkg = require(`${piral}/package.json`);
|
|
28
|
+
const piralExternals = shellPkg.pilets?.externals ?? [];
|
|
29
|
+
return [
|
|
30
|
+
...piralExternals,
|
|
31
|
+
'@dbeining/react-atom',
|
|
32
|
+
'@libre/atom',
|
|
33
|
+
'history',
|
|
34
|
+
'react',
|
|
35
|
+
'react-dom',
|
|
36
|
+
'react-router',
|
|
37
|
+
'react-router-dom',
|
|
38
|
+
'tslib',
|
|
39
|
+
'path-to-regexp',
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getDependencies(importmap: Array<SharedDependency>, compilerOptions: Configuration) {
|
|
44
|
+
const dependencies = {};
|
|
45
|
+
|
|
46
|
+
if (typeof compilerOptions.entry === 'object' && compilerOptions.entry) {
|
|
47
|
+
for (const dep of importmap) {
|
|
48
|
+
dependencies[dep.id] = dep.ref;
|
|
49
|
+
compilerOptions.externals[dep.name] = dep.id;
|
|
50
|
+
|
|
51
|
+
if (dep.type === 'local') {
|
|
52
|
+
compilerOptions.entry[dep.ref.replace(/\.js$/, '')] = dep.entry;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return dependencies;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function withSetPath(compilerOptions: Configuration) {
|
|
61
|
+
if (typeof compilerOptions.entry === 'object' && compilerOptions.entry) {
|
|
62
|
+
const setPath = join(__dirname, '..', '..', 'set-path');
|
|
63
|
+
|
|
64
|
+
if (Array.isArray(compilerOptions.entry)) {
|
|
65
|
+
compilerOptions.entry.unshift(setPath);
|
|
66
|
+
} else {
|
|
67
|
+
for (const key of Object.keys(compilerOptions.entry)) {
|
|
68
|
+
const entry = compilerOptions.entry[key];
|
|
69
|
+
|
|
70
|
+
if (Array.isArray(entry)) {
|
|
71
|
+
entry.unshift(setPath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function withExternals(compilerOptions: Configuration, externals: Array<string>) {
|
|
79
|
+
const current = compilerOptions.externals;
|
|
80
|
+
const newExternals = Array.isArray(current)
|
|
81
|
+
? [...(current as Array<string>), ...externals]
|
|
82
|
+
: typeof current === 'string'
|
|
83
|
+
? [current, ...externals]
|
|
84
|
+
: externals;
|
|
85
|
+
|
|
86
|
+
if (newExternals !== externals || typeof compilerOptions.externals !== 'object' || !compilerOptions.externals) {
|
|
87
|
+
compilerOptions.externals = {};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for (const external of newExternals) {
|
|
91
|
+
if (typeof external === 'string') {
|
|
92
|
+
compilerOptions.externals[external] = external;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|