@simplysm/sd-cli 12.16.36 → 12.16.38
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/SdNgBundler.js +4 -0
- package/dist/pkg-builders/client/SdPolyfillPlugin.d.ts +2 -0
- package/dist/pkg-builders/client/SdPolyfillPlugin.js +51 -0
- package/package.json +9 -5
- package/src/pkg-builders/client/SdNgBundler.ts +4 -0
- package/src/pkg-builders/client/SdPolyfillPlugin.ts +62 -0
|
@@ -22,6 +22,7 @@ import { createSdNgPlugin } from "./createSdNgPlugin";
|
|
|
22
22
|
import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTimer";
|
|
23
23
|
import nodeModule from "module";
|
|
24
24
|
import { SdWorkerPathPlugin } from "../commons/SdWorkerPathPlugin";
|
|
25
|
+
import { SdPolyfillPlugin } from "./SdPolyfillPlugin";
|
|
25
26
|
export class SdNgBundler {
|
|
26
27
|
constructor(_opt, _conf) {
|
|
27
28
|
this._opt = _opt;
|
|
@@ -247,6 +248,7 @@ export class SdNgBundler {
|
|
|
247
248
|
const indexHtmlGenerator = new IndexHtmlGenerator({
|
|
248
249
|
indexPath: this._indexHtmlFilePath,
|
|
249
250
|
entrypoints: [
|
|
251
|
+
["sd-polyfills", true],
|
|
250
252
|
["polyfills", true],
|
|
251
253
|
["styles", false],
|
|
252
254
|
["main", true],
|
|
@@ -369,6 +371,7 @@ export class SdNgBundler {
|
|
|
369
371
|
mainFields: ["es2020", "es2015", "browser", "module", "main"],
|
|
370
372
|
entryNames: "[dir]/[name]",
|
|
371
373
|
entryPoints: {
|
|
374
|
+
"sd-polyfills": "virtual:sd-polyfills",
|
|
372
375
|
main: this._mainFilePath,
|
|
373
376
|
...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/polyfills.ts"))
|
|
374
377
|
? {
|
|
@@ -431,6 +434,7 @@ export class SdNgBundler {
|
|
|
431
434
|
}),
|
|
432
435
|
plugins: [
|
|
433
436
|
createSourcemapIgnorelistPlugin(),
|
|
437
|
+
SdPolyfillPlugin(["Chrome >= 61"]),
|
|
434
438
|
createSdNgPlugin(this._opt, this._modifiedFileSet, this._ngResultCache),
|
|
435
439
|
...(this._conf.builderType === "electron"
|
|
436
440
|
? []
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import compat from "core-js-compat";
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { PathUtils } from "@simplysm/sd-core-node";
|
|
4
|
+
const _require = createRequire(import.meta.url);
|
|
5
|
+
const SD_POLYFILL_NS = "sd-polyfill";
|
|
6
|
+
const SD_POLYFILL_FILTER = /^virtual:sd-polyfills$/;
|
|
7
|
+
export function SdPolyfillPlugin(browserslistQuery) {
|
|
8
|
+
return {
|
|
9
|
+
name: "sd-polyfill-plugin",
|
|
10
|
+
setup(build) {
|
|
11
|
+
build.onResolve({ filter: SD_POLYFILL_FILTER }, () => ({
|
|
12
|
+
path: "sd-polyfills",
|
|
13
|
+
namespace: SD_POLYFILL_NS,
|
|
14
|
+
}));
|
|
15
|
+
build.onLoad({ filter: /.*/, namespace: SD_POLYFILL_NS }, () => {
|
|
16
|
+
const { list } = compat({
|
|
17
|
+
targets: browserslistQuery,
|
|
18
|
+
});
|
|
19
|
+
const lines = [];
|
|
20
|
+
// core-js 모듈 (절대 경로로 resolve하여 소비 프로젝트의 node_modules 의존 제거)
|
|
21
|
+
for (const mod of list) {
|
|
22
|
+
try {
|
|
23
|
+
const absPath = _require.resolve(`core-js/modules/${mod}.js`);
|
|
24
|
+
lines.push(`import "${PathUtils.posix(absPath)}";`);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// 모듈이 존재하지 않으면 skip (WeakRef 등 polyfill 불가 항목)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// AbortController (Chrome 66+)
|
|
31
|
+
try {
|
|
32
|
+
const absPath = _require.resolve("abortcontroller-polyfill/dist/abortcontroller-polyfill-only");
|
|
33
|
+
lines.push(`import "${PathUtils.posix(absPath)}";`);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// skip
|
|
37
|
+
}
|
|
38
|
+
// ResizeObserver (Chrome 64+)
|
|
39
|
+
try {
|
|
40
|
+
const absPath = _require.resolve("resize-observer-polyfill");
|
|
41
|
+
lines.push(`import RO from "${PathUtils.posix(absPath)}";`);
|
|
42
|
+
lines.push(`if (typeof window !== "undefined" && !("ResizeObserver" in window)) { window.ResizeObserver = RO; }`);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// skip
|
|
46
|
+
}
|
|
47
|
+
return { contents: lines.join("\n"), loader: "js" };
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/sd-cli",
|
|
3
|
-
"version": "12.16.
|
|
3
|
+
"version": "12.16.38",
|
|
4
4
|
"description": "심플리즘 패키지 - CLI",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -17,12 +17,15 @@
|
|
|
17
17
|
"@angular/compiler-cli": "^20.3.18",
|
|
18
18
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
19
19
|
"@electron/rebuild": "^4.0.3",
|
|
20
|
-
"@simplysm/sd-core-common": "12.16.
|
|
21
|
-
"@simplysm/sd-core-node": "12.16.
|
|
22
|
-
"@simplysm/sd-service-server": "12.16.
|
|
23
|
-
"@simplysm/sd-storage": "12.16.
|
|
20
|
+
"@simplysm/sd-core-common": "12.16.38",
|
|
21
|
+
"@simplysm/sd-core-node": "12.16.38",
|
|
22
|
+
"@simplysm/sd-service-server": "12.16.38",
|
|
23
|
+
"@simplysm/sd-storage": "12.16.38",
|
|
24
|
+
"abortcontroller-polyfill": "^1.7.8",
|
|
24
25
|
"browserslist": "^4.28.1",
|
|
25
26
|
"cordova": "^13.0.0",
|
|
27
|
+
"core-js": "^3.49.0",
|
|
28
|
+
"core-js-compat": "^3.49.0",
|
|
26
29
|
"electron": "^33.4.11",
|
|
27
30
|
"electron-builder": "^25.1.8",
|
|
28
31
|
"esbuild": "0.25.9",
|
|
@@ -30,6 +33,7 @@
|
|
|
30
33
|
"eslint": "^9.39.4",
|
|
31
34
|
"glob": "^13.0.6",
|
|
32
35
|
"node-stdlib-browser": "^1.3.1",
|
|
36
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
33
37
|
"rxjs": "^7.8.2",
|
|
34
38
|
"sass-embedded": "^1.98.0",
|
|
35
39
|
"semver": "^7.7.4",
|
|
@@ -41,6 +41,7 @@ import { INpmConfig } from "../../types/common-config/INpmConfig";
|
|
|
41
41
|
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
42
42
|
import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
|
|
43
43
|
import { SdWorkerPathPlugin } from "../commons/SdWorkerPathPlugin";
|
|
44
|
+
import { SdPolyfillPlugin } from "./SdPolyfillPlugin";
|
|
44
45
|
|
|
45
46
|
export class SdNgBundler {
|
|
46
47
|
private readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundler"]);
|
|
@@ -326,6 +327,7 @@ export class SdNgBundler {
|
|
|
326
327
|
const indexHtmlGenerator = new IndexHtmlGenerator({
|
|
327
328
|
indexPath: this._indexHtmlFilePath,
|
|
328
329
|
entrypoints: [
|
|
330
|
+
["sd-polyfills", true],
|
|
329
331
|
["polyfills", true],
|
|
330
332
|
["styles", false],
|
|
331
333
|
["main", true],
|
|
@@ -487,6 +489,7 @@ export class SdNgBundler {
|
|
|
487
489
|
mainFields: ["es2020", "es2015", "browser", "module", "main"],
|
|
488
490
|
entryNames: "[dir]/[name]",
|
|
489
491
|
entryPoints: {
|
|
492
|
+
"sd-polyfills": "virtual:sd-polyfills",
|
|
490
493
|
main: this._mainFilePath,
|
|
491
494
|
...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/polyfills.ts"))
|
|
492
495
|
? {
|
|
@@ -556,6 +559,7 @@ export class SdNgBundler {
|
|
|
556
559
|
}),
|
|
557
560
|
plugins: [
|
|
558
561
|
createSourcemapIgnorelistPlugin(),
|
|
562
|
+
SdPolyfillPlugin(["Chrome >= 61"]),
|
|
559
563
|
createSdNgPlugin(this._opt, this._modifiedFileSet, this._ngResultCache),
|
|
560
564
|
...(this._conf.builderType === "electron"
|
|
561
565
|
? []
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Plugin, PluginBuild } from "esbuild";
|
|
2
|
+
import compat from "core-js-compat";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { PathUtils } from "@simplysm/sd-core-node";
|
|
5
|
+
|
|
6
|
+
const _require = createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
const SD_POLYFILL_NS = "sd-polyfill";
|
|
9
|
+
const SD_POLYFILL_FILTER = /^virtual:sd-polyfills$/;
|
|
10
|
+
|
|
11
|
+
export function SdPolyfillPlugin(browserslistQuery: string[]): Plugin {
|
|
12
|
+
return {
|
|
13
|
+
name: "sd-polyfill-plugin",
|
|
14
|
+
setup(build: PluginBuild) {
|
|
15
|
+
build.onResolve({ filter: SD_POLYFILL_FILTER }, () => ({
|
|
16
|
+
path: "sd-polyfills",
|
|
17
|
+
namespace: SD_POLYFILL_NS,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
build.onLoad({ filter: /.*/, namespace: SD_POLYFILL_NS }, () => {
|
|
21
|
+
const { list } = compat({
|
|
22
|
+
targets: browserslistQuery,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const lines: string[] = [];
|
|
26
|
+
|
|
27
|
+
// core-js 모듈 (절대 경로로 resolve하여 소비 프로젝트의 node_modules 의존 제거)
|
|
28
|
+
for (const mod of list) {
|
|
29
|
+
try {
|
|
30
|
+
const absPath = _require.resolve(`core-js/modules/${mod}.js`);
|
|
31
|
+
lines.push(`import "${PathUtils.posix(absPath)}";`);
|
|
32
|
+
} catch {
|
|
33
|
+
// 모듈이 존재하지 않으면 skip (WeakRef 등 polyfill 불가 항목)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// AbortController (Chrome 66+)
|
|
38
|
+
try {
|
|
39
|
+
const absPath = _require.resolve(
|
|
40
|
+
"abortcontroller-polyfill/dist/abortcontroller-polyfill-only",
|
|
41
|
+
);
|
|
42
|
+
lines.push(`import "${PathUtils.posix(absPath)}";`);
|
|
43
|
+
} catch {
|
|
44
|
+
// skip
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ResizeObserver (Chrome 64+)
|
|
48
|
+
try {
|
|
49
|
+
const absPath = _require.resolve("resize-observer-polyfill");
|
|
50
|
+
lines.push(`import RO from "${PathUtils.posix(absPath)}";`);
|
|
51
|
+
lines.push(
|
|
52
|
+
`if (typeof window !== "undefined" && !("ResizeObserver" in window)) { window.ResizeObserver = RO; }`,
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// skip
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { contents: lines.join("\n"), loader: "js" };
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|