@simplysm/sd-cli 12.13.19 → 12.13.21
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/pkg-builders/client/sd-cli-ng-routes.file-generator.d.ts +1 -0
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js +16 -11
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +1 -1
- package/dist/pkg-builders/client/sd-client.build-runner.js +7 -17
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler.js +105 -95
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js +68 -57
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +1 -1
- package/dist/pkg-builders/commons/build-runner.base.d.ts +2 -1
- package/dist/pkg-builders/commons/build-runner.base.js +16 -27
- package/dist/pkg-builders/commons/build-runner.base.js.map +1 -1
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.d.ts +1 -0
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js +21 -11
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +1 -0
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +13 -10
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +11 -30
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.bundler.js +48 -37
- package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -1
- package/dist/ts-compiler/sd-ts-compiler.js +116 -222
- package/dist/ts-compiler/sd-ts-compiler.js.map +1 -1
- package/package.json +5 -5
- package/src/pkg-builders/client/sd-cli-ng-routes.file-generator.ts +18 -8
- package/src/pkg-builders/client/sd-client.build-runner.ts +8 -19
- package/src/pkg-builders/client/sd-ng.bundler.ts +139 -121
- package/src/pkg-builders/client/sd-ng.plugin-creator.ts +22 -17
- package/src/pkg-builders/commons/build-runner.base.ts +62 -75
- package/src/pkg-builders/lib/sd-cli-db-context.file-generator.ts +20 -8
- package/src/pkg-builders/lib/sd-cli-index.file-generator.ts +20 -9
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +11 -31
- package/src/pkg-builders/server/sd-server.bundler.ts +59 -48
- package/src/ts-compiler/sd-ts-compiler.ts +19 -160
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { FsUtils, HashUtils, PathUtils } from "@simplysm/sd-core-node";
|
|
2
|
+
import { FsUtils, HashUtils, PathUtils, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
3
3
|
import { StringUtils } from "@simplysm/sd-core-common";
|
|
4
4
|
|
|
5
5
|
export class SdCliNgRoutesFileGenerator {
|
|
6
6
|
cachedHash?: string;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
watch(pkgPath: string, noLazyRoute?: boolean) {
|
|
9
9
|
const routesFilePath = path.resolve(pkgPath, "src/routes.ts");
|
|
10
|
-
this.cachedHash = FsUtils.exists(routesFilePath)
|
|
10
|
+
this.cachedHash = FsUtils.exists(routesFilePath)
|
|
11
|
+
? HashUtils.get(FsUtils.readFile(routesFilePath))
|
|
12
|
+
: undefined;
|
|
11
13
|
|
|
12
|
-
SdFsWatcher.watch([path.resolve(pkgPath, "src")]
|
|
13
|
-
|
|
14
|
+
SdFsWatcher.watch([path.resolve(pkgPath, "src")], {
|
|
15
|
+
ignored: [routesFilePath],
|
|
16
|
+
}).onChange({ delay: 50 }, (changeInfos) => {
|
|
17
|
+
if (changeInfos.some((item) => ["add", "addDir", "unlink", "unlinkDir"].includes(item.event)))
|
|
18
|
+
this.run(pkgPath, noLazyRoute);
|
|
14
19
|
});
|
|
15
20
|
|
|
16
21
|
this.run(pkgPath, noLazyRoute);
|
|
17
|
-
}
|
|
22
|
+
}
|
|
18
23
|
|
|
19
|
-
run(
|
|
24
|
+
run(
|
|
25
|
+
pkgPath: string,
|
|
26
|
+
noLazyRoute?: boolean,
|
|
27
|
+
): { changed: boolean; filePath: string; content: string } {
|
|
20
28
|
const appDirPath = path.resolve(pkgPath, "src/app");
|
|
21
29
|
const routesFilePath = path.resolve(pkgPath, "src/routes.ts");
|
|
22
30
|
|
|
@@ -54,7 +62,9 @@ export class SdCliNgRoutesFileGenerator {
|
|
|
54
62
|
cont += indentStr + ` path: "${key}",\n`;
|
|
55
63
|
if (val.relModulePath != null) {
|
|
56
64
|
if (noLazyRoute) {
|
|
57
|
-
cont +=
|
|
65
|
+
cont +=
|
|
66
|
+
indentStr +
|
|
67
|
+
` component: ${StringUtils.toPascalCase(path.basename(val.relModulePath))},\n`;
|
|
58
68
|
imports.push(
|
|
59
69
|
`import { ${StringUtils.toPascalCase(path.basename(val.relModulePath))} } from "./app/${val.relModulePath}";`,
|
|
60
70
|
);
|
|
@@ -10,12 +10,9 @@ import { INpmConfig } from "../../types/common-configs.types";
|
|
|
10
10
|
export class SdClientBuildRunner extends BuildRunnerBase<"client"> {
|
|
11
11
|
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdClientBuildRunner"]);
|
|
12
12
|
|
|
13
|
-
#routeGenerator = new SdCliNgRoutesFileGenerator();
|
|
14
13
|
#ngBundlers?: SdNgBundler[];
|
|
15
14
|
#cordova?: SdCliCordova;
|
|
16
15
|
|
|
17
|
-
#hasGenRoutesError = false;
|
|
18
|
-
|
|
19
16
|
protected override async _runAsync(
|
|
20
17
|
dev: boolean,
|
|
21
18
|
emitOnly: boolean,
|
|
@@ -24,8 +21,8 @@ export class SdClientBuildRunner extends BuildRunnerBase<"client"> {
|
|
|
24
21
|
): Promise<IBuildRunnerRunResult> {
|
|
25
22
|
// 최초 한번
|
|
26
23
|
if (!modifiedFileSet) {
|
|
27
|
-
// config
|
|
28
24
|
if (!noEmit) {
|
|
25
|
+
// config
|
|
29
26
|
this._debug("GEN .config...");
|
|
30
27
|
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
31
28
|
FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
@@ -39,6 +36,13 @@ export class SdClientBuildRunner extends BuildRunnerBase<"client"> {
|
|
|
39
36
|
});
|
|
40
37
|
await this.#cordova.initializeAsync();
|
|
41
38
|
}
|
|
39
|
+
|
|
40
|
+
// routes
|
|
41
|
+
const npmConf = FsUtils.readJson(path.resolve(this._pkgPath, "package.json")) as INpmConfig;
|
|
42
|
+
if ("@angular/router" in (npmConf.dependencies ?? {})) {
|
|
43
|
+
this._debug(`GEN routes.ts...`);
|
|
44
|
+
new SdCliNgRoutesFileGenerator().watch(this._pkgPath, this._pkgConf.noLazyRoute);
|
|
45
|
+
}
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
// ng
|
|
@@ -108,18 +112,6 @@ export class SdClientBuildRunner extends BuildRunnerBase<"client"> {
|
|
|
108
112
|
emitFileSet,
|
|
109
113
|
};
|
|
110
114
|
} else {
|
|
111
|
-
const npmConf = FsUtils.readJson(path.resolve(this._pkgPath, "package.json")) as INpmConfig;
|
|
112
|
-
|
|
113
|
-
let routesFileNPath: TNormPath | undefined;
|
|
114
|
-
if ("@angular/router" in (npmConf.dependencies ?? {})) {
|
|
115
|
-
this._debug(`GEN routes.ts...`);
|
|
116
|
-
const genRoutesResult = this.#routeGenerator.run(this._pkgPath, this._pkgConf.noLazyRoute);
|
|
117
|
-
if (modifiedFileSet && (genRoutesResult.changed || this.#hasGenRoutesError)) {
|
|
118
|
-
modifiedFileSet.add(PathUtils.norm(genRoutesResult.filePath));
|
|
119
|
-
}
|
|
120
|
-
routesFileNPath = PathUtils.norm(genRoutesResult.filePath);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
115
|
if (modifiedFileSet) {
|
|
124
116
|
for (const ngBundler of this.#ngBundlers!) {
|
|
125
117
|
ngBundler.markForChanges(Array.from(modifiedFileSet));
|
|
@@ -150,9 +142,6 @@ export class SdClientBuildRunner extends BuildRunnerBase<"client"> {
|
|
|
150
142
|
});
|
|
151
143
|
}
|
|
152
144
|
|
|
153
|
-
this.#hasGenRoutesError =
|
|
154
|
-
routesFileNPath != null && results.map((item) => item.filePath).includes(routesFileNPath);
|
|
155
|
-
|
|
156
145
|
this._debug(`빌드 완료`);
|
|
157
146
|
|
|
158
147
|
return {
|
|
@@ -26,11 +26,17 @@ import {
|
|
|
26
26
|
import { Entrypoint } from "@angular/build/src/utils/index-file/augment-index-html";
|
|
27
27
|
import { CrossOrigin } from "@angular/build/src/builders/application/schema";
|
|
28
28
|
import { augmentAppWithServiceWorkerEsbuild } from "@angular/build/src/utils/service-worker";
|
|
29
|
-
import {
|
|
30
|
-
|
|
29
|
+
import {
|
|
30
|
+
createSourcemapIgnorelistPlugin
|
|
31
|
+
} from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
|
|
32
|
+
import {
|
|
33
|
+
StylesheetPluginFactory
|
|
34
|
+
} from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
|
|
31
35
|
import { SassStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/sass-language";
|
|
32
36
|
import { CssStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/css-language";
|
|
33
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
createCssResourcePlugin
|
|
39
|
+
} from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
34
40
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
35
41
|
import { createSdNgPlugin } from "./sd-ng.plugin-creator";
|
|
36
42
|
import { SdCliPerformanceTimer } from "../../utils/sd-cli-performance-time";
|
|
@@ -130,142 +136,154 @@ export class SdNgBundler {
|
|
|
130
136
|
//-- results
|
|
131
137
|
const results = bundlingResults.mapMany((bundlingResult) => bundlingResult.results);
|
|
132
138
|
|
|
133
|
-
this
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
147
|
-
for (const bundlingResult of bundlingResults) {
|
|
148
|
-
bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
|
|
149
|
-
metafile.inputs = { ...metafile.inputs, ...bundlingResult.metafile?.inputs };
|
|
150
|
-
metafile.outputs = { ...metafile.outputs, ...bundlingResult.metafile?.outputs };
|
|
151
|
-
}
|
|
152
|
-
const assetFiles: { source: string; destination: string }[] = [];
|
|
153
|
-
|
|
154
|
-
//-- cordova empty
|
|
155
|
-
/*if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
|
|
156
|
-
outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
157
|
-
}*/
|
|
158
|
-
|
|
159
|
-
this.#debug(`create index.html...`);
|
|
160
|
-
await perf.run("create index.html", async () => {
|
|
161
|
-
const genIndexHtmlResult = await this.#genIndexHtmlAsync(outputFiles, initialFiles);
|
|
162
|
-
for (const warning of genIndexHtmlResult.warnings) {
|
|
163
|
-
results.push({
|
|
164
|
-
filePath: undefined,
|
|
165
|
-
line: undefined,
|
|
166
|
-
char: undefined,
|
|
167
|
-
code: undefined,
|
|
168
|
-
severity: "warning",
|
|
169
|
-
message: `${warning}`,
|
|
170
|
-
type: "gen-index",
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
for (const error of genIndexHtmlResult.errors) {
|
|
174
|
-
results.push({
|
|
175
|
-
filePath: undefined,
|
|
176
|
-
line: undefined,
|
|
177
|
-
char: undefined,
|
|
178
|
-
code: undefined,
|
|
179
|
-
severity: "error",
|
|
180
|
-
message: `${error}`,
|
|
181
|
-
type: "gen-index",
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
outputFiles.push(
|
|
185
|
-
createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root),
|
|
139
|
+
if (this._opt.noEmit) {
|
|
140
|
+
return {
|
|
141
|
+
watchFileSet: this.#ngResultCache.watchFileSet!,
|
|
142
|
+
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
143
|
+
results,
|
|
144
|
+
emitFileSet: new Set<TNormPath>(),
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
this.#debug(`convert result...`);
|
|
148
|
+
|
|
149
|
+
const outputFiles: BuildOutputFile[] = bundlingResults.mapMany(
|
|
150
|
+
(item) =>
|
|
151
|
+
item.outputFiles?.map((file) => convertOutputFile(file, BuildOutputFileType.Root)) ?? [],
|
|
186
152
|
);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
BuildOutputFileType.Root,
|
|
200
|
-
),
|
|
201
|
-
);
|
|
153
|
+
const initialFiles = new Map<string, InitialFileRecord>();
|
|
154
|
+
const metafile: {
|
|
155
|
+
inputs: Metafile["inputs"];
|
|
156
|
+
outputs: Metafile["outputs"];
|
|
157
|
+
} = {
|
|
158
|
+
inputs: {},
|
|
159
|
+
outputs: {},
|
|
160
|
+
};
|
|
161
|
+
for (const bundlingResult of bundlingResults) {
|
|
162
|
+
bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
|
|
163
|
+
metafile.inputs = { ...metafile.inputs, ...bundlingResult.metafile?.inputs };
|
|
164
|
+
metafile.outputs = { ...metafile.outputs, ...bundlingResult.metafile?.outputs };
|
|
202
165
|
}
|
|
203
|
-
});
|
|
204
166
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
167
|
+
//-- cordova empty
|
|
168
|
+
/*if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
|
|
169
|
+
outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
170
|
+
}*/
|
|
208
171
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
172
|
+
this.#debug(`create index.html...`);
|
|
173
|
+
await perf.run("create index.html", async () => {
|
|
174
|
+
const genIndexHtmlResult = await this.#genIndexHtmlAsync(outputFiles, initialFiles);
|
|
175
|
+
for (const warning of genIndexHtmlResult.warnings) {
|
|
176
|
+
results.push({
|
|
177
|
+
filePath: undefined,
|
|
178
|
+
line: undefined,
|
|
179
|
+
char: undefined,
|
|
180
|
+
code: undefined,
|
|
181
|
+
severity: "warning",
|
|
182
|
+
message: `${warning}`,
|
|
183
|
+
type: "gen-index",
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
for (const error of genIndexHtmlResult.errors) {
|
|
217
187
|
results.push({
|
|
218
188
|
filePath: undefined,
|
|
219
189
|
line: undefined,
|
|
220
190
|
char: undefined,
|
|
221
191
|
code: undefined,
|
|
222
192
|
severity: "error",
|
|
223
|
-
message: `${
|
|
224
|
-
type: "gen-
|
|
193
|
+
message: `${error}`,
|
|
194
|
+
type: "gen-index",
|
|
225
195
|
});
|
|
226
196
|
}
|
|
197
|
+
outputFiles.push(
|
|
198
|
+
createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root),
|
|
199
|
+
);
|
|
227
200
|
});
|
|
228
|
-
}
|
|
229
201
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
202
|
+
const assetFiles: { source: string; destination: string }[] = [];
|
|
203
|
+
await perf.run("assets", async () => {
|
|
204
|
+
//-- copy assets
|
|
205
|
+
assetFiles.push(...(await this.#copyAssetsAsync()));
|
|
206
|
+
|
|
207
|
+
//-- extract 3rdpartylicenses
|
|
208
|
+
if (!this._opt.dev) {
|
|
209
|
+
outputFiles.push(
|
|
210
|
+
createOutputFile(
|
|
211
|
+
"3rdpartylicenses.txt",
|
|
212
|
+
await extractLicenses(metafile, this._opt.pkgPath),
|
|
213
|
+
BuildOutputFileType.Root,
|
|
214
|
+
),
|
|
215
|
+
);
|
|
243
216
|
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
//-- service worker
|
|
220
|
+
if (FsUtils.exists(this.#swConfFilePath)) {
|
|
221
|
+
this.#debug(`prepare service worker...`);
|
|
222
|
+
|
|
223
|
+
await perf.run("prepare service worker", async () => {
|
|
224
|
+
try {
|
|
225
|
+
const serviceWorkerResult = await this.#genServiceWorkerAsync(outputFiles, assetFiles);
|
|
226
|
+
outputFiles.push(
|
|
227
|
+
createOutputFile("ngsw.json", serviceWorkerResult.manifest, BuildOutputFileType.Root),
|
|
228
|
+
);
|
|
229
|
+
assetFiles.push(...serviceWorkerResult.assetFiles);
|
|
230
|
+
} catch (err) {
|
|
231
|
+
results.push({
|
|
232
|
+
filePath: undefined,
|
|
233
|
+
line: undefined,
|
|
234
|
+
char: undefined,
|
|
235
|
+
code: undefined,
|
|
236
|
+
severity: "error",
|
|
237
|
+
message: `${err.toString()}`,
|
|
238
|
+
type: "gen-sw",
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
});
|
|
244
242
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
243
|
+
|
|
244
|
+
//-- write
|
|
245
|
+
this.#debug(`write output files...(${outputFiles.length})`);
|
|
246
|
+
|
|
247
|
+
const emitFileSet = new Set<TNormPath>();
|
|
248
|
+
perf.run("write output file", () => {
|
|
249
|
+
for (const outputFile of outputFiles) {
|
|
250
|
+
const distFilePath = PathUtils.norm(this._opt.outputPath, outputFile.path);
|
|
251
|
+
const prevHash = this.#outputHashCache.get(distFilePath);
|
|
252
|
+
const currHash = HashUtils.get(Buffer.from(outputFile.contents));
|
|
253
|
+
if (prevHash !== currHash) {
|
|
254
|
+
FsUtils.writeFile(distFilePath, outputFile.contents);
|
|
255
|
+
this.#outputHashCache.set(distFilePath, currHash);
|
|
256
|
+
emitFileSet.add(distFilePath);
|
|
257
|
+
}
|
|
252
258
|
}
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
for (const assetFile of assetFiles) {
|
|
260
|
+
const prevHash = this.#outputHashCache.get(PathUtils.norm(assetFile.source));
|
|
261
|
+
const currHash = HashUtils.get(FsUtils.readFileBuffer(assetFile.source));
|
|
262
|
+
if (prevHash !== currHash) {
|
|
263
|
+
FsUtils.copy(
|
|
264
|
+
assetFile.source,
|
|
265
|
+
path.resolve(this._opt.outputPath, assetFile.destination),
|
|
266
|
+
);
|
|
267
|
+
this.#outputHashCache.set(PathUtils.norm(assetFile.source), currHash);
|
|
268
|
+
emitFileSet.add(PathUtils.norm(this._opt.outputPath, assetFile.destination));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
255
272
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
273
|
+
this.#debug(perf.toString());
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
watchFileSet: new Set([
|
|
277
|
+
...this.#ngResultCache.watchFileSet!,
|
|
278
|
+
...this.#styleLoadResultCache.watchFiles.map((item) => PathUtils.norm(item)),
|
|
279
|
+
...assetFiles.map((item) => PathUtils.norm(item.source)),
|
|
280
|
+
PathUtils.norm(this.#indexHtmlFilePath),
|
|
281
|
+
]),
|
|
282
|
+
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
283
|
+
results,
|
|
284
|
+
emitFileSet: emitFileSet,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
269
287
|
}
|
|
270
288
|
|
|
271
289
|
async #genIndexHtmlAsync(
|
|
@@ -53,7 +53,7 @@ export function createSdNgPlugin(conf: {
|
|
|
53
53
|
Math.floor((os.cpus().length * 2) / 3),
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
let cssStore = new Map<TNormPath, Buffer>();
|
|
56
|
+
// let cssStore = new Map<TNormPath, Buffer>();
|
|
57
57
|
|
|
58
58
|
//---------------------------
|
|
59
59
|
|
|
@@ -67,7 +67,7 @@ export function createSdNgPlugin(conf: {
|
|
|
67
67
|
|
|
68
68
|
tsCompileResult = await tsCompiler.compileAsync(conf.modifiedFileSet);
|
|
69
69
|
|
|
70
|
-
cssStore.clear();
|
|
70
|
+
// cssStore.clear();
|
|
71
71
|
|
|
72
72
|
conf.result.watchFileSet = tsCompileResult.watchFileSet;
|
|
73
73
|
conf.result.affectedFileSet = tsCompileResult.affectedFileSet;
|
|
@@ -97,7 +97,7 @@ export function createSdNgPlugin(conf: {
|
|
|
97
97
|
return res;
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
build.onResolve({ filter: /\.css$/ }, (args) => {
|
|
100
|
+
/*build.onResolve({ filter: /\.css$/ }, (args) => {
|
|
101
101
|
if (args.path.startsWith("sd-css-asset:")) return;
|
|
102
102
|
return {
|
|
103
103
|
path: path.resolve(args.resolveDir, args.path),
|
|
@@ -106,7 +106,7 @@ export function createSdNgPlugin(conf: {
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
build.onLoad({ filter: /\.css$/, namespace: "sd-css" }, async (args) => {
|
|
109
|
-
const code =
|
|
109
|
+
const code = /!* language=javascript *!/ `
|
|
110
110
|
import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
111
111
|
(function __sdEnsureStyle(href) {
|
|
112
112
|
let link = document.querySelector('link[data-sd-style="' + href + '"]');
|
|
@@ -136,7 +136,14 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
136
136
|
cssStore.get(PathUtils.norm(args.path)) ??
|
|
137
137
|
cssStore.get(PathUtils.norm(args.path.replace(/[\\\/]src[\\\/]/, "\\dist\\")));
|
|
138
138
|
if (cssContent == null) {
|
|
139
|
-
return {
|
|
139
|
+
return {
|
|
140
|
+
errors: [
|
|
141
|
+
{
|
|
142
|
+
location: null,
|
|
143
|
+
text: `Missing CSS for ${PathUtils.norm(args.path)}`,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
return {
|
|
@@ -144,12 +151,12 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
144
151
|
loader: "file",
|
|
145
152
|
resolveDir: path.dirname(args.path),
|
|
146
153
|
};
|
|
147
|
-
})
|
|
154
|
+
});*/
|
|
148
155
|
|
|
149
156
|
build.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
150
157
|
const emittedFiles = tsCompileResult.emittedFilesCacheMap.get(PathUtils.norm(args.path));
|
|
151
158
|
|
|
152
|
-
try {
|
|
159
|
+
/*try {
|
|
153
160
|
const css = emittedFiles?.single((item) => Boolean(item.outAbsPath?.endsWith(".css")));
|
|
154
161
|
if (css) {
|
|
155
162
|
cssStore.set(PathUtils.norm(css.outAbsPath!), Buffer.from(css.text));
|
|
@@ -165,7 +172,7 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
165
172
|
},
|
|
166
173
|
],
|
|
167
174
|
};
|
|
168
|
-
}
|
|
175
|
+
}*/
|
|
169
176
|
|
|
170
177
|
const output = outputContentsCacheMap.get(PathUtils.norm(args.path));
|
|
171
178
|
if (output != null) {
|
|
@@ -188,7 +195,7 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
188
195
|
return { contents: newContents, loader: "js" };
|
|
189
196
|
});
|
|
190
197
|
|
|
191
|
-
build.onLoad({ filter: /\.
|
|
198
|
+
build.onLoad({ filter: /\.mjs$/ }, async (args) => {
|
|
192
199
|
conf.result.watchFileSet!.add(PathUtils.norm(args.path));
|
|
193
200
|
|
|
194
201
|
const output = outputContentsCacheMap.get(PathUtils.norm(args.path));
|
|
@@ -209,14 +216,12 @@ import href from "sd-css-asset:${PathUtils.posix(args.path)}"
|
|
|
209
216
|
|
|
210
217
|
const contents = await FsUtils.readFileBufferAsync(args.path);
|
|
211
218
|
|
|
212
|
-
return
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
sideEffects,
|
|
219
|
-
);
|
|
219
|
+
return await javascriptTransformer.transformData(
|
|
220
|
+
args.path,
|
|
221
|
+
contents.toString(),
|
|
222
|
+
false,
|
|
223
|
+
sideEffects,
|
|
224
|
+
);
|
|
220
225
|
});
|
|
221
226
|
|
|
222
227
|
outputContentsCacheMap.set(PathUtils.norm(args.path), newContents);
|