@simplysm/sd-cli 6.4.6 → 7.0.6

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 (182) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/dist/bin/sd-cli.d.ts +1 -0
  3. package/dist/bin/sd-cli.mjs +60 -0
  4. package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
  5. package/dist/build-tool/SdCliCacheCompilerHost.mjs +44 -0
  6. package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
  7. package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +36 -0
  8. package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
  9. package/dist/build-tool/SdCliPackageLinter.mjs +41 -0
  10. package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
  11. package/dist/builder/SdCliJsLibBuilder.mjs +50 -0
  12. package/dist/builder/SdCliTsLibBuilder.d.ts +27 -0
  13. package/dist/builder/SdCliTsLibBuilder.mjs +226 -0
  14. package/dist/commons.d.ts +43 -0
  15. package/dist/commons.mjs +2 -0
  16. package/dist/entry-points/SdCliWorkspace.d.ts +17 -0
  17. package/dist/entry-points/SdCliWorkspace.mjs +186 -0
  18. package/dist/packages/SdCliPackage.d.ts +19 -0
  19. package/dist/packages/SdCliPackage.mjs +89 -0
  20. package/dist/utils/SdBuildResultUtil.d.ts +6 -0
  21. package/dist/utils/SdBuildResultUtil.mjs +38 -0
  22. package/lib/ts-node-esm-paths.mjs +15 -0
  23. package/package.json +27 -59
  24. package/src/bin/sd-cli.ts +54 -220
  25. package/src/build-tool/SdCliCacheCompilerHost.ts +71 -0
  26. package/src/build-tool/SdCliNgCacheCompilerHost.ts +50 -0
  27. package/src/build-tool/SdCliPackageLinter.ts +54 -0
  28. package/src/builder/SdCliJsLibBuilder.ts +66 -0
  29. package/src/builder/SdCliTsLibBuilder.ts +335 -0
  30. package/src/commons.ts +15 -124
  31. package/src/entry-points/SdCliWorkspace.ts +222 -0
  32. package/src/packages/SdCliPackage.ts +111 -0
  33. package/src/utils/SdBuildResultUtil.ts +43 -0
  34. package/tsconfig-build.json +9 -0
  35. package/tsconfig.json +7 -18
  36. package/.eslintrc.js +0 -19
  37. package/dist-node/bin/sd-cli.js +0 -197
  38. package/dist-node/bin/sd-cli.js.map +0 -1
  39. package/dist-node/build-tools/SdCliCordova.js +0 -145
  40. package/dist-node/build-tools/SdCliCordova.js.map +0 -1
  41. package/dist-node/build-tools/SdCliIndexFileGenerator.js +0 -51
  42. package/dist-node/build-tools/SdCliIndexFileGenerator.js.map +0 -1
  43. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +0 -675
  44. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +0 -1
  45. package/dist-node/build-tools/metadata/SdAotMetadataReader.js +0 -274
  46. package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +0 -1
  47. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +0 -124
  48. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +0 -1
  49. package/dist-node/build-tools/metadata/SdMetadataError.js +0 -13
  50. package/dist-node/build-tools/metadata/SdMetadataError.js.map +0 -1
  51. package/dist-node/build-tools/metadata/SdMyMetadataReader.js +0 -321
  52. package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +0 -1
  53. package/dist-node/builders/SdCliJavascriptLinter.js +0 -65
  54. package/dist-node/builders/SdCliJavascriptLinter.js.map +0 -1
  55. package/dist-node/builders/SdCliNgClientBuilder.js +0 -636
  56. package/dist-node/builders/SdCliNgClientBuilder.js.map +0 -1
  57. package/dist-node/builders/SdCliNgLibraryBuilder.js +0 -217
  58. package/dist-node/builders/SdCliNgLibraryBuilder.js.map +0 -1
  59. package/dist-node/builders/SdCliPublisher.js +0 -129
  60. package/dist-node/builders/SdCliPublisher.js.map +0 -1
  61. package/dist-node/builders/SdCliServerBuilder.js +0 -452
  62. package/dist-node/builders/SdCliServerBuilder.js.map +0 -1
  63. package/dist-node/builders/SdCliTypescriptBuilder.js +0 -347
  64. package/dist-node/builders/SdCliTypescriptBuilder.js.map +0 -1
  65. package/dist-node/commons.js +0 -3
  66. package/dist-node/commons.js.map +0 -1
  67. package/dist-node/entry-points/SdCliLocalUpdater.js +0 -88
  68. package/dist-node/entry-points/SdCliLocalUpdater.js.map +0 -1
  69. package/dist-node/entry-points/SdCliPrepare.js +0 -56
  70. package/dist-node/entry-points/SdCliPrepare.js.map +0 -1
  71. package/dist-node/entry-points/SdCliProject.js +0 -302
  72. package/dist-node/entry-points/SdCliProject.js.map +0 -1
  73. package/dist-node/packages/SdCliClientPackage.js +0 -91
  74. package/dist-node/packages/SdCliClientPackage.js.map +0 -1
  75. package/dist-node/packages/SdCliLibraryPackage.js +0 -99
  76. package/dist-node/packages/SdCliLibraryPackage.js.map +0 -1
  77. package/dist-node/packages/SdCliPackageBase.js +0 -33
  78. package/dist-node/packages/SdCliPackageBase.js.map +0 -1
  79. package/dist-node/packages/SdCliServerPackage.js +0 -69
  80. package/dist-node/packages/SdCliServerPackage.js.map +0 -1
  81. package/dist-node/packages/SdCliUnknownPackage.js +0 -15
  82. package/dist-node/packages/SdCliUnknownPackage.js.map +0 -1
  83. package/dist-node/utils/SdCliFileCrypto.js +0 -76
  84. package/dist-node/utils/SdCliFileCrypto.js.map +0 -1
  85. package/dist-node/utils/SdProjectConfigUtil.js +0 -62
  86. package/dist-node/utils/SdProjectConfigUtil.js.map +0 -1
  87. package/dist-node/utils/SdTsDiagnosticUtil.js +0 -45
  88. package/dist-node/utils/SdTsDiagnosticUtil.js.map +0 -1
  89. package/dist-node/utils/SdWebpackUtil.js +0 -63
  90. package/dist-node/utils/SdWebpackUtil.js.map +0 -1
  91. package/dist-node/workers/client-ng-gen-worker.js +0 -57
  92. package/dist-node/workers/client-ng-gen-worker.js.map +0 -1
  93. package/dist-node/workers/lib-build-worker.js +0 -88
  94. package/dist-node/workers/lib-build-worker.js.map +0 -1
  95. package/dist-types/bin/sd-cli.d.ts +0 -3
  96. package/dist-types/bin/sd-cli.d.ts.map +0 -1
  97. package/dist-types/build-tools/SdCliCordova.d.ts +0 -15
  98. package/dist-types/build-tools/SdCliCordova.d.ts.map +0 -1
  99. package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts +0 -13
  100. package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts.map +0 -1
  101. package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts +0 -43
  102. package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts.map +0 -1
  103. package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts +0 -58
  104. package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts.map +0 -1
  105. package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +0 -43
  106. package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts.map +0 -1
  107. package/dist-types/build-tools/metadata/SdMetadataError.d.ts +0 -7
  108. package/dist-types/build-tools/metadata/SdMetadataError.d.ts.map +0 -1
  109. package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +0 -59
  110. package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts.map +0 -1
  111. package/dist-types/builders/SdCliJavascriptLinter.d.ts +0 -14
  112. package/dist-types/builders/SdCliJavascriptLinter.d.ts.map +0 -1
  113. package/dist-types/builders/SdCliNgClientBuilder.d.ts +0 -29
  114. package/dist-types/builders/SdCliNgClientBuilder.d.ts.map +0 -1
  115. package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +0 -30
  116. package/dist-types/builders/SdCliNgLibraryBuilder.d.ts.map +0 -1
  117. package/dist-types/builders/SdCliPublisher.d.ts +0 -9
  118. package/dist-types/builders/SdCliPublisher.d.ts.map +0 -1
  119. package/dist-types/builders/SdCliServerBuilder.d.ts +0 -31
  120. package/dist-types/builders/SdCliServerBuilder.d.ts.map +0 -1
  121. package/dist-types/builders/SdCliTypescriptBuilder.d.ts +0 -56
  122. package/dist-types/builders/SdCliTypescriptBuilder.d.ts.map +0 -1
  123. package/dist-types/commons.d.ts +0 -134
  124. package/dist-types/commons.d.ts.map +0 -1
  125. package/dist-types/entry-points/SdCliLocalUpdater.d.ts +0 -12
  126. package/dist-types/entry-points/SdCliLocalUpdater.d.ts.map +0 -1
  127. package/dist-types/entry-points/SdCliPrepare.d.ts +0 -6
  128. package/dist-types/entry-points/SdCliPrepare.d.ts.map +0 -1
  129. package/dist-types/entry-points/SdCliProject.d.ts +0 -32
  130. package/dist-types/entry-points/SdCliProject.d.ts.map +0 -1
  131. package/dist-types/packages/SdCliClientPackage.d.ts +0 -17
  132. package/dist-types/packages/SdCliClientPackage.d.ts.map +0 -1
  133. package/dist-types/packages/SdCliLibraryPackage.d.ts +0 -20
  134. package/dist-types/packages/SdCliLibraryPackage.d.ts.map +0 -1
  135. package/dist-types/packages/SdCliPackageBase.d.ts +0 -11
  136. package/dist-types/packages/SdCliPackageBase.d.ts.map +0 -1
  137. package/dist-types/packages/SdCliServerPackage.d.ts +0 -16
  138. package/dist-types/packages/SdCliServerPackage.d.ts.map +0 -1
  139. package/dist-types/packages/SdCliUnknownPackage.d.ts +0 -9
  140. package/dist-types/packages/SdCliUnknownPackage.d.ts.map +0 -1
  141. package/dist-types/utils/SdCliFileCrypto.d.ts +0 -8
  142. package/dist-types/utils/SdCliFileCrypto.d.ts.map +0 -1
  143. package/dist-types/utils/SdProjectConfigUtil.d.ts +0 -7
  144. package/dist-types/utils/SdProjectConfigUtil.d.ts.map +0 -1
  145. package/dist-types/utils/SdTsDiagnosticUtil.d.ts +0 -6
  146. package/dist-types/utils/SdTsDiagnosticUtil.d.ts.map +0 -1
  147. package/dist-types/utils/SdWebpackUtil.d.ts +0 -7
  148. package/dist-types/utils/SdWebpackUtil.d.ts.map +0 -1
  149. package/dist-types/workers/client-ng-gen-worker.d.ts +0 -2
  150. package/dist-types/workers/client-ng-gen-worker.d.ts.map +0 -1
  151. package/dist-types/workers/lib-build-worker.d.ts +0 -2
  152. package/dist-types/workers/lib-build-worker.d.ts.map +0 -1
  153. package/schema/schema.json +0 -447
  154. package/sd-tsconfig.node.json +0 -18
  155. package/src/build-tools/SdCliCordova.ts +0 -242
  156. package/src/build-tools/SdCliIndexFileGenerator.ts +0 -61
  157. package/src/build-tools/SdCliNgModuleFilesGenerator.ts +0 -894
  158. package/src/build-tools/metadata/SdAotMetadataReader.ts +0 -374
  159. package/src/build-tools/metadata/SdIvyMetadataReader.ts +0 -183
  160. package/src/build-tools/metadata/SdMetadataError.ts +0 -7
  161. package/src/build-tools/metadata/SdMyMetadataReader.ts +0 -407
  162. package/src/builders/SdCliJavascriptLinter.ts +0 -81
  163. package/src/builders/SdCliNgClientBuilder.ts +0 -793
  164. package/src/builders/SdCliNgLibraryBuilder.ts +0 -301
  165. package/src/builders/SdCliPublisher.ts +0 -144
  166. package/src/builders/SdCliServerBuilder.ts +0 -555
  167. package/src/builders/SdCliTypescriptBuilder.ts +0 -552
  168. package/src/entry-points/SdCliLocalUpdater.ts +0 -114
  169. package/src/entry-points/SdCliPrepare.ts +0 -104
  170. package/src/entry-points/SdCliProject.ts +0 -405
  171. package/src/packages/SdCliClientPackage.ts +0 -111
  172. package/src/packages/SdCliLibraryPackage.ts +0 -118
  173. package/src/packages/SdCliPackageBase.ts +0 -34
  174. package/src/packages/SdCliServerPackage.ts +0 -85
  175. package/src/packages/SdCliUnknownPackage.ts +0 -14
  176. package/src/utils/SdCliFileCrypto.ts +0 -87
  177. package/src/utils/SdCliUtils.ts +0 -56
  178. package/src/utils/SdProjectConfigUtil.ts +0 -145
  179. package/src/utils/SdTsDiagnosticUtil.ts +0 -46
  180. package/src/utils/SdWebpackUtil.ts +0 -71
  181. package/src/workers/client-ng-gen-worker.ts +0 -63
  182. package/src/workers/lib-build-worker.ts +0 -97
