@simplysm/sd-cli 12.16.37 → 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.
@@ -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;
@@ -370,7 +371,7 @@ export class SdNgBundler {
370
371
  mainFields: ["es2020", "es2015", "browser", "module", "main"],
371
372
  entryNames: "[dir]/[name]",
372
373
  entryPoints: {
373
- "sd-polyfills": path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../lib/chrome61-polyfills.js"),
374
+ "sd-polyfills": "virtual:sd-polyfills",
374
375
  main: this._mainFilePath,
375
376
  ...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/polyfills.ts"))
376
377
  ? {
@@ -433,6 +434,7 @@ export class SdNgBundler {
433
434
  }),
434
435
  plugins: [
435
436
  createSourcemapIgnorelistPlugin(),
437
+ SdPolyfillPlugin(["Chrome >= 61"]),
436
438
  createSdNgPlugin(this._opt, this._modifiedFileSet, this._ngResultCache),
437
439
  ...(this._conf.builderType === "electron"
438
440
  ? []
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "esbuild";
2
+ export declare function SdPolyfillPlugin(browserslistQuery: string[]): Plugin;
@@ -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.37",
3
+ "version": "12.16.38",
4
4
  "description": "심플리즘 패키지 - CLI",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -17,14 +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.37",
21
- "@simplysm/sd-core-node": "12.16.37",
22
- "@simplysm/sd-service-server": "12.16.37",
23
- "@simplysm/sd-storage": "12.16.37",
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
24
  "abortcontroller-polyfill": "^1.7.8",
25
25
  "browserslist": "^4.28.1",
26
26
  "cordova": "^13.0.0",
27
27
  "core-js": "^3.49.0",
28
+ "core-js-compat": "^3.49.0",
28
29
  "electron": "^33.4.11",
29
30
  "electron-builder": "^25.1.8",
30
31
  "esbuild": "0.25.9",
@@ -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"]);
@@ -488,10 +489,7 @@ export class SdNgBundler {
488
489
  mainFields: ["es2020", "es2015", "browser", "module", "main"],
489
490
  entryNames: "[dir]/[name]",
490
491
  entryPoints: {
491
- "sd-polyfills": path.resolve(
492
- path.dirname(fileURLToPath(import.meta.url)),
493
- "../../../lib/chrome61-polyfills.js",
494
- ),
492
+ "sd-polyfills": "virtual:sd-polyfills",
495
493
  main: this._mainFilePath,
496
494
  ...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/polyfills.ts"))
497
495
  ? {
@@ -561,6 +559,7 @@ export class SdNgBundler {
561
559
  }),
562
560
  plugins: [
563
561
  createSourcemapIgnorelistPlugin(),
562
+ SdPolyfillPlugin(["Chrome >= 61"]),
564
563
  createSdNgPlugin(this._opt, this._modifiedFileSet, this._ngResultCache),
565
564
  ...(this._conf.builderType === "electron"
566
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
+ }
@@ -1,46 +0,0 @@
1
- // =============================================================
2
- // Chrome 61+ Polyfills
3
- // core-js는 feature detection 기반 — 이미 지원하는 기능은 skip
4
- // sd-cli가 Angular 클라이언트 빌드 시 자동 주입
5
- // =============================================================
6
-
7
- // -- ES2018 --
8
- import "core-js/actual/promise/finally";
9
-
10
- // -- ES2019 --
11
- import "core-js/actual/array/flat";
12
- import "core-js/actual/array/flat-map";
13
- import "core-js/actual/object/from-entries";
14
- import "core-js/actual/string/trim-start";
15
- import "core-js/actual/string/trim-end";
16
-
17
- // -- ES2020 --
18
- import "core-js/actual/global-this";
19
- import "core-js/actual/string/match-all";
20
- import "core-js/actual/promise/all-settled";
21
-
22
- // -- ES2021 --
23
- import "core-js/actual/promise/any";
24
- import "core-js/actual/aggregate-error";
25
- import "core-js/actual/string/replace-all";
26
- import "core-js/actual/weak-ref";
27
- import "core-js/actual/finalization-registry";
28
-
29
- // -- ES2022 --
30
- import "core-js/actual/array/at";
31
- import "core-js/actual/string/at";
32
- import "core-js/actual/object/has-own";
33
- import "core-js/actual/error/cause";
34
-
35
- // -- Web APIs --
36
- import "core-js/actual/queue-microtask";
37
- import "core-js/actual/structured-clone";
38
-
39
- // -- AbortController (Chrome 66+) --
40
- import "abortcontroller-polyfill/dist/abortcontroller-polyfill-only";
41
-
42
- // -- ResizeObserver (Chrome 64+) --
43
- import ResizeObserver from "resize-observer-polyfill";
44
- if (typeof window !== "undefined" && !("ResizeObserver" in window)) {
45
- window.ResizeObserver = ResizeObserver;
46
- }