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,83 +0,0 @@
1
- import type { LogLevels } from 'piral-cli';
2
- import { setStandardEnvs } from 'piral-cli/utils';
3
- import { resolve } from 'path';
4
- import { runWebpack } from './bundler-run';
5
- import { getPiralConfig } from '../configs';
6
- import { extendConfig } from '../helpers';
7
- import { defaultWebpackConfig } from '../constants';
8
-
9
- async function run(
10
- root: string,
11
- piral: string,
12
- emulator: boolean,
13
- sourceMaps: boolean,
14
- contentHash: boolean,
15
- minify: boolean,
16
- externals: Array<string>,
17
- publicUrl: string,
18
- outDir: string,
19
- entryFiles: string,
20
- logLevel: LogLevels,
21
- ) {
22
- setStandardEnvs({
23
- production: !emulator,
24
- root,
25
- debugPiral: emulator,
26
- debugPilet: emulator,
27
- piral,
28
- dependencies: externals,
29
- });
30
-
31
- const otherConfigPath = resolve(root, defaultWebpackConfig);
32
- const baseConfig = await getPiralConfig(
33
- root,
34
- entryFiles,
35
- outDir,
36
- externals,
37
- emulator,
38
- sourceMaps,
39
- contentHash,
40
- minify,
41
- publicUrl,
42
- );
43
- const wpConfig = extendConfig(baseConfig, otherConfigPath, {
44
- watch: false,
45
- });
46
-
47
- const bundler = runWebpack(wpConfig, logLevel);
48
- return bundler.bundle();
49
- }
50
-
51
- process.on('message', async (msg) => {
52
- switch (msg.type) {
53
- case 'start':
54
- const result = await run(
55
- process.cwd(),
56
- msg.piral,
57
- msg.emulator,
58
- msg.sourceMaps,
59
- msg.contentHash,
60
- msg.minify,
61
- msg.externals,
62
- msg.publicUrl,
63
- msg.outDir,
64
- msg.entryFiles,
65
- msg.logLevel,
66
- ).catch((error) => {
67
- process.send({
68
- type: 'fail',
69
- error: error?.message,
70
- });
71
- });
72
-
73
- if (result) {
74
- process.send({
75
- type: 'done',
76
- outDir: result.outDir,
77
- outFile: result.outFile,
78
- });
79
- }
80
-
81
- break;
82
- }
83
- });
@@ -1,76 +0,0 @@
1
- import type { LogLevels } from 'piral-cli';
2
- import { setStandardEnvs, progress, getFreePort, logReset } from 'piral-cli/utils';
3
- import { resolve } from 'path';
4
- import { runWebpack } from './bundler-run';
5
- import { extendConfig } from '../helpers';
6
- import { getPiralConfig } from '../configs';
7
- import { defaultWebpackConfig } from '../constants';
8
-
9
- async function run(
10
- root: string,
11
- piral: string,
12
- hmr: boolean,
13
- externals: Array<string>,
14
- entryFiles: string,
15
- logLevel: LogLevels,
16
- ) {
17
- progress(`Preparing supplied Piral instance ...`);
18
-
19
- const outDir = resolve(root, 'dist', 'app');
20
-
21
- setStandardEnvs({
22
- piral,
23
- dependencies: externals,
24
- production: true,
25
- debugPiral: true,
26
- debugPilet: true,
27
- root,
28
- });
29
-
30
- const otherConfigPath = resolve(root, defaultWebpackConfig);
31
- const hmrPort = hmr ? await getFreePort(62123) : 0;
32
- const baseConfig = await getPiralConfig(
33
- root,
34
- entryFiles,
35
- outDir,
36
- externals,
37
- true,
38
- true,
39
- false,
40
- false,
41
- undefined,
42
- hmrPort,
43
- );
44
- const wpConfig = extendConfig(baseConfig, otherConfigPath, {
45
- watch: true,
46
- });
47
-
48
- const bundler = runWebpack(wpConfig, logLevel);
49
- const bundle = await bundler.bundle();
50
- logReset();
51
- return bundle;
52
- }
53
-
54
- process.on('message', async (msg) => {
55
- switch (msg.type) {
56
- case 'start':
57
- const result = await run(process.cwd(), msg.piral, true, msg.externals, msg.entryFiles, msg.logLevel).catch(
58
- (error) => {
59
- process.send({
60
- type: 'fail',
61
- error: error?.message,
62
- });
63
- },
64
- );
65
-
66
- if (result) {
67
- process.send({
68
- type: 'done',
69
- outDir: result.outDir,
70
- outFile: result.outFile,
71
- });
72
- }
73
-
74
- break;
75
- }
76
- });
@@ -1,94 +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
- externals: Array<string>,
13
- entryModule: string,
14
- version: PiletSchemaVersion,
15
- logLevel: LogLevels,
16
- ) {
17
- setStandardEnvs({
18
- piral,
19
- root,
20
- });
21
-
22
- const otherConfigPath = resolve(root, defaultWebpackConfig);
23
- const dist = resolve(root, 'dist');
24
- const baseConfig = await getPiletConfig(
25
- root,
26
- entryModule,
27
- dist,
28
- 'index.js',
29
- externals,
30
- piral,
31
- version,
32
- true,
33
- true,
34
- true,
35
- false,
36
- );
37
- const wpConfig = extendConfig(baseConfig, otherConfigPath, {
38
- watch: true,
39
- });
40
-
41
- return runWebpack(wpConfig, logLevel);
42
- }
43
-
44
- let bundler;
45
-
46
- process.on('message', async (msg) => {
47
- const root = process.cwd();
48
-
49
- switch (msg.type) {
50
- case 'bundle':
51
- if (bundler) {
52
- await bundler.bundle();
53
-
54
- bundler.on('buildStart', () => {
55
- process.send({
56
- type: 'pending',
57
- });
58
- });
59
- }
60
-
61
- break;
62
- case 'start':
63
- bundler = await run(root, msg.piral, msg.externals, msg.entryModule, msg.version, msg.logLevel).catch((error) => {
64
- process.send({
65
- type: 'fail',
66
- error: error?.message,
67
- });
68
- });
69
-
70
- if (bundler) {
71
- bundler.on('bundled', async () => {
72
- if (msg.hmr) {
73
- process.send({
74
- type: 'update',
75
- outHash: bundler.mainBundle.entryAsset.hash,
76
- outName: bundler.mainBundle.name.substr(bundler.options.outDir.length),
77
- args: {
78
- requireRef: bundler.mainBundle.requireRef,
79
- version: msg.version,
80
- root,
81
- },
82
- });
83
- }
84
- });
85
-
86
- process.send({
87
- type: 'done',
88
- outDir: bundler.options.outDir,
89
- });
90
- }
91
-
92
- break;
93
- }
94
- });
@@ -1,95 +0,0 @@
1
- import type { LogLevels } from 'piral-cli';
2
- import { setStandardEnvs, getFreePort } from 'piral-cli/utils';
3
- import { resolve } from 'path';
4
- import { runWebpack } from './bundler-run';
5
- import { getPiralConfig } from '../configs';
6
- import { extendConfig } from '../helpers';
7
- import { defaultWebpackConfig } from '../constants';
8
-
9
- async function run(
10
- root: string,
11
- piral: string,
12
- hmr: boolean,
13
- externals: Array<string>,
14
- publicUrl: string,
15
- entryFiles: string,
16
- logLevel: LogLevels,
17
- ) {
18
- setStandardEnvs({
19
- root,
20
- debugPiral: true,
21
- dependencies: externals,
22
- piral,
23
- });
24
-
25
- const otherConfigPath = resolve(root, defaultWebpackConfig);
26
- const dist = resolve(root, 'dist');
27
- const hmrPort = hmr ? await getFreePort(62123) : 0;
28
- const baseConfig = await getPiralConfig(
29
- root,
30
- entryFiles,
31
- dist,
32
- externals,
33
- true,
34
- true,
35
- false,
36
- false,
37
- publicUrl,
38
- hmrPort,
39
- );
40
- const wpConfig = extendConfig(baseConfig, otherConfigPath, {
41
- watch: true,
42
- });
43
-
44
- return runWebpack(wpConfig, logLevel);
45
- }
46
-
47
- let bundler;
48
-
49
- process.on('message', async (msg) => {
50
- const root = process.cwd();
51
-
52
- switch (msg.type) {
53
- case 'bundle':
54
- if (bundler) {
55
- await bundler.bundle();
56
-
57
- bundler.on('buildStart', () => {
58
- process.send({
59
- type: 'pending',
60
- });
61
- });
62
- }
63
-
64
- break;
65
- case 'start':
66
- bundler = await run(root, msg.piral, msg.hmr, msg.externals, msg.publicUrl, msg.entryFiles, msg.logLevel).catch(
67
- (error) => {
68
- process.send({
69
- type: 'fail',
70
- error: error?.message,
71
- });
72
- },
73
- );
74
-
75
- if (bundler) {
76
- bundler.on('bundled', () => {
77
- process.send({
78
- type: 'update',
79
- outHash: bundler.mainBundle.entryAsset.hash,
80
- outName: 'index.html',
81
- args: {
82
- root,
83
- },
84
- });
85
- });
86
-
87
- process.send({
88
- type: 'done',
89
- outDir: bundler.options.outDir,
90
- });
91
- }
92
-
93
- break;
94
- }
95
- });