@simplysm/sd-cli 12.5.21 → 12.5.22
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/{build-tools → entry}/SdCliCordova.d.ts +5 -6
- package/dist/{build-tools → entry}/SdCliCordova.js +117 -99
- package/dist/entry/SdCliCordova.js.map +1 -0
- package/dist/entry/SdCliElectron.d.ts +2 -2
- package/dist/entry/SdCliElectron.js +50 -40
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.d.ts +1 -2
- package/dist/entry/SdCliLocalUpdate.js +26 -27
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +1 -5
- package/dist/entry/SdCliProject.js +62 -288
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +23 -20
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +21 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js +174 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.js +7 -7
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +20 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js +135 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdNgBundler.d.ts +29 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundler.js +100 -95
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.d.ts +1 -2
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.js +19 -45
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
- package/dist/pkg-builders/client/createSdNgPlugin.d.ts +10 -0
- package/dist/{bundle-plugins/sdNgPlugin.js → pkg-builders/client/createSdNgPlugin.js} +32 -33
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +5 -0
- package/dist/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.js +11 -11
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +16 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +81 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +13 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +89 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +14 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +54 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +17 -0
- package/dist/{builders/SdCliServerBuilder.js → pkg-builders/server/SdServerBuildRunner.js} +48 -53
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBundler.d.ts +19 -0
- package/dist/{build-tools → pkg-builders/server}/SdServerBundler.js +25 -30
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
- package/dist/pkg-builders/server/createSdServerPlugin.d.ts +10 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js +53 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
- package/dist/sd-cli.js +61 -54
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +9 -0
- package/dist/ts-builder/SdTsCompileWorker.js +16 -0
- package/dist/ts-builder/SdTsCompileWorker.js.map +1 -0
- package/dist/ts-builder/SdTsCompiler.d.ts +7 -0
- package/dist/{build-tools → ts-builder}/SdTsCompiler.js +226 -212
- package/dist/ts-builder/SdTsCompiler.js.map +1 -0
- package/dist/types/build-plugin.type.d.ts +14 -0
- package/dist/types/build-plugin.type.js +2 -0
- package/dist/types/build-plugin.type.js.map +1 -0
- package/dist/types/build.type.d.ts +15 -0
- package/dist/types/build.type.js +2 -0
- package/dist/types/build.type.js.map +1 -0
- package/dist/types/common-configs.type.d.ts +22 -0
- package/dist/types/common-configs.type.js +2 -0
- package/dist/types/common-configs.type.js.map +1 -0
- package/dist/types/sd-configs.type.d.ts +99 -0
- package/dist/types/sd-configs.type.js +2 -0
- package/dist/types/sd-configs.type.js.map +1 -0
- package/dist/types/ts-compiler.type.d.ts +29 -0
- package/dist/types/ts-compiler.type.js +2 -0
- package/dist/types/ts-compiler.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +49 -0
- package/dist/types/workers.type.js +2 -0
- package/dist/types/workers.type.js.map +1 -0
- package/dist/utils/SdCliConvertMessageUtil.d.ts +21 -0
- package/dist/utils/SdCliConvertMessageUtil.js +137 -0
- package/dist/utils/SdCliConvertMessageUtil.js.map +1 -0
- package/dist/workers/compile-worker.js +27 -0
- package/dist/workers/compile-worker.js.map +1 -0
- package/dist/workers/lint-worker.js +36 -0
- package/dist/workers/lint-worker.js.map +1 -0
- package/dist/workers/server-worker.d.ts +1 -0
- package/dist/workers/server-worker.js +49 -0
- package/dist/workers/server-worker.js.map +1 -0
- package/lib/dev-worker.cjs +5 -0
- package/package.json +7 -10
- package/src/entry/SdCliCordova.ts +363 -0
- package/src/entry/SdCliElectron.ts +96 -69
- package/src/entry/SdCliLocalUpdate.ts +43 -44
- package/src/entry/SdCliProject.ts +72 -417
- package/src/index.ts +23 -20
- package/src/pkg-builders/SdMultiBuildRunner.ts +250 -0
- package/src/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.ts +7 -7
- package/src/pkg-builders/client/SdClientBuildRunner.ts +191 -0
- package/src/{build-tools → pkg-builders/client}/SdNgBundler.ts +125 -121
- package/src/pkg-builders/client/SdNgBundlerContext.ts +111 -0
- package/src/{bundle-plugins/sdNgPlugin.ts → pkg-builders/client/createSdNgPlugin.ts} +43 -46
- package/src/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.ts +11 -11
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +105 -0
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +128 -0
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +69 -0
- package/src/{builders/SdCliServerBuilder.ts → pkg-builders/server/SdServerBuildRunner.ts} +66 -78
- package/src/{build-tools → pkg-builders/server}/SdServerBundler.ts +40 -41
- package/src/pkg-builders/server/createSdServerPlugin.ts +77 -0
- package/src/sd-cli.ts +197 -211
- package/src/ts-builder/SdTsCompileWorker.ts +21 -0
- package/src/ts-builder/SdTsCompiler.ts +758 -0
- package/src/types/build-plugin.type.ts +16 -0
- package/src/types/build.type.ts +17 -0
- package/src/types/common-configs.type.ts +27 -0
- package/src/types/sd-configs.type.ts +114 -0
- package/src/types/ts-compiler.type.ts +29 -0
- package/src/types/workers.type.ts +27 -0
- package/src/utils/SdCliConvertMessageUtil.ts +177 -0
- package/src/workers/compile-worker.ts +31 -0
- package/src/workers/lint-worker.ts +44 -0
- package/src/workers/server-worker.ts +52 -0
- package/tsconfig.json +7 -1
- package/dist/build-cluster.js +0 -201
- package/dist/build-cluster.js.map +0 -1
- package/dist/build-tools/SdCliCordova.js.map +0 -1
- package/dist/build-tools/SdCliIndexFileGenerator.d.ts +0 -5
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +0 -4
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +0 -1
- package/dist/build-tools/SdLinter.d.ts +0 -5
- package/dist/build-tools/SdLinter.js +0 -49
- package/dist/build-tools/SdLinter.js.map +0 -1
- package/dist/build-tools/SdNgBundler.d.ts +0 -29
- package/dist/build-tools/SdNgBundler.js.map +0 -1
- package/dist/build-tools/SdNgBundlerContext.js.map +0 -1
- package/dist/build-tools/SdReactBundler.d.ts +0 -25
- package/dist/build-tools/SdReactBundler.js +0 -295
- package/dist/build-tools/SdReactBundler.js.map +0 -1
- package/dist/build-tools/SdReactBundlerContext.d.ts +0 -14
- package/dist/build-tools/SdReactBundlerContext.js +0 -59
- package/dist/build-tools/SdReactBundlerContext.js.map +0 -1
- package/dist/build-tools/SdServerBundler.d.ts +0 -20
- package/dist/build-tools/SdServerBundler.js.map +0 -1
- package/dist/build-tools/SdTsCompiler.d.ts +0 -34
- package/dist/build-tools/SdTsCompiler.js.map +0 -1
- package/dist/build-tools/SdTsLibBundler.d.ts +0 -13
- package/dist/build-tools/SdTsLibBundler.js +0 -58
- package/dist/build-tools/SdTsLibBundler.js.map +0 -1
- package/dist/builders/SdCliClientBuilder.d.ts +0 -18
- package/dist/builders/SdCliClientBuilder.js +0 -172
- package/dist/builders/SdCliClientBuilder.js.map +0 -1
- package/dist/builders/SdCliJsLibLinter.d.ts +0 -13
- package/dist/builders/SdCliJsLibLinter.js +0 -60
- package/dist/builders/SdCliJsLibLinter.js.map +0 -1
- package/dist/builders/SdCliServerBuilder.d.ts +0 -15
- package/dist/builders/SdCliServerBuilder.js.map +0 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +0 -12
- package/dist/builders/SdCliTsLibBuilder.js +0 -90
- package/dist/builders/SdCliTsLibBuilder.js.map +0 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdNgPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdReactPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdReactPlugin.js +0 -117
- package/dist/bundle-plugins/sdReactPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdServerPlugin.js +0 -63
- package/dist/bundle-plugins/sdServerPlugin.js.map +0 -1
- package/dist/commons.d.ts +0 -145
- package/dist/commons.js +0 -2
- package/dist/commons.js.map +0 -1
- package/dist/server-worker.js +0 -57
- package/dist/server-worker.js.map +0 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +0 -16
- package/dist/utils/SdCliBuildResultUtil.js +0 -54
- package/dist/utils/SdCliBuildResultUtil.js.map +0 -1
- package/src/build-cluster.ts +0 -212
- package/src/build-tools/SdCliCordova.ts +0 -340
- package/src/build-tools/SdLinter.ts +0 -65
- package/src/build-tools/SdNgBundlerContext.ts +0 -137
- package/src/build-tools/SdReactBundler.ts +0 -372
- package/src/build-tools/SdReactBundlerContext.ts +0 -71
- package/src/build-tools/SdTsCompiler.ts +0 -754
- package/src/build-tools/SdTsLibBundler.ts +0 -72
- package/src/builders/SdCliClientBuilder.ts +0 -233
- package/src/builders/SdCliJsLibLinter.ts +0 -72
- package/src/builders/SdCliTsLibBuilder.ts +0 -126
- package/src/bundle-plugins/sdReactPlugin.ts +0 -164
- package/src/bundle-plugins/sdServerPlugin.ts +0 -94
- package/src/commons.ts +0 -171
- package/src/server-worker.ts +0 -65
- package/src/utils/SdCliBuildResultUtil.ts +0 -63
- /package/dist/{build-cluster.d.ts → workers/compile-worker.d.ts} +0 -0
- /package/dist/{server-worker.d.ts → workers/lint-worker.d.ts} +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
2
|
-
import { ISdCliPackageBuildResult } from "../commons";
|
|
3
|
-
import { SdTsCompiler } from "./SdTsCompiler";
|
|
4
|
-
import ts from "typescript";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
7
|
-
|
|
8
|
-
export class SdTsLibBundler {
|
|
9
|
-
readonly #compiler: SdTsCompiler;
|
|
10
|
-
|
|
11
|
-
readonly #pkgPath: string;
|
|
12
|
-
|
|
13
|
-
public constructor(pkgPath: string, dev: boolean, watchScopePaths: string[]) {
|
|
14
|
-
this.#pkgPath = pkgPath;
|
|
15
|
-
this.#compiler = new SdTsCompiler({
|
|
16
|
-
pkgPath,
|
|
17
|
-
additionalOptions: { declaration: true },
|
|
18
|
-
isDevMode: dev,
|
|
19
|
-
globalStyleFilePath: path.resolve(pkgPath, "src/styles.scss"),
|
|
20
|
-
isForBundle: false,
|
|
21
|
-
watchScopePaths: watchScopePaths,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public markChanges(modifiedFileSet: Set<string>): void {
|
|
26
|
-
this.#compiler.invalidate(modifiedFileSet);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public async buildAsync(): Promise<{
|
|
30
|
-
program: ts.Program;
|
|
31
|
-
watchFileSet: Set<string>;
|
|
32
|
-
affectedFileSet: Set<string>;
|
|
33
|
-
results: ISdCliPackageBuildResult[];
|
|
34
|
-
}> {
|
|
35
|
-
const buildResult = await this.#compiler.buildAsync();
|
|
36
|
-
|
|
37
|
-
for (const emitFile of buildResult.emitFileSet) {
|
|
38
|
-
const emitFileInfos = buildResult.emittedFilesCacheMap.get(emitFile);
|
|
39
|
-
if (emitFileInfos) {
|
|
40
|
-
for (const emitFileInfo of emitFileInfos) {
|
|
41
|
-
if (emitFileInfo.outAbsPath != null) {
|
|
42
|
-
await FsUtil.writeFileAsync(emitFileInfo.outAbsPath, emitFileInfo.text);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const globalStylesheetBundlingResult = buildResult.stylesheetBundlingResultMap.get(emitFile);
|
|
48
|
-
if (globalStylesheetBundlingResult) {
|
|
49
|
-
for (const outputFile of globalStylesheetBundlingResult.outputFiles) {
|
|
50
|
-
const distPath = path.resolve(this.#pkgPath, "dist", path.relative(this.#pkgPath, outputFile.path));
|
|
51
|
-
if (PathUtil.isChildPath(distPath, path.resolve(this.#pkgPath, "dist"))) {
|
|
52
|
-
await FsUtil.writeFileAsync(distPath, outputFile.text);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
program: buildResult.program,
|
|
60
|
-
watchFileSet: buildResult.watchFileSet,
|
|
61
|
-
affectedFileSet: buildResult.affectedFileSet,
|
|
62
|
-
results: [
|
|
63
|
-
...buildResult.typescriptDiagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, "build")),
|
|
64
|
-
...Array.from(buildResult.stylesheetBundlingResultMap.values())
|
|
65
|
-
.mapMany((item) => item.errors ?? [])
|
|
66
|
-
.map((err) => SdCliBuildResultUtil.convertFromEsbuildResult(err, "build", "error")),
|
|
67
|
-
/*...Array.from(buildResult.stylesheetResultMap.values()).mapMany(item => item.warnings!)
|
|
68
|
-
.map(warn => SdCliBuildResultUtil.convertFromEsbuildResult(warn, "build", "warning"))*/
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
3
|
-
import {
|
|
4
|
-
INpmConfig,
|
|
5
|
-
ISdCliBuilderResult,
|
|
6
|
-
ISdCliClientPackageConfig,
|
|
7
|
-
ISdCliConfig,
|
|
8
|
-
ISdCliPackageBuildResult,
|
|
9
|
-
} from "../commons";
|
|
10
|
-
import { FunctionQueue } from "@simplysm/sd-core-common";
|
|
11
|
-
import path from "path";
|
|
12
|
-
import { SdNgBundler } from "../build-tools/SdNgBundler";
|
|
13
|
-
import { SdCliCordova } from "../build-tools/SdCliCordova";
|
|
14
|
-
import { SdCliNgRoutesFileGenerator } from "../build-tools/SdCliNgRoutesFileGenerator";
|
|
15
|
-
import { SdLinter } from "../build-tools/SdLinter";
|
|
16
|
-
import { SdCliElectron } from "../entry/SdCliElectron";
|
|
17
|
-
import { SdReactBundler } from "../build-tools/SdReactBundler";
|
|
18
|
-
|
|
19
|
-
export class SdCliClientBuilder extends EventEmitter {
|
|
20
|
-
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliClientBuilder"]);
|
|
21
|
-
private readonly _pkgConf: ISdCliClientPackageConfig;
|
|
22
|
-
private readonly _npmConf: INpmConfig;
|
|
23
|
-
private _builders?: (SdNgBundler | SdReactBundler)[];
|
|
24
|
-
private _cordova?: SdCliCordova;
|
|
25
|
-
|
|
26
|
-
public constructor(
|
|
27
|
-
private readonly _projConf: ISdCliConfig,
|
|
28
|
-
private readonly _pkgPath: string,
|
|
29
|
-
) {
|
|
30
|
-
super();
|
|
31
|
-
this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdCliClientPackageConfig;
|
|
32
|
-
this._npmConf = FsUtil.readJson(path.resolve(_pkgPath, "package.json")) as INpmConfig;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public override on(event: "change", listener: () => void): this;
|
|
36
|
-
public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
|
|
37
|
-
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
38
|
-
super.on(event, listener);
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
43
|
-
this._debug("dist 초기화...");
|
|
44
|
-
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
45
|
-
|
|
46
|
-
if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies).includes("@angular/router")) {
|
|
47
|
-
this._debug(`GEN routes.ts...`);
|
|
48
|
-
await SdCliNgRoutesFileGenerator.runAsync(this._pkgPath, undefined, this._pkgConf.noLazyRoute);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this._debug("GEN .config...");
|
|
52
|
-
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
53
|
-
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
54
|
-
|
|
55
|
-
const result = await this._runAsync({ dev: false });
|
|
56
|
-
return {
|
|
57
|
-
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
58
|
-
buildResults: result.buildResults,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public async watchAsync() {
|
|
63
|
-
this.emit("change");
|
|
64
|
-
|
|
65
|
-
this._debug("dist 초기화...");
|
|
66
|
-
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
67
|
-
|
|
68
|
-
if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies).includes("@angular/router")) {
|
|
69
|
-
this._debug(`WATCH GEN routes.ts...`);
|
|
70
|
-
await SdCliNgRoutesFileGenerator.watchAsync(this._pkgPath, this._pkgConf.noLazyRoute);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
this._debug("GEN .config...");
|
|
74
|
-
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
75
|
-
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
76
|
-
|
|
77
|
-
const result = await this._runAsync({ dev: !this._pkgConf.forceProductionMode });
|
|
78
|
-
this.emit("complete", {
|
|
79
|
-
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
80
|
-
buildResults: result.buildResults,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
this._debug("WATCH...");
|
|
84
|
-
let changeFiles: string[] = [];
|
|
85
|
-
const fnQ = new FunctionQueue();
|
|
86
|
-
const watcher = SdFsWatcher.watch(Array.from(result.watchFileSet)).onChange({ delay: 100 }, (changeInfos) => {
|
|
87
|
-
changeFiles.push(...changeInfos.map((item) => item.path));
|
|
88
|
-
|
|
89
|
-
fnQ.runLast(async () => {
|
|
90
|
-
const currChangeFiles = [...changeFiles];
|
|
91
|
-
changeFiles = [];
|
|
92
|
-
|
|
93
|
-
this.emit("change");
|
|
94
|
-
|
|
95
|
-
for (const builder of this._builders!) {
|
|
96
|
-
// builder.removeCache(currChangeFiles);
|
|
97
|
-
builder.markForChanges(currChangeFiles);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const watchResult = await this._runAsync({ dev: !this._pkgConf.forceProductionMode });
|
|
101
|
-
this.emit("complete", {
|
|
102
|
-
affectedFilePaths: Array.from(watchResult.affectedFileSet),
|
|
103
|
-
buildResults: watchResult.buildResults,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
watcher.add(watchResult.watchFileSet);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private async _runAsync(opt: { dev: boolean }): Promise<{
|
|
112
|
-
watchFileSet: Set<string>;
|
|
113
|
-
affectedFileSet: Set<string>;
|
|
114
|
-
buildResults: ISdCliPackageBuildResult[];
|
|
115
|
-
}> {
|
|
116
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
117
|
-
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const builderTypes = Object.keys(this._pkgConf.builder ?? { web: {} }) as ("web" | "electron" | "cordova")[];
|
|
121
|
-
if (this._pkgConf.builder?.cordova && !this._cordova) {
|
|
122
|
-
this._debug("CORDOVA 준비...");
|
|
123
|
-
this._cordova = new SdCliCordova({
|
|
124
|
-
pkgPath: this._pkgPath,
|
|
125
|
-
config: this._pkgConf.builder.cordova,
|
|
126
|
-
});
|
|
127
|
-
await this._cordova.initializeAsync();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (!this._builders) {
|
|
131
|
-
this._debug(`BUILD 준비...`);
|
|
132
|
-
|
|
133
|
-
if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies).includes("react")) {
|
|
134
|
-
this._builders = builderTypes.map(
|
|
135
|
-
(builderType) =>
|
|
136
|
-
new SdReactBundler({
|
|
137
|
-
dev: opt.dev,
|
|
138
|
-
builderType: builderType,
|
|
139
|
-
pkgPath: this._pkgPath,
|
|
140
|
-
outputPath:
|
|
141
|
-
builderType === "web"
|
|
142
|
-
? path.resolve(this._pkgPath, "dist")
|
|
143
|
-
: builderType === "electron" && !opt.dev
|
|
144
|
-
? path.resolve(this._pkgPath, ".electron/src")
|
|
145
|
-
: builderType === "cordova" && !opt.dev
|
|
146
|
-
? path.resolve(this._pkgPath, ".cordova/www")
|
|
147
|
-
: path.resolve(this._pkgPath, "dist", builderType),
|
|
148
|
-
env: {
|
|
149
|
-
...this._pkgConf.env,
|
|
150
|
-
...this._pkgConf.builder?.[builderType]?.env,
|
|
151
|
-
},
|
|
152
|
-
cordovaConfig: builderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
153
|
-
watchScopePaths: [path.resolve(this._pkgPath, "../"), ...localUpdatePaths],
|
|
154
|
-
}),
|
|
155
|
-
);
|
|
156
|
-
} else {
|
|
157
|
-
this._builders = builderTypes.map(
|
|
158
|
-
(builderType) =>
|
|
159
|
-
new SdNgBundler({
|
|
160
|
-
dev: opt.dev,
|
|
161
|
-
builderType: builderType,
|
|
162
|
-
pkgPath: this._pkgPath,
|
|
163
|
-
outputPath:
|
|
164
|
-
builderType === "web"
|
|
165
|
-
? path.resolve(this._pkgPath, "dist")
|
|
166
|
-
: builderType === "electron" && !opt.dev
|
|
167
|
-
? path.resolve(this._pkgPath, ".electron/src")
|
|
168
|
-
: builderType === "cordova" && !opt.dev
|
|
169
|
-
? path.resolve(this._pkgPath, ".cordova/www")
|
|
170
|
-
: path.resolve(this._pkgPath, "dist", builderType),
|
|
171
|
-
env: {
|
|
172
|
-
...this._pkgConf.env,
|
|
173
|
-
...this._pkgConf.builder?.[builderType]?.env,
|
|
174
|
-
},
|
|
175
|
-
cordovaConfig: builderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
176
|
-
watchScopePaths: [path.resolve(this._pkgPath, "../"), ...localUpdatePaths],
|
|
177
|
-
}),
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this._debug(`BUILD & CHECK...`);
|
|
183
|
-
const buildResults = await Promise.all(this._builders.map((builder) => builder.bundleAsync()));
|
|
184
|
-
const watchFileSet = new Set(buildResults.mapMany((item) => Array.from(item.watchFileSet)));
|
|
185
|
-
const affectedFileSet = new Set(buildResults.mapMany((item) => Array.from(item.affectedFileSet)));
|
|
186
|
-
const results = buildResults.mapMany((item) => item.results).distinct();
|
|
187
|
-
const firstProgram = buildResults.first()?.program;
|
|
188
|
-
|
|
189
|
-
this._debug(`LINT...`);
|
|
190
|
-
// const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
191
|
-
// const parsedTsConfig = ts.parseJsonConfigFileContent(tsConfig, ts.sys, this._pkgPath);
|
|
192
|
-
// this.#program = ts.createProgram({
|
|
193
|
-
// rootNames: parsedTsConfig.fileNames,
|
|
194
|
-
// options: parsedTsConfig.options,
|
|
195
|
-
// oldProgram: this.#program
|
|
196
|
-
// });
|
|
197
|
-
// const pkgFilePaths = filePaths.filter(item => PathUtil.isChildPath(item, this._pkgPath));
|
|
198
|
-
const lintResults = await SdLinter.lintAsync(this._pkgPath, affectedFileSet, firstProgram);
|
|
199
|
-
|
|
200
|
-
if (!opt.dev && this._cordova) {
|
|
201
|
-
this._debug("CORDOVA BUILD...");
|
|
202
|
-
await this._cordova.buildAsync(path.resolve(this._pkgPath, "dist"));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!opt.dev && this._pkgConf.builder?.electron) {
|
|
206
|
-
this._debug("ELECTRON BUILD...");
|
|
207
|
-
await SdCliElectron.buildAsync({
|
|
208
|
-
pkgPath: this._pkgPath,
|
|
209
|
-
config: this._pkgConf.builder.electron,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
this._debug(`빌드 완료`);
|
|
214
|
-
const currWatchFileSet = new Set(
|
|
215
|
-
Array.from(watchFileSet).filter(
|
|
216
|
-
(item) =>
|
|
217
|
-
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
218
|
-
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)),
|
|
219
|
-
),
|
|
220
|
-
);
|
|
221
|
-
return {
|
|
222
|
-
watchFileSet: currWatchFileSet,
|
|
223
|
-
affectedFileSet,
|
|
224
|
-
buildResults: [...results, ...lintResults].filter(
|
|
225
|
-
(item) => item.filePath !== path.resolve(this._pkgPath, "src/routes.ts"),
|
|
226
|
-
),
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private _debug(msg: string): void {
|
|
231
|
-
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {FsUtil, Logger, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import {ISdCliBuilderResult} from "../commons";
|
|
4
|
-
import {EventEmitter} from "events";
|
|
5
|
-
import {SdLinter} from "../build-tools/SdLinter";
|
|
6
|
-
|
|
7
|
-
export class SdCliJsLibLinter extends EventEmitter {
|
|
8
|
-
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliJsLibLinter"]);
|
|
9
|
-
private readonly _pkgName: string;
|
|
10
|
-
|
|
11
|
-
public constructor(private readonly _pkgPath: string) {
|
|
12
|
-
super();
|
|
13
|
-
this._pkgName = path.basename(_pkgPath);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public override on(event: "change", listener: () => void): this;
|
|
17
|
-
public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
|
|
18
|
-
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
19
|
-
super.on(event, listener);
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
24
|
-
this._debug("LINT...");
|
|
25
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.js");
|
|
26
|
-
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
27
|
-
const lintResults = await SdLinter.lintAsync(this._pkgPath, new Set(srcFilePaths), undefined);
|
|
28
|
-
|
|
29
|
-
this._debug(`LINT 완료`);
|
|
30
|
-
return {
|
|
31
|
-
affectedFilePaths: srcFilePaths,
|
|
32
|
-
buildResults: lintResults
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public async watchAsync(): Promise<void> {
|
|
37
|
-
this.emit("change");
|
|
38
|
-
this._debug("LINT...");
|
|
39
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.js");
|
|
40
|
-
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
41
|
-
const lintResults = await SdLinter.lintAsync(this._pkgPath, new Set(srcFilePaths), undefined);
|
|
42
|
-
|
|
43
|
-
this._debug(`LINT 완료`);
|
|
44
|
-
this.emit("complete", {
|
|
45
|
-
affectedFilePaths: srcFilePaths,
|
|
46
|
-
buildResults: lintResults
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
SdFsWatcher
|
|
50
|
-
.watch([srcGlobPath])
|
|
51
|
-
.onChange({
|
|
52
|
-
delay: 100
|
|
53
|
-
}, async (changeInfos) => {
|
|
54
|
-
const watchFilePaths = changeInfos.filter((item) => FsUtil.exists(item.path)).map((item) => item.path);
|
|
55
|
-
if (watchFilePaths.length < 1) return;
|
|
56
|
-
|
|
57
|
-
this.emit("change");
|
|
58
|
-
this._debug("LINT...");
|
|
59
|
-
const watchLintResults = await SdLinter.lintAsync(this._pkgPath, new Set(watchFilePaths), undefined);
|
|
60
|
-
|
|
61
|
-
this._debug(`LINT 완료`);
|
|
62
|
-
this.emit("complete", {
|
|
63
|
-
affectedFilePaths: changeInfos.map((item) => item.path),
|
|
64
|
-
buildResults: watchLintResults
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private _debug(msg: string): void {
|
|
70
|
-
this._logger.debug(`[${this._pkgName}] ${msg}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { ISdCliBuilderResult, ISdCliConfig, ISdCliLibPackageConfig, ISdCliPackageBuildResult } from "../commons";
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
import { SdTsLibBundler } from "../build-tools/SdTsLibBundler";
|
|
6
|
-
import { SdLinter } from "../build-tools/SdLinter";
|
|
7
|
-
import { FunctionQueue } from "@simplysm/sd-core-common";
|
|
8
|
-
import { SdCliIndexFileGenerator } from "../build-tools/SdCliIndexFileGenerator";
|
|
9
|
-
|
|
10
|
-
export class SdCliTsLibBuilder extends EventEmitter {
|
|
11
|
-
readonly #logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
|
|
12
|
-
|
|
13
|
-
readonly #projConf: ISdCliConfig;
|
|
14
|
-
readonly #pkgPath: string;
|
|
15
|
-
readonly #pkgConf: ISdCliLibPackageConfig;
|
|
16
|
-
|
|
17
|
-
#bundler?: SdTsLibBundler;
|
|
18
|
-
|
|
19
|
-
public constructor(projConf: ISdCliConfig, pkgPath: string) {
|
|
20
|
-
super();
|
|
21
|
-
this.#projConf = projConf;
|
|
22
|
-
this.#pkgPath = pkgPath;
|
|
23
|
-
|
|
24
|
-
this.#pkgConf = projConf.packages[path.basename(pkgPath)] as ISdCliLibPackageConfig;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public override on(event: "change", listener: () => void): this;
|
|
28
|
-
public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
|
|
29
|
-
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
30
|
-
super.on(event, listener);
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
35
|
-
this._debug("dist 초기화...");
|
|
36
|
-
await FsUtil.removeAsync(path.resolve(this.#pkgPath, "dist"));
|
|
37
|
-
|
|
38
|
-
if (!this.#pkgConf.noGenIndex) {
|
|
39
|
-
this._debug("GEN index.ts...");
|
|
40
|
-
await SdCliIndexFileGenerator.runAsync(this.#pkgPath, this.#pkgConf.polyfills);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const result = await this._runAsync(false);
|
|
44
|
-
return {
|
|
45
|
-
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
46
|
-
buildResults: result.buildResults,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async watchAsync(): Promise<void> {
|
|
51
|
-
this.emit("change");
|
|
52
|
-
|
|
53
|
-
this._debug("dist 초기화...");
|
|
54
|
-
await FsUtil.removeAsync(path.resolve(this.#pkgPath, "dist"));
|
|
55
|
-
|
|
56
|
-
if (!this.#pkgConf.noGenIndex) {
|
|
57
|
-
this._debug("WATCH GEN index.ts...");
|
|
58
|
-
await SdCliIndexFileGenerator.watchAsync(this.#pkgPath, this.#pkgConf.polyfills);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const result = await this._runAsync(true);
|
|
62
|
-
this.emit("complete", {
|
|
63
|
-
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
64
|
-
buildResults: result.buildResults,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
this._debug("WATCH...");
|
|
68
|
-
const fnQ = new FunctionQueue();
|
|
69
|
-
const watcher = SdFsWatcher.watch(Array.from(result.watchFileSet)).onChange({ delay: 100 }, (changeInfos) => {
|
|
70
|
-
this.#bundler!.markChanges(new Set(changeInfos.map((item) => item.path)));
|
|
71
|
-
|
|
72
|
-
fnQ.runLast(async () => {
|
|
73
|
-
this.emit("change");
|
|
74
|
-
|
|
75
|
-
const watchResult = await this._runAsync(true);
|
|
76
|
-
this.emit("complete", {
|
|
77
|
-
affectedFilePaths: Array.from(watchResult.affectedFileSet),
|
|
78
|
-
buildResults: watchResult.buildResults,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
watcher.add(watchResult.watchFileSet);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private async _runAsync(dev: boolean): Promise<{
|
|
87
|
-
watchFileSet: Set<string>;
|
|
88
|
-
affectedFileSet: Set<string>;
|
|
89
|
-
buildResults: ISdCliPackageBuildResult[];
|
|
90
|
-
}> {
|
|
91
|
-
const localUpdatePaths = Object.keys(this.#projConf.localUpdates ?? {}).mapMany((key) =>
|
|
92
|
-
FsUtil.glob(path.resolve(this.#pkgPath, "../../node_modules", key)),
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
this._debug(`BUILD...`);
|
|
96
|
-
this.#bundler =
|
|
97
|
-
this.#bundler ??
|
|
98
|
-
new SdTsLibBundler(this.#pkgPath, dev, [path.resolve(this.#pkgPath, "../"), ...localUpdatePaths]);
|
|
99
|
-
const buildResult = await this.#bundler.buildAsync();
|
|
100
|
-
|
|
101
|
-
this._debug("LINT...");
|
|
102
|
-
/*const lintFilePaths = Array.from(buildResult.affectedFileSet).filter((item) =>
|
|
103
|
-
PathUtil.isChildPath(item, this.#pkgPath),
|
|
104
|
-
);*/
|
|
105
|
-
const lintResults = await SdLinter.lintAsync(this.#pkgPath, buildResult.affectedFileSet, buildResult.program);
|
|
106
|
-
|
|
107
|
-
this._debug(`빌드 완료`);
|
|
108
|
-
const watchFileSet = new Set(
|
|
109
|
-
Array.from(buildResult.watchFileSet).filter(
|
|
110
|
-
(item) =>
|
|
111
|
-
PathUtil.isChildPath(item, path.resolve(this.#pkgPath, "../")) ||
|
|
112
|
-
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)),
|
|
113
|
-
),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
watchFileSet,
|
|
118
|
-
affectedFileSet: buildResult.affectedFileSet,
|
|
119
|
-
buildResults: [...buildResult.results, ...lintResults],
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
private _debug(msg: string): void {
|
|
124
|
-
this.#logger.debug(`[${path.basename(this.#pkgPath)}] ${msg}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import esbuild from "esbuild";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { ISdTsCompilerResult, SdTsCompiler } from "../build-tools/SdTsCompiler";
|
|
5
|
-
import { convertTypeScriptDiagnostic } from "@angular/build/src/tools/esbuild/angular/diagnostics";
|
|
6
|
-
import postcss from "postcss";
|
|
7
|
-
import { FsUtil } from "@simplysm/sd-core-node";
|
|
8
|
-
import postcssUrl from "postcss-url";
|
|
9
|
-
import postcssHas from "css-has-pseudo";
|
|
10
|
-
import autoprefixer from "autoprefixer";
|
|
11
|
-
|
|
12
|
-
export function sdReactPlugin(conf: {
|
|
13
|
-
pkgPath: string;
|
|
14
|
-
dev: boolean;
|
|
15
|
-
modifiedFileSet: Set<string>;
|
|
16
|
-
result: IReactPluginResultCache;
|
|
17
|
-
watchScopePaths: string[];
|
|
18
|
-
}): esbuild.Plugin {
|
|
19
|
-
return {
|
|
20
|
-
name: "sd-ng-compiler",
|
|
21
|
-
setup: (build: esbuild.PluginBuild) => {
|
|
22
|
-
const compiler = new SdTsCompiler({
|
|
23
|
-
pkgPath: conf.pkgPath,
|
|
24
|
-
additionalOptions: { declaration: false },
|
|
25
|
-
isDevMode: conf.dev,
|
|
26
|
-
isForBundle: true,
|
|
27
|
-
watchScopePaths: conf.watchScopePaths
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
let buildResult: ISdTsCompilerResult;
|
|
31
|
-
const outputContentsCacheMap = new Map<string, string | Uint8Array | undefined>();
|
|
32
|
-
|
|
33
|
-
//---------------------------
|
|
34
|
-
|
|
35
|
-
build.onStart(async () => {
|
|
36
|
-
compiler.invalidate(conf.modifiedFileSet);
|
|
37
|
-
for (const modifiedFile of conf.modifiedFileSet) {
|
|
38
|
-
outputContentsCacheMap.delete(modifiedFile);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
buildResult = await compiler.buildAsync();
|
|
42
|
-
|
|
43
|
-
conf.result.watchFileSet = buildResult.watchFileSet;
|
|
44
|
-
conf.result.affectedFileSet = buildResult.affectedFileSet;
|
|
45
|
-
conf.result.program = buildResult.program;
|
|
46
|
-
|
|
47
|
-
//-- return err/warn
|
|
48
|
-
return {
|
|
49
|
-
errors: [
|
|
50
|
-
...buildResult.typescriptDiagnostics
|
|
51
|
-
.filter((item) => item.category === ts.DiagnosticCategory.Error)
|
|
52
|
-
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
53
|
-
...Array.from(buildResult.stylesheetBundlingResultMap.values()).flatMap((item) => item.errors),
|
|
54
|
-
].filterExists(),
|
|
55
|
-
warnings: [
|
|
56
|
-
...buildResult.typescriptDiagnostics
|
|
57
|
-
.filter((item) => item.category !== ts.DiagnosticCategory.Error)
|
|
58
|
-
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
59
|
-
// ...Array.from(buildResult.stylesheetResultMap.values()).flatMap(item => item.warnings)
|
|
60
|
-
],
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
build.onLoad({ filter: /\.tsx?$/ }, (args) => {
|
|
65
|
-
const output = outputContentsCacheMap.get(path.normalize(args.path));
|
|
66
|
-
if (output != null) {
|
|
67
|
-
return { contents: output, loader: "js" };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const emittedJsFile = buildResult.emittedFilesCacheMap.get(path.normalize(args.path))?.last();
|
|
71
|
-
if (!emittedJsFile) {
|
|
72
|
-
throw new Error(`ts 빌더 결과 emit 파일이 존재하지 않습니다. ${args.path}`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const contents = emittedJsFile.text;
|
|
76
|
-
|
|
77
|
-
outputContentsCacheMap.set(path.normalize(args.path), contents);
|
|
78
|
-
|
|
79
|
-
return { contents, loader: "js" };
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
build.onLoad({ filter: /\.[cm]?jsx?$/ }, (args) => {
|
|
83
|
-
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
84
|
-
return null;
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
88
|
-
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
89
|
-
const output = outputContentsCacheMap.get(path.normalize(args.path));
|
|
90
|
-
if (output != null) {
|
|
91
|
-
return {
|
|
92
|
-
contents: output,
|
|
93
|
-
loader: "file",
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const css = await FsUtil.readFileAsync(path.normalize(args.path));
|
|
98
|
-
const result = await postcss()
|
|
99
|
-
.use(
|
|
100
|
-
autoprefixer({
|
|
101
|
-
overrideBrowserslist: ["Chrome > 78"]
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
.use(
|
|
105
|
-
postcssUrl({
|
|
106
|
-
url: "copy",
|
|
107
|
-
}),
|
|
108
|
-
)
|
|
109
|
-
.use(
|
|
110
|
-
postcssHas()
|
|
111
|
-
)
|
|
112
|
-
.process(css, {
|
|
113
|
-
from: path.normalize(args.path),
|
|
114
|
-
to: path.resolve(conf.pkgPath, "dist", "media", path.basename(args.path)),
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
outputContentsCacheMap.set(path.normalize(args.path), result.css);
|
|
118
|
-
|
|
119
|
-
return { contents: result.css, loader: "file" };
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
build.onLoad(
|
|
123
|
-
{
|
|
124
|
-
filter: new RegExp(
|
|
125
|
-
"(" +
|
|
126
|
-
Object.keys(build.initialOptions.loader!)
|
|
127
|
-
.map((item) => "\\" + item)
|
|
128
|
-
.join("|") +
|
|
129
|
-
")$",
|
|
130
|
-
),
|
|
131
|
-
},
|
|
132
|
-
(args) => {
|
|
133
|
-
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
134
|
-
return null;
|
|
135
|
-
},
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
build.onEnd((result) => {
|
|
139
|
-
for (const { outputFiles, metafile } of buildResult.stylesheetBundlingResultMap.values()) {
|
|
140
|
-
result.outputFiles = result.outputFiles ?? [];
|
|
141
|
-
result.outputFiles.push(...outputFiles);
|
|
142
|
-
|
|
143
|
-
if (result.metafile && metafile) {
|
|
144
|
-
result.metafile.inputs = { ...result.metafile.inputs, ...metafile.inputs };
|
|
145
|
-
result.metafile.outputs = { ...result.metafile.outputs, ...metafile.outputs };
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
conf.result.outputFiles = result.outputFiles;
|
|
150
|
-
conf.result.metafile = result.metafile;
|
|
151
|
-
|
|
152
|
-
conf.modifiedFileSet.clear();
|
|
153
|
-
});
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface IReactPluginResultCache {
|
|
159
|
-
watchFileSet?: Set<string>;
|
|
160
|
-
affectedFileSet?: Set<string>;
|
|
161
|
-
program?: ts.Program;
|
|
162
|
-
outputFiles?: esbuild.OutputFile[];
|
|
163
|
-
metafile?: esbuild.Metafile;
|
|
164
|
-
}
|