@@ -1,636 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SdCliNgClientBuilder = void 0;
4
- const events_1 = require("events");
5
- const webpack = require("webpack");
6
- const path = require("path");
7
- const ts = require("typescript");
8
- const sd_core_node_1 = require("@simplysm/sd-core-node");
9
- const javascript_optimizer_plugin_1 = require("@angular-devkit/build-angular/src/webpack/plugins/javascript-optimizer-plugin");
10
- const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
11
- const esbuild = require("esbuild");
12
- const plugins_1 = require("@angular-devkit/build-angular/src/webpack/plugins");
13
- const license_webpack_plugin_1 = require("license-webpack-plugin");
14
- const sass_service_1 = require("@angular-devkit/build-angular/src/sass/sass-service");
15
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
16
- const webpack_1 = require("@ngtools/webpack");
17
- const SdWebpackUtil_1 = require("../utils/SdWebpackUtil");
18
- const index_html_webpack_plugin_1 = require("@angular-devkit/build-angular/src/webpack/plugins/index-html-webpack-plugin");
19
- const CopyWebpackPlugin = require("copy-webpack-plugin");
20
- const hmr_loader_1 = require("@angular-devkit/build-angular/src/webpack/plugins/hmr/hmr-loader");
21
- const WebpackDevMiddleware = require("webpack-dev-middleware");
22
- const sd_core_common_1 = require("@simplysm/sd-core-common");
23
- const service_worker_1 = require("@angular-devkit/build-angular/src/utils/service-worker");
24
- const browserslist = require("browserslist");
25
- const WebpackHotMiddleware = require("webpack-hot-middleware");
26
- const os = require("os");
27
- const SdCliCordova_1 = require("../build-tools/SdCliCordova");
28
- const JSZip = require("jszip");
29
- const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
30
- const ESLintWebpackPlugin = require("eslint-webpack-plugin");
31
- class SdCliNgClientBuilder extends events_1.EventEmitter {
32
- constructor(rootPath, tsconfigFilePath, projectRootPath, config, platformType, skipProcesses) {
33
- super();
34
- this.rootPath = rootPath;
35
- this.tsconfigFilePath = tsconfigFilePath;
36
- this.projectRootPath = projectRootPath;
37
- this.config = config;
38
- this.platformType = platformType;
39
- this.skipProcesses = skipProcesses;
40
- const tsconfig = sd_core_node_1.FsUtil.readJson(this.tsconfigFilePath);
41
- this.parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
42
- this.npmConfig = sd_core_node_1.FsUtil.readJson(path.resolve(this.rootPath, "package.json"));
43
- this._logger = sd_core_node_1.Logger.get(["simplysm", "sd-cli", this.constructor.name, this.npmConfig.name]);
44
- }
45
- get _platformConfig() {
46
- return this.config.platforms.single((item) => item.type === this.platformType);
47
- }
48
- on(event, listener) {
49
- return super.on(event, listener);
50
- }
51
- async buildAsync() {
52
- this.emit("change");
53
- await sd_core_node_1.FsUtil.removeAsync(this.parsedTsconfig.options.outDir);
54
- const buildResult = [];
55
- const cordova = this.platformType !== "cordova" ? undefined
56
- : new SdCliCordova_1.SdCliCordova(this.rootPath, this._platformConfig);
57
- if (cordova) {
58
- await cordova.initializeAsync();
59
- }
60
- if (!this.skipProcesses.includes("genNgModule")) {
61
- this._logger.debug("NgGen 수행");
62
- const genResult = await this._runNgGenWorkerAsync(false);
63
- buildResult.push(...genResult.result);
64
- this._logger.debug("NgGen 수행 결과", genResult);
65
- }
66
- this._logger.debug("Webpack 빌드 수행");
67
- const webpackConfig = this._getWebpackConfig(false);
68
- const compiler = webpack(webpackConfig);
69
- const webpackBuildResults = await new Promise((resolve, reject) => {
70
- compiler.run(async (err, stat) => {
71
- if (err != null) {
72
- reject(err);
73
- return;
74
- }
75
- if (cordova) {
76
- await cordova.buildAsync(this.parsedTsconfig.options.outDir);
77
- const platformConfig = this._platformConfig;
78
- const zip = new JSZip();
79
- const resultFiles = await sd_core_node_1.FsUtil.globAsync(path.resolve(this.rootPath, ".cordova", "www", "**/*"), {
80
- dot: true,
81
- nodir: true
82
- });
83
- for (const resultFile of resultFiles) {
84
- const contentBuffer = await sd_core_node_1.FsUtil.readFileBufferAsync(resultFile);
85
- const relativePath = path.relative(path.resolve(this.rootPath, ".cordova", "www"), resultFile);
86
- zip.file("/" + relativePath, contentBuffer);
87
- }
88
- const zipFileName = path.basename(`${platformConfig.appName}-v${this.npmConfig.version}.zip`);
89
- const resultBuffer = await zip.generateAsync({ type: "nodebuffer" });
90
- await sd_core_node_1.FsUtil.writeFileAsync(path.resolve(this.parsedTsconfig.options.outDir, "updates/", zipFileName), resultBuffer);
91
- }
92
- const results = SdWebpackUtil_1.SdWebpackUtil.getWebpackResults(stat);
93
- resolve(results);
94
- });
95
- });
96
- this._logger.debug("Webpack 빌드 결과", webpackBuildResults);
97
- buildResult.push(...webpackBuildResults);
98
- const targetPath = path.resolve(this.parsedTsconfig.options.outDir, ".config.json");
99
- await sd_core_node_1.FsUtil.writeFileAsync(targetPath, JSON.stringify(this.config.configs ?? {}, undefined, 2));
100
- if (sd_core_node_1.FsUtil.exists(path.resolve(this.rootPath, "ngsw-config.json"))) {
101
- const packageKey = this.npmConfig.name.split("/").last();
102
- await service_worker_1.augmentAppWithServiceWorker(sd_core_node_1.PathUtil.posix(this.projectRootPath), sd_core_node_1.PathUtil.posix(path.relative(this.projectRootPath, this.rootPath)), sd_core_node_1.PathUtil.posix(path.relative(this.projectRootPath, this.parsedTsconfig.options.outDir)), `/${packageKey}/`, sd_core_node_1.PathUtil.posix(path.relative(this.projectRootPath, path.resolve(this.rootPath, "ngsw-config.json"))));
103
- }
104
- this.emit("complete", buildResult.distinct());
105
- }
106
- async watchAsync(serverPath) {
107
- await sd_core_node_1.FsUtil.removeAsync(this.parsedTsconfig.options.outDir);
108
- const ngGenResultsMap = new Map();
109
- const addNgGenResults = (r) => {
110
- for (const item of r) {
111
- const arr = ngGenResultsMap.getOrCreate(item.filePath !== undefined ? sd_core_node_1.PathUtil.posix(item.filePath) : "undefined", []);
112
- arr.push(item);
113
- }
114
- };
115
- const removeNgGenResults = (filePaths) => {
116
- for (const filePath of filePaths) {
117
- ngGenResultsMap.delete(sd_core_node_1.PathUtil.posix(filePath));
118
- }
119
- };
120
- const getNgGenResults = () => {
121
- return Array.from(ngGenResultsMap.values()).mapMany().distinct();
122
- };
123
- const cordova = this.platformType !== "cordova" ? undefined
124
- : new SdCliCordova_1.SdCliCordova(this.rootPath, this._platformConfig);
125
- if (cordova) {
126
- await cordova.initializeAsync();
127
- }
128
- let invalidFiles = new Set();
129
- const webpackConfig = this._getWebpackConfig(true);
130
- const compiler = webpack(webpackConfig);
131
- return await new Promise((resolve, reject) => {
132
- compiler.hooks.invalid.tap(this.constructor.name, (fileName) => {
133
- if (fileName != null) {
134
- invalidFiles.add(fileName);
135
- }
136
- });
137
- compiler.hooks.watchRun.tapAsync(this.constructor.name, async (compiler1, callback) => {
138
- this.emit("change");
139
- if (invalidFiles.size === 0) {
140
- if (!this.skipProcesses.includes("genNgModule")) {
141
- this._logger.debug("첫 NgGen 수행");
142
- const genResult = await this._runNgGenWorkerAsync(true);
143
- addNgGenResults(genResult.result);
144
- this._logger.debug("첫 NgGen 수행 결과", genResult);
145
- }
146
- this._logger.debug("Webpack 빌드 수행");
147
- callback();
148
- }
149
- else {
150
- const changedFiles = [...invalidFiles];
151
- invalidFiles = new Set();
152
- const changedFilePaths = changedFiles
153
- .map((item) => sd_core_node_1.PathUtil.posix(item))
154
- .filter((item) => path.basename(item).includes("."))
155
- .distinct();
156
- if (changedFilePaths.length === 0) {
157
- this._logger.debug("Webpack 빌드 수행");
158
- callback();
159
- return;
160
- }
161
- removeNgGenResults(["undefined"]);
162
- removeNgGenResults(changedFilePaths);
163
- if (!this.skipProcesses.includes("genNgModule")) {
164
- this._logger.debug("변경파일에 대한, NgGen 수행", changedFilePaths);
165
- const genResult = await this._runNgGenWorkerAsync(true, changedFilePaths);
166
- if (genResult.dirtyFilePaths.length === 0) {
167
- this._logger.debug("변경파일에 대한, NgGen 결과", genResult);
168
- this._logger.debug("Webpack 빌드 수행");
169
- callback();
170
- return;
171
- }
172
- removeNgGenResults(genResult.dirtyFilePaths);
173
- addNgGenResults(genResult.result);
174
- this._logger.debug("변경파일에 대한, NgGen 결과", genResult);
175
- const modifiedFiles = [...compiler.modifiedFiles];
176
- const removedFiles = [...compiler.removedFiles];
177
- for (const genFilePath of genResult.dirtyFilePaths.distinct()) {
178
- if (sd_core_node_1.FsUtil.exists(genFilePath)) {
179
- modifiedFiles.push(genFilePath);
180
- }
181
- else {
182
- removedFiles.push(genFilePath);
183
- }
184
- }
185
- compiler.modifiedFiles = new Set(modifiedFiles.distinct());
186
- compiler.removedFiles = new Set(removedFiles.distinct());
187
- }
188
- this._logger.debug("Webpack 빌드 수행");
189
- callback();
190
- }
191
- });
192
- let devMiddleware;
193
- let hotMiddleware;
194
- compiler.hooks.failed.tap(this.constructor.name, (err) => {
195
- const results = SdWebpackUtil_1.SdWebpackUtil.getWebpackResults(err);
196
- const allResults = [...getNgGenResults(), ...results].distinct();
197
- this.emit("complete", allResults);
198
- this._logger.debug("Webpack 빌드 수행 결과", allResults);
199
- reject(err);
200
- });
201
- compiler.hooks.done.tap("SdCliClientCompiler", async (stats) => {
202
- const results = SdWebpackUtil_1.SdWebpackUtil.getWebpackResults(stats);
203
- const packageKey = this.npmConfig.name.split("/").last();
204
- const configDistPath = !sd_core_common_1.StringUtil.isNullOrEmpty(serverPath)
205
- ? path.resolve(serverPath, "dist/www", packageKey, ".config.json")
206
- : path.resolve(this.parsedTsconfig.options.outDir, ".config.json");
207
- await sd_core_node_1.FsUtil.writeFileAsync(configDistPath, JSON.stringify(this.config.configs ?? {}, undefined, 2));
208
- await sd_core_common_1.Wait.true(() => devMiddleware !== undefined && hotMiddleware !== undefined);
209
- const allResults = [...getNgGenResults(), ...results].distinct();
210
- this.emit("complete", allResults);
211
- this._logger.debug("Webpack 빌드 수행 결과", allResults);
212
- resolve([devMiddleware, hotMiddleware]);
213
- });
214
- devMiddleware = WebpackDevMiddleware(compiler, {
215
- publicPath: webpackConfig.output.publicPath,
216
- index: "index.html",
217
- headers: { "Access-Control-Allow-Origin": "*" },
218
- stats: false
219
- });
220
- hotMiddleware = WebpackHotMiddleware(compiler, {
221
- path: `${webpackConfig.output.publicPath}__webpack_hmr`,
222
- log: false
223
- });
224
- });
225
- }
226
- _getWebpackConfig(watch) {
227
- const nodeSass = new sass_service_1.SassWorkerImplementation();
228
- const packageKey = this.npmConfig.name.split("/").last();
229
- const distPath = (this.platformType === "cordova" && !watch) ? path.resolve(this.rootPath, ".cordova", "www")
230
- : this.parsedTsconfig.options.outDir;
231
- const publicPath = (this.platformType === "cordova" && !watch) ? ""
232
- : (this.platformType !== "browser" ? `/__${this.platformType}` : "") + `/${packageKey}/`;
233
- return {
234
- mode: watch ? "development" : "production",
235
- devtool: false,
236
- target: ["web", "es2015"],
237
- profile: false,
238
- resolve: {
239
- roots: [this.rootPath],
240
- extensions: [".ts", ".js"],
241
- symlinks: true,
242
- mainFields: ["es2015", "browser", "module", "main"],
243
- fallback: this.config.resolveFallback
244
- },
245
- context: this.projectRootPath,
246
- entry: {
247
- main: [
248
- ...watch ? [
249
- `webpack-hot-middleware/client?path=${publicPath}__webpack_hmr&timeout=20000&reload=true&overlay=true`
250
- ] : [],
251
- path.resolve(this.rootPath, "src/main.ts")
252
- ],
253
- polyfills: [
254
- path.resolve(this.rootPath, "src/polyfills.ts")
255
- ],
256
- styles: [
257
- path.resolve(this.rootPath, "src/styles.scss")
258
- ]
259
- },
260
- output: {
261
- clean: true,
262
- path: distPath,
263
- publicPath,
264
- filename: "[name].js",
265
- chunkFilename: "[name].js",
266
- assetModuleFilename: "resources/[name][ext][query]",
267
- crossOriginLoading: false,
268
- trustedTypes: "angular#bundler"
269
- },
270
- ...watch ? {
271
- watchOptions: { poll: undefined, ignored: "**/$_lazy_route_resources" }
272
- } : {
273
- watch: false
274
- },
275
- performance: { hints: false },
276
- ignoreWarnings: [
277
- /System.import\(\) is deprecated and will be removed soon/i,
278
- /Failed to parse source map from/,
279
- /Add postcss as project dependency/
280
- ],
281
- module: {
282
- strictExportPresence: true,
283
- rules: [
284
- ...watch ? [
285
- {
286
- loader: hmr_loader_1.HmrLoader,
287
- include: [path.resolve(this.rootPath, "src/main.ts")]
288
- }
289
- ] : [],
290
- {
291
- test: /[/\\]@angular[/\\]core[/\\].+\.js$/,
292
- parser: { system: true }
293
- },
294
- {
295
- test: /[/\\]rxjs[/\\]add[/\\].+\.js$/,
296
- sideEffects: true
297
- },
298
- ...watch ? [
299
- {
300
- test: /\.m?js$/,
301
- enforce: "pre",
302
- loader: require.resolve("source-map-loader"),
303
- options: {
304
- filterSourceMappingUrl: (mapUri, resourcePath) => {
305
- return !resourcePath.includes("node_modules") || (/@simplysm[\\/]sd/).test(resourcePath);
306
- }
307
- }
308
- }
309
- ] : [],
310
- {
311
- test: /\.scss$/i,
312
- rules: [
313
- {
314
- oneOf: [
315
- {
316
- include: path.resolve(this.rootPath, "src/styles.scss"),
317
- use: [
318
- {
319
- loader: MiniCssExtractPlugin.loader
320
- },
321
- {
322
- loader: "css-loader",
323
- options: {
324
- url: false,
325
- sourceMap: watch
326
- }
327
- }
328
- ]
329
- },
330
- {
331
- exclude: path.resolve(this.rootPath, "src/styles.scss"),
332
- type: "asset/source"
333
- }
334
- ]
335
- },
336
- {
337
- use: [
338
- {
339
- loader: "resolve-url-loader",
340
- options: {
341
- sourceMap: watch
342
- }
343
- },
344
- {
345
- loader: "sass-loader",
346
- options: {
347
- implementation: nodeSass,
348
- sourceMap: true,
349
- sassOptions: {
350
- fiber: false,
351
- precision: 8,
352
- includePaths: [],
353
- outputStyle: "expanded",
354
- quietDeps: true,
355
- verbose: false
356
- }
357
- }
358
- }
359
- ]
360
- }
361
- ]
362
- },
363
- {
364
- test: /\.[jt]sx?$/,
365
- loader: "@ngtools/webpack"
366
- },
367
- {
368
- test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico|otf|xlsx?|pptx?|docx?|zip|pfx|pkl)$/,
369
- type: "asset/resource"
370
- }
371
- ]
372
- },
373
- experiments: { syncWebAssembly: true, asyncWebAssembly: true },
374
- ...watch ? {
375
- cache: { type: "memory", maxGenerations: 1 },
376
- snapshot: {
377
- immutablePaths: this._findAllInternalModuleCachePaths(),
378
- managedPaths: this._findAllInternalModuleCachePaths()
379
- }
380
- } : {
381
- cache: false
382
- },
383
- optimization: {
384
- minimizer: watch ? [] : [
385
- new javascript_optimizer_plugin_1.JavaScriptOptimizerPlugin({
386
- define: { ngDevMode: false, ngI18nClosureMode: false, ngJitMode: false },
387
- sourcemap: false,
388
- target: this.parsedTsconfig.options.target,
389
- keepNames: true,
390
- removeLicenses: true,
391
- advanced: true
392
- }),
393
- new CssMinimizerPlugin({
394
- test: /\.(css|scss)$/,
395
- exclude: "styles.css",
396
- parallel: false,
397
- minify: async (data) => {
398
- const [[sourcefile, input]] = Object.entries(data);
399
- const { code, warnings } = await esbuild.transform(input, {
400
- loader: "css",
401
- minify: true,
402
- sourcefile,
403
- target: browserslist([
404
- "last 2 Chrome versions",
405
- "last 2 Edge major versions"
406
- ]).map((item) => item.replace(/ /g, ""))
407
- });
408
- return {
409
- code,
410
- warnings: warnings.length > 0
411
- ? await esbuild.formatMessages(warnings, { kind: "warning" })
412
- : []
413
- };
414
- }
415
- }),
416
- new CssMinimizerPlugin({
417
- test: /\.css$/,
418
- include: "styles.css",
419
- parallel: 4,
420
- minify: [CssMinimizerPlugin.cssnanoMinify],
421
- minimizerOptions: {
422
- preset: [
423
- "default",
424
- {
425
- svgo: false,
426
- calc: false,
427
- cssDeclarationSorter: false,
428
- minifyParams: false
429
- }
430
- ]
431
- }
432
- })
433
- ],
434
- moduleIds: "deterministic",
435
- chunkIds: watch ? "named" : "deterministic",
436
- emitOnErrors: watch,
437
- runtimeChunk: "single",
438
- splitChunks: {
439
- maxAsyncRequests: Infinity,
440
- cacheGroups: {
441
- default: { chunks: "async", minChunks: 2, priority: 10 },
442
- common: {
443
- name: "common",
444
- chunks: "async",
445
- minChunks: 2,
446
- enforce: true,
447
- priority: 5
448
- },
449
- vendors: false,
450
- defaultVendors: watch ? {
451
- name: "vendor",
452
- chunks: (chunk) => chunk.name === "main",
453
- enforce: true,
454
- test: /[\\/]node_modules[\\/]/
455
- } : false
456
- }
457
- }
458
- },
459
- plugins: [
460
- new NodePolyfillPlugin(),
461
- new webpack.ContextReplacementPlugin(/@angular[\\/]core[\\/]/, path.join(this.rootPath, "$_lazy_route_resources"), {}),
462
- new plugins_1.DedupeModuleResolvePlugin({ verbose: false }),
463
- new CopyWebpackPlugin({
464
- patterns: [
465
- ...["favicon.ico", "assets/", "manifest.webmanifest"].map((item) => ({
466
- context: this.rootPath,
467
- to: item,
468
- from: `src/${item}`,
469
- noErrorOnMissing: true,
470
- force: true,
471
- globOptions: {
472
- dot: true,
473
- followSymbolicLinks: false,
474
- ignore: [
475
- ".gitkeep",
476
- "**/.DS_Store",
477
- "**/Thumbs.db"
478
- ].map((i) => sd_core_node_1.PathUtil.posix(this.rootPath, i))
479
- },
480
- priority: 0
481
- })),
482
- ...this.platformType === "cordova" ? [
483
- ...this._platformConfig.targets.map((target) => ({
484
- context: this.rootPath,
485
- to: `cordova-${target}`,
486
- from: `.cordova/platforms/${target}/platform_www`
487
- })),
488
- ...watch ? [{
489
- context: this.rootPath,
490
- to: `cordova-browser`,
491
- from: `.cordova/platforms/browser/platform_www`
492
- }] : []
493
- ] : []
494
- ]
495
- }),
496
- ...watch ? [] : [
497
- new license_webpack_plugin_1.LicenseWebpackPlugin({
498
- stats: { warnings: false, errors: false },
499
- perChunkOutput: false,
500
- outputFilename: "3rdpartylicenses.txt",
501
- skipChildCompilers: true
502
- })
503
- ],
504
- new plugins_1.CommonJsUsageWarnPlugin(),
505
- ...watch ? [
506
- new webpack.SourceMapDevToolPlugin({
507
- filename: "[file].map",
508
- include: [/js$/, /css$/],
509
- sourceRoot: "webpack:///",
510
- moduleFilenameTemplate: "[resource-path]",
511
- append: undefined
512
- })
513
- ] : [],
514
- {
515
- apply(compiler) {
516
- compiler.hooks.shutdown.tap("sass-worker", () => {
517
- nodeSass.close();
518
- });
519
- }
520
- },
521
- new MiniCssExtractPlugin({
522
- filename: "[name].css"
523
- }),
524
- ...watch ? [] : [
525
- new plugins_1.SuppressExtractedTextChunksWebpackPlugin()
526
- ],
527
- new webpack_1.AngularWebpackPlugin({
528
- tsconfig: this.tsconfigFilePath,
529
- compilerOptions: this.parsedTsconfig.options,
530
- jitMode: false,
531
- emitNgModuleScope: watch,
532
- inlineStyleFileExtension: "scss"
533
- }),
534
- new index_html_webpack_plugin_1.IndexHtmlWebpackPlugin({
535
- indexPath: path.resolve(this.rootPath, "src/index.html"),
536
- outputPath: "index.html",
537
- baseHref: publicPath,
538
- entrypoints: [
539
- "runtime",
540
- "polyfills",
541
- "sw-register",
542
- "styles",
543
- "vendor",
544
- "main"
545
- ],
546
- moduleEntrypoints: [],
547
- noModuleEntrypoints: [],
548
- deployUrl: undefined,
549
- sri: false,
550
- postTransform: undefined,
551
- optimization: {
552
- scripts: !watch,
553
- styles: { minify: !watch, inlineCritical: !watch },
554
- fonts: { inline: !watch }
555
- },
556
- WOFFSupportNeeded: false,
557
- crossOrigin: "none",
558
- lang: undefined
559
- }),
560
- new webpack.EnvironmentPlugin({
561
- SD_VERSION: this.npmConfig.version,
562
- ...this.config.env
563
- }),
564
- ...!this.skipProcesses.includes("lint") ? [
565
- new ESLintWebpackPlugin({
566
- context: this.rootPath,
567
- eslintPath: path.resolve(this.projectRootPath, "node_modules", "eslint"),
568
- extensions: ["js", "ts"],
569
- exclude: ["node_modules"],
570
- fix: false,
571
- threads: false,
572
- formatter: (results) => {
573
- const resultMessages = [];
574
- for (const result of results) {
575
- for (const msg of result.messages) {
576
- resultMessages.push(`${result.filePath}(${msg.line}, ${msg.column}): ${msg.ruleId ?? ""}: ${msg.severity === 1 ? "warning" : msg.severity === 2 ? "error" : ""} ${msg.message}`);
577
- }
578
- }
579
- return resultMessages.join(os.EOL);
580
- }
581
- })
582
- ] : [],
583
- ...watch ? [
584
- new webpack.HotModuleReplacementPlugin()
585
- ] : [],
586
- new webpack.ProgressPlugin({
587
- handler: (per, msg, ...args) => {
588
- const phaseText = msg ? ` - phase: ${msg}` : "";
589
- const argsText = args.length > 0 ? ` - args: [${args.join(", ")}]` : "";
590
- this._logger.debug(`Webpack 빌드 수행중...(${Math.round(per * 100)}%)${phaseText}${argsText}`);
591
- }
592
- })
593
- ],
594
- node: false,
595
- stats: "errors-warnings"
596
- };
597
- }
598
- _findAllInternalModuleCachePaths() {
599
- return this._findAllNodeModules(this.rootPath, this.projectRootPath)
600
- .mapMany((item) => (sd_core_node_1.FsUtil.readdir(item)
601
- .filter((item1) => item1 !== "@simplysm")
602
- .map((item1) => path.resolve(item, item1))));
603
- }
604
- _findAllNodeModules(from, root) {
605
- const nodeModules = [];
606
- let current = from;
607
- while (current) {
608
- const potential = path.join(current, "node_modules");
609
- if (sd_core_node_1.FsUtil.exists(potential) && sd_core_node_1.FsUtil.isDirectory(potential)) {
610
- nodeModules.push(potential);
611
- }
612
- if (current === root)
613
- break;
614
- const next = path.dirname(current);
615
- if (next === current)
616
- break;
617
- current = next;
618
- }
619
- return nodeModules;
620
- }
621
- async _runNgGenWorkerAsync(watch, changedFilePaths) {
622
- if (!this._ngGenWorker) {
623
- this._ngGenWorker = await sd_core_node_1.SdProcessWorker.createAsync(path.resolve(__dirname, `../workers/client-ng-gen-worker`), []);
624
- }
625
- const sender = this._ngGenWorker.createWorkSender();
626
- return await new Promise(async (resolve) => {
627
- await sender
628
- .on("complete", (result) => {
629
- resolve(result);
630
- })
631
- .sendAsync(this.rootPath, watch, changedFilePaths);
632
- });
633
- }
634
- }
635
- exports.SdCliNgClientBuilder = SdCliNgClientBuilder;
636
- //# sourceMappingURL=SdCliNgClientBuilder.js.map