piral-cli-webpack5 1.0.0-pre.1960 → 1.0.1-beta.5640

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.
Files changed (133) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +31 -10
  3. package/extend-config.js +125 -18
  4. package/lib/actions.d.ts +2 -2
  5. package/lib/actions.js +33 -39
  6. package/lib/actions.js.map +1 -1
  7. package/lib/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.js +1 -1
  8. package/lib/enhancers/hmr-webpack-config-enhancer/HotModuleServerPlugin.js.map +1 -0
  9. package/lib/enhancers/hmr-webpack-config-enhancer/index.d.ts +5 -0
  10. package/lib/enhancers/hmr-webpack-config-enhancer/index.js +30 -0
  11. package/lib/enhancers/hmr-webpack-config-enhancer/index.js.map +1 -0
  12. package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.d.ts +2 -2
  13. package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.js +1 -1
  14. package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.js.map +1 -1
  15. package/lib/enhancers/html5-entry-webpack-config-enhancer/index.d.ts +2 -1
  16. package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js +17 -6
  17. package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js.map +1 -1
  18. package/lib/enhancers/pilet-webpack-config-enhancer/helpers.d.ts +5 -0
  19. package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js +53 -1
  20. package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js.map +1 -1
  21. package/lib/enhancers/pilet-webpack-config-enhancer/index.d.ts +18 -4
  22. package/lib/enhancers/pilet-webpack-config-enhancer/index.js +117 -49
  23. package/lib/enhancers/pilet-webpack-config-enhancer/index.js.map +1 -1
  24. package/lib/enhancers/piral-instance-webpack-config-enhancer/helpers.js +2 -0
  25. package/lib/enhancers/piral-instance-webpack-config-enhancer/helpers.js.map +1 -1
  26. package/lib/enhancers/piral-instance-webpack-config-enhancer/index.d.ts +2 -3
  27. package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js +6 -7
  28. package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js.map +1 -1
  29. package/lib/helpers.d.ts +2 -1
  30. package/lib/helpers.js +10 -4
  31. package/lib/helpers.js.map +1 -1
  32. package/lib/index.js +1 -1
  33. package/lib/index.js.map +1 -1
  34. package/lib/plugins/SheetLoader.d.ts +1 -0
  35. package/lib/plugins/SheetLoader.js +19 -0
  36. package/lib/plugins/SheetLoader.js.map +1 -0
  37. package/lib/plugins/SheetPlugin.d.ts +7 -0
  38. package/lib/plugins/SheetPlugin.js +31 -0
  39. package/lib/plugins/SheetPlugin.js.map +1 -0
  40. package/lib/plugins/StylesLoader.d.ts +1 -0
  41. package/lib/plugins/StylesLoader.js +14 -0
  42. package/lib/plugins/StylesLoader.js.map +1 -0
  43. package/lib/plugins/StylesPlugin.d.ts +6 -0
  44. package/lib/plugins/StylesPlugin.js +34 -0
  45. package/lib/plugins/StylesPlugin.js.map +1 -0
  46. package/lib/webpack/bundler-run.d.ts +2 -21
  47. package/lib/webpack/bundler-run.js +54 -46
  48. package/lib/webpack/bundler-run.js.map +1 -1
  49. package/lib/webpack/common.d.ts +8 -0
  50. package/lib/webpack/common.js +104 -0
  51. package/lib/webpack/common.js.map +1 -0
  52. package/lib/webpack/pilet.d.ts +19 -0
  53. package/lib/webpack/pilet.js +97 -0
  54. package/lib/webpack/pilet.js.map +1 -0
  55. package/lib/webpack/piral.d.ts +16 -0
  56. package/lib/webpack/piral.js +90 -0
  57. package/lib/webpack/piral.js.map +1 -0
  58. package/package.json +28 -29
  59. package/src/actions.ts +33 -20
  60. package/src/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.ts +1 -1
  61. package/src/enhancers/hmr-webpack-config-enhancer/index.ts +34 -0
  62. package/src/enhancers/html5-entry-webpack-config-enhancer/helpers.ts +7 -7
  63. package/src/enhancers/html5-entry-webpack-config-enhancer/index.ts +31 -19
  64. package/src/enhancers/pilet-webpack-config-enhancer/helpers.ts +62 -0
  65. package/src/enhancers/pilet-webpack-config-enhancer/index.ts +187 -59
  66. package/src/enhancers/piral-instance-webpack-config-enhancer/helpers.ts +2 -0
  67. package/src/enhancers/piral-instance-webpack-config-enhancer/index.ts +14 -18
  68. package/src/helpers.ts +15 -5
  69. package/src/index.ts +1 -1
  70. package/src/plugins/SheetLoader.ts +16 -0
  71. package/src/plugins/SheetPlugin.ts +34 -0
  72. package/src/plugins/StylesLoader.ts +11 -0
  73. package/src/plugins/StylesPlugin.ts +35 -0
  74. package/src/webpack/bundler-run.ts +60 -56
  75. package/src/webpack/common.ts +111 -0
  76. package/src/webpack/pilet.ts +121 -0
  77. package/src/webpack/piral.ts +110 -0
  78. package/src/webpack-hot-middleware/LICENSE +20 -0
  79. package/src/webpack-hot-middleware/client-overlay.js +99 -0
  80. package/src/webpack-hot-middleware/client.js +306 -0
  81. package/src/webpack-hot-middleware/helpers.js +9 -0
  82. package/src/webpack-hot-middleware/middleware.js +175 -0
  83. package/src/webpack-hot-middleware/process-update.js +157 -0
  84. package/lib/configs/HotModuleServerPlugin.js.map +0 -1
  85. package/lib/configs/SheetLoader.d.ts +0 -1
  86. package/lib/configs/SheetLoader.js +0 -27
  87. package/lib/configs/SheetLoader.js.map +0 -1
  88. package/lib/configs/common.d.ts +0 -6
  89. package/lib/configs/common.js +0 -115
  90. package/lib/configs/common.js.map +0 -1
  91. package/lib/configs/index.d.ts +0 -2
  92. package/lib/configs/index.js +0 -15
  93. package/lib/configs/index.js.map +0 -1
  94. package/lib/configs/pilet.d.ts +0 -3
  95. package/lib/configs/pilet.js +0 -72
  96. package/lib/configs/pilet.js.map +0 -1
  97. package/lib/configs/piral.d.ts +0 -2
  98. package/lib/configs/piral.js +0 -65
  99. package/lib/configs/piral.js.map +0 -1
  100. package/lib/webpack/bundler-calls.d.ts +0 -3
  101. package/lib/webpack/bundler-calls.js +0 -93
  102. package/lib/webpack/bundler-calls.js.map +0 -1
  103. package/lib/webpack/index.d.ts +0 -1
  104. package/lib/webpack/index.js +0 -14
  105. package/lib/webpack/index.js.map +0 -1
  106. package/lib/webpack/run-build-pilet.d.ts +0 -1
  107. package/lib/webpack/run-build-pilet.js +0 -53
  108. package/lib/webpack/run-build-pilet.js.map +0 -1
  109. package/lib/webpack/run-build-piral.d.ts +0 -1
  110. package/lib/webpack/run-build-piral.js +0 -56
  111. package/lib/webpack/run-build-piral.js.map +0 -1
  112. package/lib/webpack/run-debug-mono-piral.d.ts +0 -1
  113. package/lib/webpack/run-debug-mono-piral.js +0 -61
  114. package/lib/webpack/run-debug-mono-piral.js.map +0 -1
  115. package/lib/webpack/run-debug-pilet.d.ts +0 -1
  116. package/lib/webpack/run-debug-pilet.js +0 -77
  117. package/lib/webpack/run-debug-pilet.js.map +0 -1
  118. package/lib/webpack/run-debug-piral.d.ts +0 -1
  119. package/lib/webpack/run-debug-piral.js +0 -76
  120. package/lib/webpack/run-debug-piral.js.map +0 -1
  121. package/src/configs/SheetLoader.ts +0 -12
  122. package/src/configs/common.ts +0 -118
  123. package/src/configs/index.ts +0 -2
  124. package/src/configs/pilet.ts +0 -82
  125. package/src/configs/piral.ts +0 -73
  126. package/src/webpack/bundler-calls.ts +0 -107
  127. package/src/webpack/index.ts +0 -1
  128. package/src/webpack/run-build-pilet.ts +0 -82
  129. package/src/webpack/run-build-piral.ts +0 -83
  130. package/src/webpack/run-debug-mono-piral.ts +0 -76
  131. package/src/webpack/run-debug-pilet.ts +0 -94
  132. package/src/webpack/run-debug-piral.ts +0 -95
  133. /package/lib/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.d.ts +0 -0
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const utils_1 = require("piral-cli/utils");
13
- const path_1 = require("path");
14
- const bundler_run_1 = require("./bundler-run");
15
- const configs_1 = require("../configs");
16
- const helpers_1 = require("../helpers");
17
- const constants_1 = require("../constants");
18
- function run(root, piral, externals, entryModule, version, logLevel) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- utils_1.setStandardEnvs({
21
- piral,
22
- root,
23
- });
24
- const otherConfigPath = path_1.resolve(root, constants_1.defaultWebpackConfig);
25
- const dist = path_1.resolve(root, 'dist');
26
- const baseConfig = yield configs_1.getPiletConfig(root, entryModule, dist, 'index.js', externals, piral, version, true, true, true, false);
27
- const wpConfig = helpers_1.extendConfig(baseConfig, otherConfigPath, {
28
- watch: true,
29
- });
30
- return bundler_run_1.runWebpack(wpConfig, logLevel);
31
- });
32
- }
33
- let bundler;
34
- process.on('message', (msg) => __awaiter(void 0, void 0, void 0, function* () {
35
- const root = process.cwd();
36
- switch (msg.type) {
37
- case 'bundle':
38
- if (bundler) {
39
- yield bundler.bundle();
40
- bundler.on('buildStart', () => {
41
- process.send({
42
- type: 'pending',
43
- });
44
- });
45
- }
46
- break;
47
- case 'start':
48
- bundler = yield run(root, msg.piral, msg.externals, msg.entryModule, msg.version, msg.logLevel).catch((error) => {
49
- process.send({
50
- type: 'fail',
51
- error: error === null || error === void 0 ? void 0 : error.message,
52
- });
53
- });
54
- if (bundler) {
55
- bundler.on('bundled', () => __awaiter(void 0, void 0, void 0, function* () {
56
- if (msg.hmr) {
57
- process.send({
58
- type: 'update',
59
- outHash: bundler.mainBundle.entryAsset.hash,
60
- outName: bundler.mainBundle.name.substr(bundler.options.outDir.length),
61
- args: {
62
- requireRef: bundler.mainBundle.requireRef,
63
- version: msg.version,
64
- root,
65
- },
66
- });
67
- }
68
- }));
69
- process.send({
70
- type: 'done',
71
- outDir: bundler.options.outDir,
72
- });
73
- }
74
- break;
75
- }
76
- }));
77
- //# sourceMappingURL=run-debug-pilet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-debug-pilet.js","sourceRoot":"","sources":["../../src/webpack/run-debug-pilet.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,2CAAkD;AAClD,+BAA+B;AAC/B,+CAA2C;AAC3C,wCAA4C;AAC5C,wCAA0C;AAC1C,4CAAoD;AAEpD,SAAe,GAAG,CAChB,IAAY,EACZ,KAAa,EACb,SAAwB,EACxB,WAAmB,EACnB,OAA2B,EAC3B,QAAmB;;QAEnB,uBAAe,CAAC;YACd,KAAK;YACL,IAAI;SACL,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,cAAO,CAAC,IAAI,EAAE,gCAAoB,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,cAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,MAAM,UAAU,GAAG,MAAM,wBAAc,CACrC,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,UAAU,EACV,SAAS,EACT,KAAK,EACL,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,CACN,CAAC;QACF,MAAM,QAAQ,GAAG,sBAAY,CAAC,UAAU,EAAE,eAAe,EAAE;YACzD,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,OAAO,wBAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;CAAA;AAED,IAAI,OAAO,CAAC;AAEZ,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAO,GAAG,EAAE,EAAE;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE3B,QAAQ,GAAG,CAAC,IAAI,EAAE;QAChB,KAAK,QAAQ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,OAAO,CAAC,OAAO,CAAC,MAAM;iBAC/B,CAAC,CAAC;aACJ;YAED,MAAM;KACT;AACH,CAAC,CAAA,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const utils_1 = require("piral-cli/utils");
13
- const path_1 = require("path");
14
- const bundler_run_1 = require("./bundler-run");
15
- const configs_1 = require("../configs");
16
- const helpers_1 = require("../helpers");
17
- const constants_1 = require("../constants");
18
- function run(root, piral, hmr, externals, publicUrl, entryFiles, logLevel) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- utils_1.setStandardEnvs({
21
- root,
22
- debugPiral: true,
23
- dependencies: externals,
24
- piral,
25
- });
26
- const otherConfigPath = path_1.resolve(root, constants_1.defaultWebpackConfig);
27
- const dist = path_1.resolve(root, 'dist');
28
- const hmrPort = hmr ? yield utils_1.getFreePort(62123) : 0;
29
- const baseConfig = yield configs_1.getPiralConfig(root, entryFiles, dist, externals, true, true, false, false, publicUrl, hmrPort);
30
- const wpConfig = helpers_1.extendConfig(baseConfig, otherConfigPath, {
31
- watch: true,
32
- });
33
- return bundler_run_1.runWebpack(wpConfig, logLevel);
34
- });
35
- }
36
- let bundler;
37
- process.on('message', (msg) => __awaiter(void 0, void 0, void 0, function* () {
38
- const root = process.cwd();
39
- switch (msg.type) {
40
- case 'bundle':
41
- if (bundler) {
42
- yield bundler.bundle();
43
- bundler.on('buildStart', () => {
44
- process.send({
45
- type: 'pending',
46
- });
47
- });
48
- }
49
- break;
50
- case 'start':
51
- bundler = yield run(root, msg.piral, msg.hmr, msg.externals, msg.publicUrl, msg.entryFiles, msg.logLevel).catch((error) => {
52
- process.send({
53
- type: 'fail',
54
- error: error === null || error === void 0 ? void 0 : error.message,
55
- });
56
- });
57
- if (bundler) {
58
- bundler.on('bundled', () => {
59
- process.send({
60
- type: 'update',
61
- outHash: bundler.mainBundle.entryAsset.hash,
62
- outName: 'index.html',
63
- args: {
64
- root,
65
- },
66
- });
67
- });
68
- process.send({
69
- type: 'done',
70
- outDir: bundler.options.outDir,
71
- });
72
- }
73
- break;
74
- }
75
- }));
76
- //# sourceMappingURL=run-debug-piral.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-debug-piral.js","sourceRoot":"","sources":["../../src/webpack/run-debug-piral.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,2CAA+D;AAC/D,+BAA+B;AAC/B,+CAA2C;AAC3C,wCAA4C;AAC5C,wCAA0C;AAC1C,4CAAoD;AAEpD,SAAe,GAAG,CAChB,IAAY,EACZ,KAAa,EACb,GAAY,EACZ,SAAwB,EACxB,SAAiB,EACjB,UAAkB,EAClB,QAAmB;;QAEnB,uBAAe,CAAC;YACd,IAAI;YACJ,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,SAAS;YACvB,KAAK;SACN,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,cAAO,CAAC,IAAI,EAAE,gCAAoB,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,cAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,mBAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,MAAM,wBAAc,CACrC,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,SAAS,EACT,IAAI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;wBACd,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI;wBAC3C,OAAO,EAAE,YAAY;wBACrB,IAAI,EAAE;4BACJ,IAAI;yBACL;qBACF,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,MAAM;oBACZ,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;iBAC/B,CAAC,CAAC;aACJ;YAED,MAAM;KACT;AACH,CAAC,CAAA,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- export default async function SheetLoader() {
2
- const callback = this.async();
3
- const stylesheet = [
4
- `var d=document`,
5
- `var e=d.createElement("link")`,
6
- `e.type="text/css"`,
7
- `e.rel="stylesheet"`,
8
- `e.href=__webpack_public_path__ + ${JSON.stringify('main.css')}`,
9
- `d.head.appendChild(e)`,
10
- ].join(';');
11
- callback(undefined, stylesheet);
12
- }
@@ -1,118 +0,0 @@
1
- import * as MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
- import { resolve } from 'path';
3
- import { progress, logReset, log } from 'piral-cli/utils';
4
- import { RuleSetRule, ProgressPlugin, HotModuleReplacementPlugin, optimize, WebpackPluginInstance } from 'webpack';
5
- import { ImportMapsWebpackPlugin } from 'import-maps-webpack-plugin';
6
- import { HotModuleServerPlugin } from './HotModuleServerPlugin';
7
-
8
- function getStyleLoaders(production: boolean, pilet: boolean) {
9
- if (production && pilet) {
10
- return [require.resolve('./SheetLoader'), MiniCssExtractPlugin.loader];
11
- } else if (production) {
12
- return [MiniCssExtractPlugin.loader];
13
- } else {
14
- return ['style-loader'];
15
- }
16
- }
17
-
18
- export const extensions = ['.ts', '.tsx', '.js', '.json'];
19
-
20
- export function getVariables(): Record<string, string> {
21
- return Object.keys(process.env).reduce((prev, curr) => {
22
- prev[curr] = process.env[curr];
23
- return prev;
24
- }, {});
25
- }
26
-
27
- export function getHmrEntry(hmrPort: number): [] | [string] {
28
- return hmrPort ? [`webpack-hot-middleware/client?path=http://localhost:${hmrPort}/__webpack_hmr&reload=true`] : [];
29
- }
30
-
31
- export function getPlugins(plugins: Array<any>, showProgress: boolean, production: boolean, hmrPort?: number) {
32
- const otherPlugins: Array<WebpackPluginInstance> = [
33
- new MiniCssExtractPlugin({
34
- filename: '[name].css',
35
- chunkFilename: '[id].css',
36
- }) as any,
37
- new ImportMapsWebpackPlugin(),
38
- ];
39
-
40
- if (showProgress) {
41
- otherPlugins.push(
42
- new ProgressPlugin((percent, msg) => {
43
- if (percent !== undefined) {
44
- progress(`${~~(percent * 100)}% : ${msg}`);
45
-
46
- if (percent === 1) {
47
- logReset();
48
- log('generalInfo_0000', 'Bundling finished.');
49
- }
50
- }
51
- }),
52
- );
53
- }
54
-
55
- if (hmrPort) {
56
- otherPlugins.push(new HotModuleReplacementPlugin());
57
- otherPlugins.push(new HotModuleServerPlugin(hmrPort));
58
- }
59
-
60
- return plugins.concat(otherPlugins);
61
- }
62
-
63
- export function getRules(baseDir: string, production: boolean, pilet: boolean): Array<RuleSetRule> {
64
- const styleLoaders = getStyleLoaders(production, pilet);
65
- const nodeModules = resolve(baseDir, 'node_modules');
66
- const babelLoader = {
67
- loader: 'babel-loader',
68
- options: {
69
- presets: ['@babel/preset-env', '@babel/preset-react'],
70
- },
71
- };
72
- const tsLoader = {
73
- loader: 'ts-loader',
74
- options: {
75
- transpileOnly: true,
76
- },
77
- };
78
- const fileLoader = {
79
- loader: 'file-loader',
80
- options: {
81
- esModule: false,
82
- },
83
- };
84
-
85
- return [
86
- {
87
- test: /\.(png|jpe?g|gif|bmp|avi|mp4|mp3|svg|ogg|webp|woff2?|eot|ttf|wav)$/i,
88
- use: [fileLoader],
89
- },
90
- {
91
- test: /\.s[ac]ss$/i,
92
- use: [...styleLoaders, 'css-loader', 'sass-loader'],
93
- },
94
- {
95
- test: /\.css$/i,
96
- use: [...styleLoaders, 'css-loader'],
97
- },
98
- {
99
- test: /\.m?jsx?$/i,
100
- use: [babelLoader],
101
- exclude: nodeModules,
102
- },
103
- {
104
- test: /\.tsx?$/i,
105
- use: [babelLoader, tsLoader],
106
- },
107
- {
108
- test: /\.codegen$/i,
109
- use: ['parcel-codegen-loader'],
110
- },
111
- {
112
- test: /\.js$/i,
113
- use: ['source-map-loader'],
114
- exclude: nodeModules,
115
- enforce: 'pre',
116
- },
117
- ];
118
- }
@@ -1,2 +0,0 @@
1
- export * from './pilet';
2
- export * from './piral';
@@ -1,82 +0,0 @@
1
- import * as webpack from 'webpack';
2
- import * as TerserPlugin from 'terser-webpack-plugin';
3
- import * as OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
4
- import { PiletSchemaVersion } from 'piral-cli';
5
- import { piletWebpackConfigEnhancer } from '../enhancers/pilet-webpack-config-enhancer';
6
- import { join } from 'path';
7
- import { getRules, getPlugins, extensions, getVariables } from './common';
8
-
9
- export async function getPiletConfig(
10
- baseDir: string,
11
- template: string,
12
- dist: string,
13
- filename: string,
14
- externals: Array<string>,
15
- piral: string,
16
- schema: PiletSchemaVersion,
17
- develop = false,
18
- sourceMaps = true,
19
- contentHash = true,
20
- minimize = true,
21
- publicPath = '/',
22
- progress = false,
23
- ): Promise<webpack.Configuration> {
24
- const production = !develop;
25
- const name = process.env.BUILD_PCKG_NAME;
26
- const version = process.env.BUILD_PCKG_VERSION;
27
-
28
- const enhance = piletWebpackConfigEnhancer({
29
- name,
30
- piral,
31
- version,
32
- externals,
33
- schema,
34
- variables: getVariables(),
35
- });
36
-
37
- return enhance({
38
- devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
39
-
40
- mode: develop ? 'development' : 'production',
41
-
42
- entry: {
43
- main: [join(__dirname, '..', 'set-path'), template],
44
- },
45
-
46
- output: {
47
- publicPath,
48
- path: dist,
49
- filename,
50
- chunkFilename: contentHash ? '[chunkhash:8].js' : undefined,
51
- },
52
-
53
- resolve: {
54
- extensions,
55
- },
56
-
57
- module: {
58
- rules: getRules(baseDir, production, true),
59
- },
60
-
61
- optimization: {
62
- minimize,
63
- minimizer: [
64
- new TerserPlugin({
65
- extractComments: false,
66
- terserOptions: {
67
- ie8: true,
68
- output: {
69
- comments: /^@pilet/,
70
- },
71
- mangle: {
72
- reserved: ['__bundleUrl__'],
73
- },
74
- },
75
- }),
76
- new OptimizeCSSAssetsPlugin({}),
77
- ],
78
- },
79
-
80
- plugins: getPlugins([], progress, production),
81
- });
82
- }
@@ -1,73 +0,0 @@
1
- import * as webpack from 'webpack';
2
- import * as TerserPlugin from 'terser-webpack-plugin';
3
- import * as OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
4
- import { html5EntryWebpackConfigEnhancer } from '../enhancers/html5-entry-webpack-config-enhancer';
5
- import { piralInstanceWebpackConfigEnhancer } from '../enhancers/piral-instance-webpack-config-enhancer';
6
- import { getRules, getPlugins, extensions, getVariables, getHmrEntry } from './common';
7
-
8
- export async function getPiralConfig(
9
- baseDir: string,
10
- template: string,
11
- dist: string,
12
- externals: Array<string>,
13
- develop = false,
14
- sourceMaps = true,
15
- contentHash = true,
16
- minimize = true,
17
- publicPath = '/',
18
- hmr = 0,
19
- progress = false,
20
- ): Promise<webpack.Configuration> {
21
- const production = !develop;
22
- const name = process.env.BUILD_PCKG_NAME;
23
- const version = process.env.BUILD_PCKG_VERSION;
24
-
25
- const enhance = (options) =>
26
- [
27
- html5EntryWebpackConfigEnhancer({}),
28
- piralInstanceWebpackConfigEnhancer({
29
- name,
30
- version,
31
- externals,
32
- variables: getVariables(),
33
- }),
34
- ].reduceRight((acc, val) => val(acc), options);
35
-
36
- return enhance({
37
- devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
38
-
39
- mode: develop ? 'development' : 'production',
40
-
41
- entry: [...getHmrEntry(hmr), template],
42
-
43
- output: {
44
- publicPath,
45
- path: dist,
46
- filename: `index.${contentHash ? '[contenthash].' : ''}js`,
47
- chunkFilename: contentHash ? '[chunkhash:8].js' : undefined,
48
- },
49
-
50
- resolve: {
51
- extensions,
52
- },
53
-
54
- module: {
55
- rules: getRules(baseDir, production, false),
56
- },
57
-
58
- optimization: {
59
- minimize,
60
- minimizer: [
61
- new TerserPlugin({
62
- extractComments: false,
63
- terserOptions: {
64
- ie8: true,
65
- },
66
- }),
67
- new OptimizeCSSAssetsPlugin({}),
68
- ],
69
- },
70
-
71
- plugins: getPlugins([], progress, production, hmr),
72
- });
73
- }
@@ -1,107 +0,0 @@
1
- import { resolve } from 'path';
2
- import { fork, ChildProcess } from 'child_process';
3
- import { Bundler, BundleDetails, BaseBundleParameters } from 'piral-cli';
4
-
5
- function getPath(name: string) {
6
- return resolve(__dirname, '..', '..', 'lib', 'webpack', `run-${name}.js`);
7
- }
8
-
9
- type BundleListener = (args: any) => void;
10
-
11
- function createBundler(cwd: string, ps: ChildProcess, args: any) {
12
- let promise = Promise.resolve();
13
- const listeners: Array<BundleListener> = [];
14
- const bundle: BundleDetails = {
15
- dir: cwd,
16
- hash: '',
17
- name: '',
18
- };
19
- const setPending = () => {
20
- promise = new Promise((done) => {
21
- const f = () => {
22
- done();
23
- bundler.off(f);
24
- };
25
- bundler.on(f);
26
- });
27
- };
28
- const bundler = {
29
- bundle,
30
- start() {
31
- ps.send({
32
- type: 'bundle',
33
- ...args,
34
- });
35
- },
36
- on(cb: BundleListener) {
37
- listeners.push(cb);
38
- },
39
- off(cb: BundleListener) {
40
- listeners.splice(listeners.indexOf(cb), 1);
41
- },
42
- emit(args: any) {
43
- [...listeners].forEach((cb) => cb(args));
44
- },
45
- ready() {
46
- return promise;
47
- },
48
- setPending,
49
- };
50
- setPending();
51
- return bundler;
52
- }
53
-
54
- export function callDynamic<T extends BaseBundleParameters>(name: string, args: T) {
55
- const cwd = args.root;
56
- return new Promise<Bundler>((resolve, reject) => {
57
- const ps = fork(getPath(name), [], { cwd });
58
- const bundler = createBundler(cwd, ps, args);
59
-
60
- ps.on('message', (msg: any) => {
61
- switch (msg.type) {
62
- case 'pending':
63
- bundler.setPending();
64
- break;
65
- case 'update':
66
- bundler.bundle.hash = msg.outHash;
67
- bundler.bundle.name = msg.outName;
68
- bundler.emit(msg.args);
69
- break;
70
- case 'done':
71
- bundler.bundle.dir = msg.outDir;
72
- return resolve(bundler);
73
- case 'fail':
74
- return reject(msg.error);
75
- }
76
- });
77
-
78
- ps.send({
79
- type: 'start',
80
- ...args,
81
- });
82
- });
83
- }
84
-
85
- export function callStatic<T extends BaseBundleParameters>(name: string, args: T) {
86
- const cwd = args.root;
87
- return new Promise<Bundler>((resolve, reject) => {
88
- const ps = fork(getPath(name), [], { cwd });
89
- const bundler = createBundler(cwd, ps, args);
90
-
91
- ps.on('message', (msg: any) => {
92
- switch (msg.type) {
93
- case 'done':
94
- bundler.bundle.dir = msg.outDir;
95
- bundler.bundle.name = msg.outFile;
96
- return resolve(bundler);
97
- case 'fail':
98
- return reject(msg.error);
99
- }
100
- });
101
-
102
- ps.send({
103
- type: 'start',
104
- ...args,
105
- });
106
- });
107
- }
@@ -1 +0,0 @@
1
- export * from './bundler-calls';
@@ -1,82 +0,0 @@
1
- import type { PiletSchemaVersion, LogLevels } from 'piral-cli';
2
- import { setStandardEnvs } from 'piral-cli/utils';
3
- import { resolve } from 'path';
4
- import { runWebpack } from './bundler-run';
5
- import { getPiletConfig } from '../configs';
6
- import { extendConfig } from '../helpers';
7
- import { defaultWebpackConfig } from '../constants';
8
-
9
- async function run(
10
- root: string,
11
- piral: string,
12
- sourceMaps: boolean,
13
- contentHash: boolean,
14
- minify: boolean,
15
- externals: Array<string>,
16
- outDir: string,
17
- outFile: string,
18
- entryModule: string,
19
- version: PiletSchemaVersion,
20
- logLevel: LogLevels,
21
- ) {
22
- setStandardEnvs({
23
- production: true,
24
- piral,
25
- root,
26
- });
27
-
28
- const otherConfigPath = resolve(root, defaultWebpackConfig);
29
- const baseConfig = await getPiletConfig(
30
- root,
31
- entryModule,
32
- outDir,
33
- outFile,
34
- externals,
35
- piral,
36
- version,
37
- false,
38
- sourceMaps,
39
- contentHash,
40
- minify,
41
- );
42
- const wpConfig = extendConfig(baseConfig, otherConfigPath, {
43
- watch: false,
44
- });
45
-
46
- const bundler = runWebpack(wpConfig, logLevel);
47
- return await bundler.bundle();
48
- }
49
-
50
- process.on('message', async (msg) => {
51
- switch (msg.type) {
52
- case 'start':
53
- const result = await run(
54
- process.cwd(),
55
- msg.piral,
56
- msg.sourceMaps,
57
- msg.contentHash,
58
- msg.minify,
59
- msg.externals,
60
- msg.outDir,
61
- msg.outFile,
62
- msg.entryModule,
63
- msg.version,
64
- msg.logLevel,
65
- ).catch((error) => {
66
- process.send({
67
- type: 'fail',
68
- error: error?.message,
69
- });
70
- });
71
-
72
- if (result) {
73
- process.send({
74
- type: 'done',
75
- outDir: result.outDir,
76
- outFile: result.outFile,
77
- });
78
- }
79
-
80
- break;
81
- }
82
- });