@simplysm/sd-cli 12.13.21 → 12.13.35
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/dist/entry/{sd-cli-ai-command.js → SdCliAiCommand.js} +1 -1
- package/dist/entry/SdCliAiCommand.js.map +1 -0
- package/dist/entry/{sd-cli-cordova.d.ts → SdCliCordova.d.ts} +1 -1
- package/dist/entry/{sd-cli-cordova.js → SdCliCordova.js} +1 -1
- package/dist/entry/SdCliCordova.js.map +1 -0
- package/dist/entry/{sd-cli-electron.d.ts → SdCliElectron.d.ts} +1 -1
- package/dist/entry/{sd-cli-electron.js → SdCliElectron.js} +2 -2
- package/dist/entry/SdCliElectron.js.map +1 -0
- package/dist/entry/{sd-cli-local-update.js → SdCliLocalUpdate.js} +4 -4
- package/dist/entry/SdCliLocalUpdate.js.map +1 -0
- package/dist/entry/{sd-cli-postinstall.js → SdCliPostinstall.js} +1 -1
- package/dist/entry/SdCliPostinstall.js.map +1 -0
- package/dist/entry/{sd-cli-project.d.ts → SdCliProject.d.ts} +0 -1
- package/dist/entry/{sd-cli-project.js → SdCliProject.js} +41 -64
- package/dist/entry/SdCliProject.js.map +1 -0
- package/dist/fix/core/convert-symbol.js +22 -13
- package/dist/fix/core/convert-symbol.js.map +1 -1
- package/dist/fix/remove-unused-protected-readonly.js +7 -1
- package/dist/fix/remove-unused-protected-readonly.js.map +1 -1
- package/dist/pkg-builders/SdProjectBuildRunner.d.ts +18 -0
- package/dist/pkg-builders/SdProjectBuildRunner.js +235 -0
- package/dist/pkg-builders/SdProjectBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/{sd-cli-ng-routes.file-generator.js → SdCliNgRoutesFileGenerator.js} +1 -1
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +8 -0
- package/dist/pkg-builders/client/{sd-client.build-runner.js → SdClientBuildRunner.js} +27 -31
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/{sd-ng.bundler.d.ts → SdNgBundler.d.ts} +6 -10
- package/dist/pkg-builders/client/{sd-ng.bundler.js → SdNgBundler.js} +12 -11
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
- package/dist/pkg-builders/client/{sd-ng.bundler-context.d.ts → SdNgBundlerContext.d.ts} +1 -1
- package/dist/pkg-builders/client/{sd-ng.bundler-context.js → SdNgBundlerContext.js} +3 -4
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
- package/dist/pkg-builders/client/{sd-ng.plugin-creator.d.ts → createSdNgPlugin.d.ts} +4 -3
- package/dist/pkg-builders/client/{sd-ng.plugin-creator.js → createSdNgPlugin.js} +6 -86
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
- package/dist/pkg-builders/commons/{scope-path.d.ts → ScopePathSet.d.ts} +1 -1
- package/dist/pkg-builders/commons/{scope-path.js → ScopePathSet.js} +3 -3
- package/dist/pkg-builders/commons/ScopePathSet.js.map +1 -0
- package/dist/pkg-builders/commons/SdBuildRunnerBase.d.ts +20 -0
- package/dist/pkg-builders/commons/SdBuildRunnerBase.js +30 -0
- package/dist/pkg-builders/commons/SdBuildRunnerBase.js.map +1 -0
- package/dist/pkg-builders/lib/{sd-cli-db-context.file-generator.js → SdCliDbContextFileGenerator.js} +1 -1
- package/dist/pkg-builders/lib/SdCliDbContextFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/{sd-cli-index.file-generator.js → SdCliIndexFileGenerator.js} +1 -1
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +8 -0
- package/dist/pkg-builders/lib/{sd-js-lib.build-runner.js → SdJsLibBuildRunner.js} +11 -16
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +8 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +36 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +9 -0
- package/dist/pkg-builders/lib/{sd-ts-lib.builder.js → SdTsLibBuilder.js} +8 -8
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +8 -0
- package/dist/pkg-builders/server/{sd-server.build-runner.js → SdServerBuildRunner.js} +30 -45
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBundler.d.ts +18 -0
- package/dist/pkg-builders/server/{sd-server.bundler.js → SdServerBundler.js} +11 -11
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
- package/dist/pkg-builders/server/{sd-server.plugin-creator.d.ts → createSdServerPlugin.d.ts} +4 -3
- package/dist/pkg-builders/server/{sd-server.plugin-creator.js → createSdServerPlugin.js} +5 -4
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
- package/dist/sd-cli-entry.js +6 -12
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +1 -13
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-compiler/{sd-dependency-analyzer.d.ts → SdDepAnalyzer.d.ts} +5 -5
- package/dist/ts-compiler/{sd-dependency-analyzer.js → SdDepAnalyzer.js} +2 -4
- package/dist/ts-compiler/SdDepAnalyzer.js.map +1 -0
- package/dist/ts-compiler/{sd-dependency-cache.d.ts → SdDepCache.d.ts} +1 -11
- package/dist/ts-compiler/{sd-dependency-cache.js → SdDepCache.js} +2 -65
- package/dist/ts-compiler/SdDepCache.js.map +1 -0
- package/dist/ts-compiler/{sd-style-bundler.d.ts → SdStyleBundler.d.ts} +4 -4
- package/dist/ts-compiler/{sd-style-bundler.js → SdStyleBundler.js} +5 -5
- package/dist/ts-compiler/SdStyleBundler.js.map +1 -0
- package/dist/ts-compiler/{sd-ts-compiler.d.ts → SdTsCompiler.d.ts} +3 -2
- package/dist/ts-compiler/{sd-ts-compiler.js → SdTsCompiler.js} +33 -148
- package/dist/ts-compiler/SdTsCompiler.js.map +1 -0
- package/dist/types/{build.types.d.ts → build/ISdBuildMessage.d.ts} +0 -5
- package/dist/types/build/ISdBuildMessage.js +2 -0
- package/dist/types/build/ISdBuildMessage.js.map +1 -0
- package/dist/types/build/ISdBuildResult.d.ts +8 -0
- package/dist/types/build/ISdBuildResult.js +2 -0
- package/dist/types/build/ISdBuildResult.js.map +1 -0
- package/dist/types/build/ISdTsCompilerOptions.d.ts +13 -0
- package/dist/types/build/ISdTsCompilerOptions.js +2 -0
- package/dist/types/build/ISdTsCompilerOptions.js.map +1 -0
- package/dist/types/build/ISdTsCompilerResult.d.ts +14 -0
- package/dist/types/build/ISdTsCompilerResult.js +2 -0
- package/dist/types/build/ISdTsCompilerResult.js.map +1 -0
- package/dist/types/build/TStylesheetBundlingResult.d.ts +12 -0
- package/dist/types/build/TStylesheetBundlingResult.js +2 -0
- package/dist/types/build/TStylesheetBundlingResult.js.map +1 -0
- package/dist/types/{common-configs.types.d.ts → common-config/INpmConfig.d.ts} +0 -7
- package/dist/types/common-config/INpmConfig.js +2 -0
- package/dist/types/common-config/INpmConfig.js.map +1 -0
- package/dist/types/common-config/ITsConfig.d.ts +7 -0
- package/dist/types/common-config/ITsConfig.js +2 -0
- package/dist/types/common-config/ITsConfig.js.map +1 -0
- package/dist/types/{config.types.d.ts → config/ISdProjectConfig.d.ts} +0 -1
- package/dist/types/config/ISdProjectConfig.js +2 -0
- package/dist/types/config/ISdProjectConfig.js.map +1 -0
- package/dist/types/plugin/ISdCliNgPluginResultCache.d.ts +8 -0
- package/dist/types/plugin/ISdCliNgPluginResultCache.js +2 -0
- package/dist/types/plugin/ISdCliNgPluginResultCache.js.map +1 -0
- package/dist/types/{build-plugin.types.d.ts → plugin/ISdCliServerPluginResultCache.d.ts} +0 -6
- package/dist/types/plugin/ISdCliServerPluginResultCache.js +2 -0
- package/dist/types/plugin/ISdCliServerPluginResultCache.js.map +1 -0
- package/dist/types/worker/ISdBuildRunnerWorkerType.d.ts +23 -0
- package/dist/types/worker/ISdBuildRunnerWorkerType.js +2 -0
- package/dist/types/worker/ISdBuildRunnerWorkerType.js.map +1 -0
- package/dist/types/worker/IServerWorkerType.d.ts +17 -0
- package/dist/types/worker/IServerWorkerType.js +2 -0
- package/dist/types/worker/IServerWorkerType.js.map +1 -0
- package/dist/utils/{sd-cli-convert-message.utils.d.ts → SdCliConvertMessageUtils.d.ts} +1 -1
- package/dist/utils/{sd-cli-convert-message.utils.js → SdCliConvertMessageUtils.js} +4 -2
- package/dist/utils/SdCliConvertMessageUtils.js.map +1 -0
- package/dist/utils/{sd-cli-performance-time.js → SdCliPerformanceTimer.js} +1 -1
- package/dist/utils/SdCliPerformanceTimer.js.map +1 -0
- package/dist/{entry/utils → utils}/loadProjConfAsync.d.ts +1 -1
- package/dist/utils/loadProjConfAsync.js.map +1 -0
- package/dist/workers/build-runner.worker.js +13 -23
- package/dist/workers/build-runner.worker.js.map +1 -1
- package/dist/workers/server.worker.js +4 -4
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +12 -12
- package/src/entry/{sd-cli-cordova.ts → SdCliCordova.ts} +2 -2
- package/src/entry/{sd-cli-electron.ts → SdCliElectron.ts} +3 -3
- package/src/entry/{sd-cli-local-update.ts → SdCliLocalUpdate.ts} +6 -4
- package/src/entry/{sd-cli-project.ts → SdCliProject.ts} +55 -71
- package/src/fix/core/convert-symbol.ts +35 -16
- package/src/fix/remove-unused-protected-readonly.ts +7 -1
- package/src/pkg-builders/SdProjectBuildRunner.ts +354 -0
- package/src/pkg-builders/client/{sd-client.build-runner.ts → SdClientBuildRunner.ts} +31 -38
- package/src/pkg-builders/client/{sd-ng.bundler.ts → SdNgBundler.ts} +22 -31
- package/src/pkg-builders/client/{sd-ng.bundler-context.ts → SdNgBundlerContext.ts} +7 -9
- package/src/pkg-builders/client/{sd-ng.plugin-creator.ts → createSdNgPlugin.ts} +11 -94
- package/src/pkg-builders/commons/{scope-path.ts → ScopePathSet.ts} +3 -3
- package/src/pkg-builders/commons/SdBuildRunnerBase.ts +47 -0
- package/src/pkg-builders/lib/{sd-cli-db-context.file-generator.ts → SdCliDbContextFileGenerator.ts} +1 -1
- package/src/pkg-builders/lib/{sd-js-lib.build-runner.ts → SdJsLibBuildRunner.ts} +13 -32
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +47 -0
- package/src/pkg-builders/lib/{sd-ts-lib.builder.ts → SdTsLibBuilder.ts} +12 -15
- package/src/pkg-builders/server/{sd-server.build-runner.ts → SdServerBuildRunner.ts} +25 -48
- package/src/pkg-builders/server/{sd-server.bundler.ts → SdServerBundler.ts} +26 -23
- package/src/pkg-builders/server/{sd-server.plugin-creator.ts → createSdServerPlugin.ts} +9 -7
- package/src/sd-cli-entry.ts +6 -12
- package/src/sd-cli.ts +1 -15
- package/src/ts-compiler/{sd-dependency-analyzer.ts → SdDepAnalyzer.ts} +5 -9
- package/src/ts-compiler/{sd-dependency-cache.ts → SdDepCache.ts} +1 -137
- package/src/ts-compiler/{sd-style-bundler.ts → SdStyleBundler.ts} +5 -5
- package/src/ts-compiler/{sd-ts-compiler.ts → SdTsCompiler.ts} +43 -175
- package/src/types/{build.types.ts → build/ISdBuildMessage.ts} +0 -6
- package/src/types/build/ISdBuildResult.ts +9 -0
- package/src/types/build/ISdTsCompilerOptions.ts +14 -0
- package/src/types/build/ISdTsCompilerResult.ts +12 -0
- package/src/types/build/TStylesheetBundlingResult.ts +15 -0
- package/src/types/{common-configs.types.ts → common-config/INpmConfig.ts} +0 -6
- package/src/types/common-config/ITsConfig.ts +5 -0
- package/src/types/{config.types.ts → config/ISdProjectConfig.ts} +0 -1
- package/src/types/plugin/ISdCliNgPluginResultCache.ts +9 -0
- package/src/types/{build-plugin.types.ts → plugin/ISdCliServerPluginResultCache.ts} +0 -7
- package/src/types/worker/ISdBuildRunnerWorkerType.ts +24 -0
- package/src/types/worker/IServerWorkerType.ts +8 -0
- package/src/utils/{sd-cli-convert-message.utils.ts → SdCliConvertMessageUtils.ts} +6 -3
- package/src/{entry/utils → utils}/loadProjConfAsync.ts +10 -6
- package/src/workers/build-runner.worker.ts +30 -29
- package/src/workers/server.worker.ts +7 -7
- package/tests/deps/sd-dependency-analyzer.spec.ts +38 -69
- package/tests/deps/sd-dependency-cache.spec.ts +3 -6
- package/dist/entry/sd-cli-ai-command.js.map +0 -1
- package/dist/entry/sd-cli-cordova.js.map +0 -1
- package/dist/entry/sd-cli-electron.js.map +0 -1
- package/dist/entry/sd-cli-local-update.js.map +0 -1
- package/dist/entry/sd-cli-postinstall.js.map +0 -1
- package/dist/entry/sd-cli-project.js.map +0 -1
- package/dist/entry/utils/loadProjConfAsync.js.map +0 -1
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +0 -1
- package/dist/pkg-builders/client/sd-client.build-runner.d.ts +0 -7
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +0 -1
- package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +0 -1
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +0 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +0 -1
- package/dist/pkg-builders/commons/build-runner.base.d.ts +0 -29
- package/dist/pkg-builders/commons/build-runner.base.js +0 -114
- package/dist/pkg-builders/commons/build-runner.base.js.map +0 -1
- package/dist/pkg-builders/commons/scope-path.js.map +0 -1
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js.map +0 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +0 -1
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.d.ts +0 -8
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +0 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +0 -7
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +0 -41
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +0 -1
- package/dist/pkg-builders/lib/sd-ts-lib.builder.d.ts +0 -14
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +0 -1
- package/dist/pkg-builders/sd-multi.build-runner.d.ts +0 -14
- package/dist/pkg-builders/sd-multi.build-runner.js +0 -228
- package/dist/pkg-builders/sd-multi.build-runner.js.map +0 -1
- package/dist/pkg-builders/server/sd-server.build-runner.d.ts +0 -7
- package/dist/pkg-builders/server/sd-server.build-runner.js.map +0 -1
- package/dist/pkg-builders/server/sd-server.bundler.d.ts +0 -22
- package/dist/pkg-builders/server/sd-server.bundler.js.map +0 -1
- package/dist/pkg-builders/server/sd-server.plugin-creator.js.map +0 -1
- package/dist/ts-compiler/sd-dependency-analyzer.js.map +0 -1
- package/dist/ts-compiler/sd-dependency-cache.js.map +0 -1
- package/dist/ts-compiler/sd-style-bundler.js.map +0 -1
- package/dist/ts-compiler/sd-ts-compiler.js.map +0 -1
- package/dist/types/build-plugin.types.js +0 -2
- package/dist/types/build-plugin.types.js.map +0 -1
- package/dist/types/build-runner.types.d.ts +0 -10
- package/dist/types/build-runner.types.js +0 -2
- package/dist/types/build-runner.types.js.map +0 -1
- package/dist/types/build.types.js +0 -2
- package/dist/types/build.types.js.map +0 -1
- package/dist/types/common-configs.types.js +0 -2
- package/dist/types/common-configs.types.js.map +0 -1
- package/dist/types/config.types.js +0 -2
- package/dist/types/config.types.js.map +0 -1
- package/dist/types/ts-compiler.types.d.ts +0 -37
- package/dist/types/ts-compiler.types.js +0 -2
- package/dist/types/ts-compiler.types.js.map +0 -1
- package/dist/types/worker.types.d.ts +0 -67
- package/dist/types/worker.types.js +0 -2
- package/dist/types/worker.types.js.map +0 -1
- package/dist/utils/sd-cli-convert-message.utils.js.map +0 -1
- package/dist/utils/sd-cli-performance-time.js.map +0 -1
- package/src/pkg-builders/commons/build-runner.base.ts +0 -184
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +0 -57
- package/src/pkg-builders/sd-multi.build-runner.ts +0 -304
- package/src/types/build-runner.types.ts +0 -11
- package/src/types/ts-compiler.types.ts +0 -43
- package/src/types/worker.types.ts +0 -51
- /package/dist/entry/{sd-cli-ai-command.d.ts → SdCliAiCommand.d.ts} +0 -0
- /package/dist/entry/{sd-cli-local-update.d.ts → SdCliLocalUpdate.d.ts} +0 -0
- /package/dist/entry/{sd-cli-postinstall.d.ts → SdCliPostinstall.d.ts} +0 -0
- /package/dist/pkg-builders/client/{sd-cli-ng-routes.file-generator.d.ts → SdCliNgRoutesFileGenerator.d.ts} +0 -0
- /package/dist/pkg-builders/lib/{sd-cli-db-context.file-generator.d.ts → SdCliDbContextFileGenerator.d.ts} +0 -0
- /package/dist/pkg-builders/lib/{sd-cli-index.file-generator.d.ts → SdCliIndexFileGenerator.d.ts} +0 -0
- /package/dist/utils/{sd-cli-performance-time.d.ts → SdCliPerformanceTimer.d.ts} +0 -0
- /package/dist/{entry/utils → utils}/loadProjConfAsync.js +0 -0
- /package/src/entry/{sd-cli-ai-command.ts → SdCliAiCommand.ts} +0 -0
- /package/src/entry/{sd-cli-postinstall.ts → SdCliPostinstall.ts} +0 -0
- /package/src/pkg-builders/client/{sd-cli-ng-routes.file-generator.ts → SdCliNgRoutesFileGenerator.ts} +0 -0
- /package/src/pkg-builders/lib/{sd-cli-index.file-generator.ts → SdCliIndexFileGenerator.ts} +0 -0
- /package/src/utils/{sd-cli-performance-time.ts → SdCliPerformanceTimer.ts} +0 -0
|
@@ -3,21 +3,22 @@ import path from "path";
|
|
|
3
3
|
import os from "os";
|
|
4
4
|
import { JavaScriptTransformer } from "@angular/build/src/tools/esbuild/javascript-transformer";
|
|
5
5
|
import { FsUtils, PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
6
|
-
import { SdCliPerformanceTimer } from "../../utils/
|
|
7
|
-
import { SdCliConvertMessageUtils } from "../../utils/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTimer";
|
|
7
|
+
import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
|
|
8
|
+
import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
|
|
9
|
+
import { ScopePathSet } from "../commons/ScopePathSet";
|
|
10
|
+
import { ISdCliNgPluginResultCache } from "../../types/plugin/ISdCliNgPluginResultCache";
|
|
11
|
+
import { ISdTsCompilerResult } from "../../types/build/ISdTsCompilerResult";
|
|
12
12
|
|
|
13
13
|
export function createSdNgPlugin(conf: {
|
|
14
14
|
pkgPath: TNormPath;
|
|
15
|
+
watch: boolean;
|
|
15
16
|
dev: boolean;
|
|
16
17
|
emitOnly: boolean;
|
|
17
18
|
noEmit: boolean;
|
|
18
19
|
modifiedFileSet: Set<TNormPath>;
|
|
19
20
|
result: ISdCliNgPluginResultCache;
|
|
20
|
-
|
|
21
|
+
scopePathSet: ScopePathSet;
|
|
21
22
|
}): esbuild.Plugin {
|
|
22
23
|
let perf: SdCliPerformanceTimer;
|
|
23
24
|
const logger = SdLogger.get(["simplysm", "sd-cli", "createSdNgPlugin"]);
|
|
@@ -32,11 +33,12 @@ export function createSdNgPlugin(conf: {
|
|
|
32
33
|
const tsCompiler = new SdTsCompiler({
|
|
33
34
|
pkgPath: conf.pkgPath,
|
|
34
35
|
additionalOptions: { declaration: false },
|
|
36
|
+
isWatchMode: conf.watch,
|
|
35
37
|
isDevMode: conf.dev,
|
|
36
38
|
isForBundle: true,
|
|
37
39
|
isEmitOnly: conf.emitOnly,
|
|
38
40
|
isNoEmit: conf.noEmit,
|
|
39
|
-
|
|
41
|
+
scopePathSet: conf.scopePathSet,
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
let tsCompileResult: ISdTsCompilerResult;
|
|
@@ -53,8 +55,6 @@ export function createSdNgPlugin(conf: {
|
|
|
53
55
|
Math.floor((os.cpus().length * 2) / 3),
|
|
54
56
|
);
|
|
55
57
|
|
|
56
|
-
// let cssStore = new Map<TNormPath, Buffer>();
|
|
57
|
-
|
|
58
58
|
//---------------------------
|
|
59
59
|
|
|
60
60
|
build.onStart(async () => {
|
|
@@ -67,8 +67,6 @@ export function createSdNgPlugin(conf: {
|
|
|
67
67
|
|
|
68
68
|
tsCompileResult = await tsCompiler.compileAsync(conf.modifiedFileSet);
|
|
69
69
|
|
|
70
|
-
// cssStore.clear();
|
|
71
|
-
|
|
72
70
|
conf.result.watchFileSet = tsCompileResult.watchFileSet;
|
|
73
71
|
conf.result.affectedFileSet = tsCompileResult.affectedFileSet;
|
|
74
72
|
|
|
@@ -76,6 +74,7 @@ export function createSdNgPlugin(conf: {
|
|
|
76
74
|
tsCompileResult.messages,
|
|
77
75
|
conf.pkgPath,
|
|
78
76
|
);
|
|
77
|
+
|
|
79
78
|
//-- return err/warn
|
|
80
79
|
return {
|
|
81
80
|
errors: [
|
|
@@ -97,83 +96,9 @@ export function createSdNgPlugin(conf: {
|
|
|
97
96
|
return res;
|
|
98
97
|
});
|
|
99
98
|
|
|
100
|
-
/*build.onResolve({ filter: /\.css$/ }, (args) => {
|
|
101
|
-
if (args.path.startsWith("sd-css-asset:")) return;
|
|
102
|
-
return {
|
|
103
|
-
path: path.resolve(args.resolveDir, args.path),
|
|
104
|
-
namespace: "sd-css",
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
build.onLoad({ filter: /\.css$/, namespace: "sd-css" }, async (args) => {
|
|
109
|
-
const code = /!* language=javascript *!/ `
|
|
110
|
-
import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
111
|
-
(function __sdEnsureStyle(href) {
|
|
112
|
-
let link = document.querySelector('link[data-sd-style="' + href + '"]');
|
|
113
|
-
if (link) return;
|
|
114
|
-
link = document.createElement('link');
|
|
115
|
-
link.rel = 'stylesheet';
|
|
116
|
-
link.setAttribute('data-sd-style', href);
|
|
117
|
-
link.href = href;
|
|
118
|
-
document.head.appendChild(link);
|
|
119
|
-
})(href);`;
|
|
120
|
-
|
|
121
|
-
if (FsUtils.exists(args.path)) {
|
|
122
|
-
const css = await FsUtils.readFileBufferAsync(args.path);
|
|
123
|
-
cssStore.set(PathUtils.norm(args.path), css);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return { contents: code, loader: "js", resolveDir: path.dirname(args.path) };
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
build.onResolve({ filter: /^sd-css-asset:/ }, (args) => {
|
|
130
|
-
const real = args.path.replace(/^sd-css-asset:/, "");
|
|
131
|
-
return { path: real, namespace: "sd-css-asset" };
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
build.onLoad({ filter: /\.css$/, namespace: "sd-css-asset" }, (args) => {
|
|
135
|
-
const cssContent =
|
|
136
|
-
cssStore.get(PathUtils.norm(args.path)) ??
|
|
137
|
-
cssStore.get(PathUtils.norm(args.path.replace(/[\\\/]src[\\\/]/, "\\dist\\")));
|
|
138
|
-
if (cssContent == null) {
|
|
139
|
-
return {
|
|
140
|
-
errors: [
|
|
141
|
-
{
|
|
142
|
-
location: null,
|
|
143
|
-
text: `Missing CSS for ${PathUtils.norm(args.path)}`,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
contents: cssContent,
|
|
151
|
-
loader: "file",
|
|
152
|
-
resolveDir: path.dirname(args.path),
|
|
153
|
-
};
|
|
154
|
-
});*/
|
|
155
|
-
|
|
156
99
|
build.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
157
100
|
const emittedFiles = tsCompileResult.emittedFilesCacheMap.get(PathUtils.norm(args.path));
|
|
158
101
|
|
|
159
|
-
/*try {
|
|
160
|
-
const css = emittedFiles?.single((item) => Boolean(item.outAbsPath?.endsWith(".css")));
|
|
161
|
-
if (css) {
|
|
162
|
-
cssStore.set(PathUtils.norm(css.outAbsPath!), Buffer.from(css.text));
|
|
163
|
-
}
|
|
164
|
-
} catch (err) {
|
|
165
|
-
return {
|
|
166
|
-
errors: [
|
|
167
|
-
{
|
|
168
|
-
text:
|
|
169
|
-
(err?.message ?? String(err)) +
|
|
170
|
-
"\n" +
|
|
171
|
-
emittedFiles?.map((item) => "- " + item.outAbsPath).join("\n"),
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
};
|
|
175
|
-
}*/
|
|
176
|
-
|
|
177
102
|
const output = outputContentsCacheMap.get(PathUtils.norm(args.path));
|
|
178
103
|
if (output != null) {
|
|
179
104
|
return { contents: output, loader: "js" };
|
|
@@ -210,10 +135,6 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
210
135
|
|
|
211
136
|
try {
|
|
212
137
|
const newContents = await perf.run("esbuild transform:js:*.js", async () => {
|
|
213
|
-
/*return /\.min\.[cm]?js$/.test(args.path)
|
|
214
|
-
? await FsUtils.readFileBufferAsync(args.path)
|
|
215
|
-
: await javascriptTransformer.transformFile(args.path, false, sideEffects);*/
|
|
216
|
-
|
|
217
138
|
const contents = await FsUtils.readFileBufferAsync(args.path);
|
|
218
139
|
|
|
219
140
|
return await javascriptTransformer.transformData(
|
|
@@ -232,10 +153,6 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
232
153
|
};
|
|
233
154
|
} catch (err) {
|
|
234
155
|
return { errors: [{ text: err?.message ?? String(err) }] };
|
|
235
|
-
/*return {
|
|
236
|
-
contents: `console.error(${JSON.stringify(err.message)});`,
|
|
237
|
-
loader: "js",
|
|
238
|
-
};*/
|
|
239
156
|
}
|
|
240
157
|
});
|
|
241
158
|
|
|
@@ -3,8 +3,8 @@ import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
|
3
3
|
export class ScopePathSet {
|
|
4
4
|
#data: Set<TNormPath>;
|
|
5
5
|
|
|
6
|
-
constructor(
|
|
7
|
-
this.#data = new Set(
|
|
6
|
+
constructor(arrOrSet?: TNormPath[] | Set<TNormPath>) {
|
|
7
|
+
this.#data = arrOrSet instanceof Set ? arrOrSet : new Set(arrOrSet);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
inScope(filePath: string) {
|
|
@@ -14,4 +14,4 @@ export class ScopePathSet {
|
|
|
14
14
|
toArray() {
|
|
15
15
|
return Array.from(this.#data);
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FsUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { ISdProjectConfig, TSdPackageConfig } from "../../types/config/ISdProjectConfig";
|
|
4
|
+
import { ScopePathSet } from "./ScopePathSet";
|
|
5
|
+
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
6
|
+
|
|
7
|
+
export abstract class SdBuildRunnerBase<T extends "server" | "library" | "client"> {
|
|
8
|
+
protected abstract _logger: SdLogger;
|
|
9
|
+
|
|
10
|
+
protected _pkgName: string;
|
|
11
|
+
protected _pkgConf: TSdPackageConfig<T>;
|
|
12
|
+
|
|
13
|
+
protected _scopePathSet: ScopePathSet;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
protected _pkgPath: TNormPath,
|
|
17
|
+
protected _projConf: ISdProjectConfig,
|
|
18
|
+
scopePathSet: Set<TNormPath>,
|
|
19
|
+
protected _watch: boolean,
|
|
20
|
+
protected _dev: boolean,
|
|
21
|
+
protected _emitOnly?: boolean,
|
|
22
|
+
protected _noEmit?: boolean,
|
|
23
|
+
) {
|
|
24
|
+
this._pkgName = path.basename(_pkgPath);
|
|
25
|
+
this._pkgConf = _projConf.packages[this._pkgName] as TSdPackageConfig<T>;
|
|
26
|
+
|
|
27
|
+
this._scopePathSet = new ScopePathSet(scopePathSet);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async rebuildAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
31
|
+
if (!modifiedFileSet && !this._noEmit) {
|
|
32
|
+
const distPath = path.resolve(this._pkgPath, "dist");
|
|
33
|
+
if (FsUtils.exists(distPath)) {
|
|
34
|
+
this._debug("dist 초기화...");
|
|
35
|
+
FsUtils.remove(distPath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return await this._runAsync(modifiedFileSet);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected abstract _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult>;
|
|
43
|
+
|
|
44
|
+
protected _debug(msg: string): void {
|
|
45
|
+
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/pkg-builders/lib/{sd-cli-db-context.file-generator.ts → SdCliDbContextFileGenerator.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FsUtils, HashUtils, PathUtils, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { StringUtils } from "@simplysm/sd-core-common";
|
|
4
|
-
import { INpmConfig } from "../../types/common-
|
|
4
|
+
import { INpmConfig } from "../../types/common-config/INpmConfig";
|
|
5
5
|
|
|
6
6
|
export class SdCliDbContextFileGenerator {
|
|
7
7
|
cachedHash?: string;
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FsUtils,
|
|
3
|
-
ISdFsWatcherChangeInfo,
|
|
4
|
-
PathUtils,
|
|
5
|
-
SdLogger,
|
|
6
|
-
TNormPath,
|
|
7
|
-
} from "@simplysm/sd-core-node";
|
|
1
|
+
import { FsUtils, PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
8
2
|
import path from "path";
|
|
9
|
-
import { SdCliConvertMessageUtils } from "../../utils/sd-cli-convert-message.utils";
|
|
10
|
-
// import { TSdLintWorkerType } from "../../types/workers.type";
|
|
11
3
|
import { ESLint } from "eslint";
|
|
12
|
-
import {
|
|
4
|
+
import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
|
|
5
|
+
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
6
|
+
import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
|
|
13
7
|
|
|
14
|
-
export class SdJsLibBuildRunner extends
|
|
8
|
+
export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
|
|
15
9
|
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdJsLibBuildRunner"]);
|
|
16
10
|
|
|
17
|
-
protected override async _runAsync(
|
|
18
|
-
|
|
19
|
-
emitOnly: boolean,
|
|
20
|
-
noEmit: boolean,
|
|
21
|
-
modifiedFileSet?: Set<TNormPath>,
|
|
22
|
-
): Promise<IBuildRunnerRunResult> {
|
|
23
|
-
if (emitOnly) {
|
|
11
|
+
protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
12
|
+
if (this._emitOnly) {
|
|
24
13
|
return {
|
|
25
|
-
affectedFileSet: new Set(),
|
|
26
14
|
buildMessages: [],
|
|
15
|
+
|
|
16
|
+
watchFileSet: new Set(),
|
|
17
|
+
affectedFileSet: new Set(),
|
|
27
18
|
emitFileSet: new Set(),
|
|
28
19
|
};
|
|
29
20
|
}
|
|
@@ -44,24 +35,14 @@ export class SdJsLibBuildRunner extends BuildRunnerBase<"library"> {
|
|
|
44
35
|
this._debug(`LINT 완료`);
|
|
45
36
|
|
|
46
37
|
return {
|
|
47
|
-
affectedFileSet: filePathSet,
|
|
48
38
|
buildMessages: messages,
|
|
39
|
+
|
|
40
|
+
watchFileSet: filePathSet,
|
|
41
|
+
affectedFileSet: filePathSet,
|
|
49
42
|
emitFileSet: new Set(),
|
|
50
43
|
};
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
protected override _getModifiedFileSet(changeInfos: ISdFsWatcherChangeInfo[]) {
|
|
54
|
-
return new Set(
|
|
55
|
-
changeInfos
|
|
56
|
-
.filter(
|
|
57
|
-
(item) =>
|
|
58
|
-
FsUtils.exists(item.path) &&
|
|
59
|
-
PathUtils.isChildPath(item.path, path.resolve(this._pkgPath, "src")),
|
|
60
|
-
)
|
|
61
|
-
.map((item) => item.path),
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
46
|
async #lintAsync(fileSet: Set<string>) {
|
|
66
47
|
const lintFilePaths = Array.from(fileSet)
|
|
67
48
|
.filter((item) => PathUtils.isChildPath(item, path.resolve(this._pkgPath, "src")))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
2
|
+
import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
|
|
3
|
+
import { SdTsLibBuilder } from "./SdTsLibBuilder";
|
|
4
|
+
import { SdCliIndexFileGenerator } from "./SdCliIndexFileGenerator";
|
|
5
|
+
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
6
|
+
import { SdCliDbContextFileGenerator } from "./SdCliDbContextFileGenerator";
|
|
7
|
+
|
|
8
|
+
export class SdTsLibBuildRunner extends SdBuildRunnerBase<"library"> {
|
|
9
|
+
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdTsLibBuildRunner"]);
|
|
10
|
+
|
|
11
|
+
#builder?: SdTsLibBuilder;
|
|
12
|
+
|
|
13
|
+
protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
14
|
+
// 최초한번
|
|
15
|
+
if (!modifiedFileSet) {
|
|
16
|
+
if (!this._noEmit) {
|
|
17
|
+
// index
|
|
18
|
+
if (!this._pkgConf.noGenIndex) {
|
|
19
|
+
this._debug("GEN index.ts...");
|
|
20
|
+
new SdCliIndexFileGenerator().watch(this._pkgPath, this._pkgConf.polyfills);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// db-context
|
|
24
|
+
if (this._pkgConf.dbContext != null) {
|
|
25
|
+
this._debug(`GEN ${this._pkgConf.dbContext}.ts...`);
|
|
26
|
+
new SdCliDbContextFileGenerator().watch(this._pkgPath, this._pkgConf.dbContext);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this._debug(`BUILD 준비...`);
|
|
31
|
+
this.#builder = new SdTsLibBuilder(
|
|
32
|
+
PathUtils.norm(this._pkgPath),
|
|
33
|
+
this._watch,
|
|
34
|
+
this._dev,
|
|
35
|
+
this._emitOnly ?? false,
|
|
36
|
+
this._noEmit ?? false,
|
|
37
|
+
this._scopePathSet,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this._debug(`BUILD...`);
|
|
42
|
+
const buildResult = await this.#builder!.buildAsync(modifiedFileSet);
|
|
43
|
+
|
|
44
|
+
this._debug(`빌드 완료`);
|
|
45
|
+
return buildResult;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { SdCliConvertMessageUtils } from "../../utils/
|
|
2
|
+
import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
|
|
3
3
|
import { FsUtils, HashUtils, PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
|
|
5
|
+
import { ScopePathSet } from "../commons/ScopePathSet";
|
|
6
|
+
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
7
7
|
|
|
8
8
|
export class SdTsLibBuilder {
|
|
9
9
|
#tsCompiler: SdTsCompiler;
|
|
@@ -11,30 +11,26 @@ export class SdTsLibBuilder {
|
|
|
11
11
|
|
|
12
12
|
constructor(
|
|
13
13
|
private readonly _pkgPath: TNormPath,
|
|
14
|
+
watch: boolean,
|
|
14
15
|
dev: boolean,
|
|
15
16
|
emitOnly: boolean,
|
|
16
17
|
noEmit: boolean,
|
|
17
|
-
|
|
18
|
+
scopePathSet: ScopePathSet,
|
|
18
19
|
) {
|
|
19
20
|
this.#tsCompiler = new SdTsCompiler({
|
|
20
21
|
pkgPath: this._pkgPath,
|
|
21
22
|
additionalOptions: { declaration: true },
|
|
23
|
+
isWatchMode: watch,
|
|
22
24
|
isDevMode: dev,
|
|
23
25
|
isEmitOnly: emitOnly,
|
|
24
26
|
isNoEmit: noEmit,
|
|
25
|
-
globalStyleFilePath: PathUtils.norm(this._pkgPath, "src/styles.scss"),
|
|
26
27
|
isForBundle: false,
|
|
27
|
-
|
|
28
|
+
scopePathSet,
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
async buildAsync(modifiedFileSet
|
|
32
|
-
|
|
33
|
-
affectedFileSet: Set<TNormPath>;
|
|
34
|
-
results: ISdBuildMessage[];
|
|
35
|
-
emitFileSet: Set<TNormPath>;
|
|
36
|
-
}> {
|
|
37
|
-
const tsCompileResult = await this.#tsCompiler.compileAsync(modifiedFileSet);
|
|
32
|
+
async buildAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
33
|
+
const tsCompileResult = await this.#tsCompiler.compileAsync(modifiedFileSet ?? new Set());
|
|
38
34
|
|
|
39
35
|
const emitFileSet = new Set<TNormPath>();
|
|
40
36
|
for (const emitFile of tsCompileResult.emitFileSet) {
|
|
@@ -81,9 +77,10 @@ export class SdTsLibBuilder {
|
|
|
81
77
|
);
|
|
82
78
|
|
|
83
79
|
return {
|
|
80
|
+
buildMessages: [...tsCompileResult.messages, ...styleResults],
|
|
81
|
+
|
|
84
82
|
watchFileSet: tsCompileResult.watchFileSet,
|
|
85
83
|
affectedFileSet: tsCompileResult.affectedFileSet,
|
|
86
|
-
results: [...tsCompileResult.messages, ...styleResults],
|
|
87
84
|
emitFileSet,
|
|
88
85
|
};
|
|
89
86
|
}
|
|
@@ -1,47 +1,40 @@
|
|
|
1
1
|
import { FsUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { javascript, StringUtils } from "@simplysm/sd-core-common";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
|
|
5
|
+
import { SdServerBundler } from "./SdServerBundler";
|
|
6
|
+
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
7
|
+
import { ITsConfig } from "../../types/common-config/ITsConfig";
|
|
8
|
+
import { INpmConfig } from "../../types/common-config/INpmConfig";
|
|
7
9
|
|
|
8
|
-
export class SdServerBuildRunner extends
|
|
9
|
-
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "
|
|
10
|
+
export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
|
|
11
|
+
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBuild2Runner"]);
|
|
10
12
|
|
|
11
13
|
#serverBundler?: SdServerBundler;
|
|
12
14
|
#extModules?: { name: string; exists: boolean }[];
|
|
13
15
|
|
|
14
|
-
protected override async _runAsync(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
noEmit: boolean,
|
|
18
|
-
modifiedFileSet?: Set<TNormPath>,
|
|
19
|
-
): Promise<IBuildRunnerRunResult> {
|
|
20
|
-
if (!dev) {
|
|
16
|
+
protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
17
|
+
// prod일때 각종 파일들 생성
|
|
18
|
+
if (!this._dev) {
|
|
21
19
|
await this.#generateProductionFilesAsync();
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
// 최초
|
|
23
|
+
if (!modifiedFileSet) {
|
|
24
|
+
if (!this._noEmit) {
|
|
26
25
|
this._debug("GEN .config...");
|
|
27
26
|
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
28
27
|
FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
29
28
|
}
|
|
30
|
-
}
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
FsUtils.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.#serverBundler ??
|
|
41
|
-
new SdServerBundler({
|
|
42
|
-
dev,
|
|
43
|
-
emitOnly,
|
|
44
|
-
noEmit,
|
|
30
|
+
this._debug(`BUILD 준비...`);
|
|
31
|
+
const tsConfig = FsUtils.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
32
|
+
this.#extModules = this.#extModules ?? (await this.#getExternalModulesAsync());
|
|
33
|
+
this.#serverBundler = new SdServerBundler({
|
|
34
|
+
watch: this._watch,
|
|
35
|
+
dev: this._dev,
|
|
36
|
+
emitOnly: this._emitOnly ?? false,
|
|
37
|
+
noEmit: this._noEmit ?? false,
|
|
45
38
|
pkgPath: this._pkgPath,
|
|
46
39
|
entryPoints: tsConfig.files
|
|
47
40
|
? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
|
|
@@ -50,24 +43,15 @@ export class SdServerBuildRunner extends BuildRunnerBase<"server"> {
|
|
|
50
43
|
...FsUtils.glob(path.resolve(this._pkgPath, "src/workers/*.ts")),
|
|
51
44
|
],
|
|
52
45
|
external: this.#extModules.map((item) => item.name),
|
|
53
|
-
|
|
46
|
+
scopePathSet: this._scopePathSet,
|
|
54
47
|
});
|
|
48
|
+
}
|
|
55
49
|
|
|
56
50
|
this._debug(`BUILD...`);
|
|
57
|
-
const bundleResult = await this.#serverBundler
|
|
58
|
-
|
|
59
|
-
//-- filePaths
|
|
60
|
-
const watchFileSet = new Set(
|
|
61
|
-
Array.from(bundleResult.watchFileSet).filter((item) => this._watchScopePathSet.inScope(item)),
|
|
62
|
-
);
|
|
51
|
+
const bundleResult = await this.#serverBundler!.bundleAsync(modifiedFileSet);
|
|
63
52
|
|
|
64
53
|
this._debug(`빌드 완료`);
|
|
65
|
-
return
|
|
66
|
-
watchFileSet,
|
|
67
|
-
affectedFileSet: bundleResult.affectedFileSet,
|
|
68
|
-
buildMessages: bundleResult.results,
|
|
69
|
-
emitFileSet: bundleResult.emitFileSet,
|
|
70
|
-
};
|
|
54
|
+
return bundleResult;
|
|
71
55
|
}
|
|
72
56
|
|
|
73
57
|
async #generateProductionFilesAsync() {
|
|
@@ -92,13 +76,6 @@ export class SdServerBuildRunner extends BuildRunnerBase<"server"> {
|
|
|
92
76
|
distNpmConfig.dependencies[dep] = "*";
|
|
93
77
|
}
|
|
94
78
|
|
|
95
|
-
// distNpmConfig.scripts = {};
|
|
96
|
-
// if (this._pkgConf.pm2 && !this._pkgConf.pm2.noStartScript) {
|
|
97
|
-
// distNpmConfig.scripts["start"] = "pm2 start pm2.config.cjs";
|
|
98
|
-
// distNpmConfig.scripts["stop"] = "pm2 stop pm2.config.cjs";
|
|
99
|
-
// distNpmConfig.scripts["delete"] = "pm2 delete pm2.config.cjs";
|
|
100
|
-
// }
|
|
101
|
-
|
|
102
79
|
distNpmConfig.volta = projNpmConf.volta;
|
|
103
80
|
|
|
104
81
|
FsUtils.writeJson(path.resolve(this._pkgPath, "dist/package.json"), distNpmConfig, {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import esbuild from "esbuild";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { FsUtils, HashUtils, PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
4
|
-
import { SdCliConvertMessageUtils } from "../../utils/
|
|
5
|
-
import {
|
|
6
|
-
import { ISdBuildMessage } from "../../types/build.types";
|
|
7
|
-
import { createSdServerPlugin } from "./sd-server.plugin-creator";
|
|
4
|
+
import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
|
|
5
|
+
import { createSdServerPlugin } from "./createSdServerPlugin";
|
|
8
6
|
import {
|
|
9
7
|
BuildOutputFile,
|
|
10
8
|
BuildOutputFileType,
|
|
11
9
|
} from "@angular/build/src/tools/esbuild/bundler-context";
|
|
12
10
|
import { convertOutputFile } from "@angular/build/src/tools/esbuild/utils";
|
|
13
11
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
14
|
-
import { ScopePathSet } from "../commons/
|
|
12
|
+
import { ScopePathSet } from "../commons/ScopePathSet";
|
|
13
|
+
import { ISdCliServerPluginResultCache } from "../../types/plugin/ISdCliServerPluginResultCache";
|
|
14
|
+
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
15
15
|
|
|
16
16
|
export class SdServerBundler {
|
|
17
17
|
#logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBundler"]);
|
|
@@ -25,22 +25,18 @@ export class SdServerBundler {
|
|
|
25
25
|
|
|
26
26
|
constructor(
|
|
27
27
|
private readonly _opt: {
|
|
28
|
+
watch: boolean;
|
|
28
29
|
dev: boolean;
|
|
29
30
|
emitOnly: boolean;
|
|
30
31
|
noEmit: boolean;
|
|
31
32
|
pkgPath: TNormPath;
|
|
32
33
|
entryPoints: string[];
|
|
33
34
|
external?: string[];
|
|
34
|
-
|
|
35
|
+
scopePathSet: ScopePathSet;
|
|
35
36
|
},
|
|
36
37
|
) {}
|
|
37
38
|
|
|
38
|
-
async bundleAsync(modifiedFileSet?: Set<TNormPath>): Promise<{
|
|
39
|
-
watchFileSet: Set<TNormPath>;
|
|
40
|
-
affectedFileSet: Set<TNormPath>;
|
|
41
|
-
results: ISdBuildMessage[];
|
|
42
|
-
emitFileSet: Set<TNormPath>;
|
|
43
|
-
}> {
|
|
39
|
+
async bundleAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
44
40
|
this.#modifiedFileSet.clear();
|
|
45
41
|
if (modifiedFileSet) {
|
|
46
42
|
this.#modifiedFileSet.adds(...modifiedFileSet);
|
|
@@ -109,25 +105,30 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
109
105
|
plugins: [
|
|
110
106
|
createSdServerPlugin({
|
|
111
107
|
modifiedFileSet: this.#modifiedFileSet,
|
|
108
|
+
watch: this._opt.watch,
|
|
112
109
|
dev: this._opt.dev,
|
|
113
110
|
emitOnly: this._opt.emitOnly,
|
|
114
111
|
noEmit: this._opt.noEmit,
|
|
115
112
|
pkgPath: this._opt.pkgPath,
|
|
116
113
|
result: this.#resultCache,
|
|
117
|
-
|
|
114
|
+
scopePathSet: this._opt.scopePathSet,
|
|
118
115
|
}),
|
|
119
116
|
],
|
|
120
117
|
});
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
let
|
|
124
|
-
|
|
120
|
+
let esbuildResult: esbuild.BuildResult | esbuild.BuildFailure;
|
|
121
|
+
esbuildResult = await this.#context.rebuild();
|
|
125
122
|
|
|
126
123
|
if (this._opt.noEmit) {
|
|
127
124
|
return {
|
|
125
|
+
buildMessages: SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(
|
|
126
|
+
esbuildResult,
|
|
127
|
+
this._opt.pkgPath,
|
|
128
|
+
),
|
|
129
|
+
|
|
128
130
|
watchFileSet: this.#resultCache.watchFileSet!,
|
|
129
131
|
affectedFileSet: this.#resultCache.affectedFileSet!,
|
|
130
|
-
results: [],
|
|
131
132
|
emitFileSet: new Set<TNormPath>(),
|
|
132
133
|
};
|
|
133
134
|
} else {
|
|
@@ -135,8 +136,9 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
135
136
|
|
|
136
137
|
try {
|
|
137
138
|
const outputFiles: BuildOutputFile[] =
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
esbuildResult.outputFiles?.map((file) =>
|
|
140
|
+
convertOutputFile(file, BuildOutputFileType.Root),
|
|
141
|
+
) ?? [];
|
|
140
142
|
|
|
141
143
|
for (const outputFile of outputFiles) {
|
|
142
144
|
const distFilePath = PathUtils.norm(this._opt.pkgPath, outputFile.path);
|
|
@@ -171,7 +173,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
} catch (err) {
|
|
174
|
-
|
|
176
|
+
esbuildResult = err;
|
|
175
177
|
for (const e of err.errors) {
|
|
176
178
|
if (e.detail != null) {
|
|
177
179
|
this.#logger.error(e.detail);
|
|
@@ -180,12 +182,13 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
return {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
results: SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(
|
|
186
|
-
result,
|
|
185
|
+
buildMessages: SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(
|
|
186
|
+
esbuildResult,
|
|
187
187
|
this._opt.pkgPath,
|
|
188
188
|
),
|
|
189
|
+
|
|
190
|
+
watchFileSet: this.#resultCache.watchFileSet!,
|
|
191
|
+
affectedFileSet: this.#resultCache.affectedFileSet!,
|
|
189
192
|
emitFileSet: emitFileSet,
|
|
190
193
|
};
|
|
191
194
|
}
|