@simplysm/sd-cli 14.0.11 → 14.0.13
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/README.md +58 -253
- package/dist/angular/client-transform-stylesheet.js +1 -1
- package/dist/angular/client-transform-stylesheet.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +4 -2
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +73 -36
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/angular/vite-postcss-inline-plugin.d.ts +1 -1
- package/dist/angular/vite-postcss-inline-plugin.js +1 -1
- package/dist/capacitor/capacitor.d.ts +20 -2
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +155 -28
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/build.d.ts +3 -10
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +3 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -9
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -9
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/device.d.ts +3 -3
- package/dist/commands/device.js +5 -5
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/publish.d.ts +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +24 -26
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/replace-deps.d.ts +3 -3
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/typecheck.d.ts +4 -3
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +5 -11
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +9 -9
- package/dist/commands/watch.js +9 -9
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +42 -3
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts +1 -1
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +3 -1
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts +7 -7
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +3 -3
- package/dist/engines/ServerEsbuildEngine.d.ts +7 -7
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
- package/dist/engines/ServerEsbuildEngine.js +3 -3
- package/dist/engines/TscEngine.d.ts +7 -7
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +3 -3
- package/dist/engines/ViteEngine.d.ts +7 -1
- package/dist/engines/ViteEngine.d.ts.map +1 -1
- package/dist/engines/ViteEngine.js +13 -12
- package/dist/engines/ViteEngine.js.map +1 -1
- package/dist/engines/index.d.ts +9 -5
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +7 -5
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/types.d.ts +20 -20
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/infra/ResultCollector.d.ts +9 -9
- package/dist/infra/ResultCollector.js +8 -8
- package/dist/infra/SignalHandler.d.ts +7 -7
- package/dist/infra/SignalHandler.js +7 -7
- package/dist/infra/WorkerManager.d.ts +14 -14
- package/dist/infra/WorkerManager.js +14 -14
- package/dist/orchestrators/BuildOrchestrator.d.ts +25 -25
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +34 -30
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.d.ts +7 -7
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.js +34 -34
- package/dist/orchestrators/DevWatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +2 -2
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +15 -8
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.d.ts +3 -3
- package/dist/sd-cli.js +16 -16
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +105 -105
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/angular-compiler.js +5 -5
- package/dist/utils/angular-compiler.js.map +1 -1
- package/dist/utils/build-env.d.ts +1 -1
- package/dist/utils/build-env.js +1 -1
- package/dist/utils/concurrency.d.ts +7 -7
- package/dist/utils/concurrency.js +7 -7
- package/dist/utils/copy-public.d.ts +9 -9
- package/dist/utils/copy-public.js +17 -17
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/copy-src.d.ts +9 -9
- package/dist/utils/copy-src.js +11 -11
- package/dist/utils/copy-src.js.map +1 -1
- package/dist/utils/engine-stop.d.ts +8 -9
- package/dist/utils/engine-stop.d.ts.map +1 -1
- package/dist/utils/engine-stop.js +9 -10
- package/dist/utils/engine-stop.js.map +1 -1
- package/dist/utils/esbuild-config.d.ts +23 -23
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +25 -25
- package/dist/utils/esbuild-config.js.map +1 -1
- package/dist/utils/lint-with-program.d.ts +15 -15
- package/dist/utils/lint-with-program.d.ts.map +1 -1
- package/dist/utils/lint-with-program.js +29 -29
- package/dist/utils/lint-with-program.js.map +1 -1
- package/dist/utils/ngtsc-build-core.d.ts +8 -8
- package/dist/utils/ngtsc-build-core.d.ts.map +1 -1
- package/dist/utils/ngtsc-build-core.js +14 -14
- package/dist/utils/ngtsc-build-core.js.map +1 -1
- package/dist/utils/output-path-rewriter.d.ts +14 -14
- package/dist/utils/output-path-rewriter.js +18 -18
- package/dist/utils/output-path-rewriter.js.map +1 -1
- package/dist/utils/output-utils.d.ts +6 -6
- package/dist/utils/output-utils.js +11 -11
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/utils/package-utils.d.ts +21 -21
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +56 -45
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/replace-deps.d.ts +25 -25
- package/dist/utils/replace-deps.d.ts.map +1 -1
- package/dist/utils/replace-deps.js +84 -65
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts +3 -3
- package/dist/utils/sd-config.js +3 -3
- package/dist/utils/tsc-build.d.ts +13 -13
- package/dist/utils/tsc-build.d.ts.map +1 -1
- package/dist/utils/tsc-build.js +9 -9
- package/dist/utils/tsc-build.js.map +1 -1
- package/dist/utils/tsconfig.d.ts +11 -9
- package/dist/utils/tsconfig.d.ts.map +1 -1
- package/dist/utils/tsconfig.js +11 -9
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-non-package.d.ts +5 -6
- package/dist/utils/typecheck-non-package.d.ts.map +1 -1
- package/dist/utils/typecheck-non-package.js +7 -8
- package/dist/utils/typecheck-non-package.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts +8 -8
- package/dist/utils/typecheck-serialization.d.ts.map +1 -1
- package/dist/utils/typecheck-serialization.js +12 -16
- package/dist/utils/typecheck-serialization.js.map +1 -1
- package/dist/utils/vite-config.d.ts +12 -5
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +95 -41
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/vite-scope-watch-plugin.d.ts.map +1 -1
- package/dist/utils/vite-scope-watch-plugin.js +1 -1
- package/dist/utils/vite-scope-watch-plugin.js.map +1 -1
- package/dist/utils/worker-events.d.ts +12 -12
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-events.js +10 -10
- package/dist/utils/worker-events.js.map +1 -1
- package/dist/utils/worker-utils.d.ts +12 -13
- package/dist/utils/worker-utils.d.ts.map +1 -1
- package/dist/utils/worker-utils.js +12 -13
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +5 -7
- package/dist/vitest-plugin.js.map +1 -1
- package/dist/workers/client.worker.d.ts +8 -2
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +215 -6
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +1 -1
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +7 -7
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +2 -2
- package/dist/workers/lint.worker.js +2 -2
- package/dist/workers/ngtsc-build.worker.js +30 -30
- package/dist/workers/ngtsc-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts +17 -17
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +46 -46
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-runtime.worker.d.ts +7 -7
- package/dist/workers/server-runtime.worker.d.ts.map +1 -1
- package/dist/workers/server-runtime.worker.js +17 -17
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/docs/config.md +340 -0
- package/docs/publish-configuration-types.md +87 -0
- package/docs/pwa-configuration-types.md +55 -0
- package/docs/vitest-plugin.md +47 -0
- package/package.json +9 -7
- package/src/angular/client-transform-stylesheet.ts +1 -1
- package/src/angular/vite-angular-plugin.ts +89 -39
- package/src/angular/vite-postcss-inline-plugin.ts +1 -1
- package/src/capacitor/capacitor.ts +185 -38
- package/src/commands/build.ts +3 -10
- package/src/commands/check.ts +3 -3
- package/src/commands/dev.ts +3 -9
- package/src/commands/device.ts +5 -5
- package/src/commands/publish.ts +30 -26
- package/src/commands/replace-deps.ts +3 -3
- package/src/commands/typecheck.ts +7 -13
- package/src/commands/watch.ts +9 -9
- package/src/electron/electron.ts +49 -4
- package/src/engines/BaseEngine.ts +4 -1
- package/src/engines/NgtscEngine.ts +7 -7
- package/src/engines/ServerEsbuildEngine.ts +7 -7
- package/src/engines/TscEngine.ts +7 -7
- package/src/engines/ViteEngine.ts +18 -13
- package/src/engines/index.ts +11 -5
- package/src/engines/types.ts +20 -20
- package/src/infra/ResultCollector.ts +9 -9
- package/src/infra/SignalHandler.ts +7 -7
- package/src/infra/WorkerManager.ts +14 -14
- package/src/orchestrators/BuildOrchestrator.ts +42 -38
- package/src/orchestrators/DevWatchOrchestrator.ts +36 -36
- package/src/sd-cli-entry.ts +15 -8
- package/src/sd-cli.ts +16 -16
- package/src/sd-config.types.ts +107 -107
- package/src/utils/angular-compiler.ts +5 -5
- package/src/utils/build-env.ts +1 -1
- package/src/utils/concurrency.ts +7 -7
- package/src/utils/copy-public.ts +17 -17
- package/src/utils/copy-src.ts +11 -11
- package/src/utils/engine-stop.ts +9 -10
- package/src/utils/esbuild-config.ts +29 -29
- package/src/utils/lint-with-program.ts +34 -34
- package/src/utils/ngtsc-build-core.ts +17 -17
- package/src/utils/output-path-rewriter.ts +18 -18
- package/src/utils/output-utils.ts +11 -11
- package/src/utils/package-utils.ts +57 -45
- package/src/utils/replace-deps.ts +92 -67
- package/src/utils/sd-config.ts +3 -3
- package/src/utils/tsc-build.ts +18 -18
- package/src/utils/tsconfig.ts +11 -9
- package/src/utils/typecheck-non-package.ts +7 -8
- package/src/utils/typecheck-serialization.ts +13 -15
- package/src/utils/vite-config.ts +108 -46
- package/src/utils/vite-scope-watch-plugin.ts +6 -1
- package/src/utils/worker-events.ts +16 -16
- package/src/utils/worker-utils.ts +12 -13
- package/src/vitest-plugin.ts +5 -8
- package/src/workers/client.worker.ts +246 -7
- package/src/workers/library-build.worker.ts +8 -8
- package/src/workers/lint.worker.ts +2 -2
- package/src/workers/ngtsc-build.worker.ts +31 -31
- package/src/workers/server-build.worker.ts +60 -60
- package/src/workers/server-runtime.worker.ts +22 -22
- package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +1 -0
- package/tests/angular/vite-angular-plugin-hmr.spec.ts +78 -0
- package/tests/angular/vite-angular-plugin.spec.ts +67 -0
- package/tests/capacitor/capacitor-build.spec.ts +93 -11
- package/tests/capacitor/capacitor-icon.spec.ts +7 -5
- package/tests/capacitor/capacitor-init.spec.ts +124 -10
- package/tests/capacitor/capacitor-run.spec.ts +14 -17
- package/tests/capacitor/capacitor-workspace.spec.ts +5 -3
- package/tests/commands/check.spec.ts +2 -2
- package/tests/commands/publish.spec.ts +2 -2
- package/tests/commands/typecheck.spec.ts +8 -0
- package/tests/electron/electron.spec.ts +12 -10
- package/tests/engines/base-engine.spec.ts +37 -0
- package/tests/engines/vite-engine.spec.ts +115 -3
- package/tests/utils/vite-config.spec.ts +162 -90
- package/tests/workers/client-worker.spec.ts +690 -0
- package/tests/workers/server-build-worker.spec.ts +3 -3
|
@@ -23,8 +23,10 @@ const logger = consola.withTag("sd:cli:angular");
|
|
|
23
23
|
export interface SdAngularPluginOptions {
|
|
24
24
|
/** tsconfig.json 경로 */
|
|
25
25
|
tsconfig: string;
|
|
26
|
-
/** 개발 모드 */
|
|
26
|
+
/** 개발 모드 (HMR, advancedOptimizations 제어) */
|
|
27
27
|
dev: boolean;
|
|
28
|
+
/** 소스맵 생성 여부 (dev와 독립적으로 제어) */
|
|
29
|
+
sourcemap?: boolean;
|
|
28
30
|
/** rebuild 시작 콜백 (CLI 상태 보고용) */
|
|
29
31
|
onBuildStart?: () => void;
|
|
30
32
|
/** rebuild 완료 콜백 (CLI 상태 보고용) */
|
|
@@ -34,7 +36,7 @@ export interface SdAngularPluginOptions {
|
|
|
34
36
|
warnings?: string[];
|
|
35
37
|
lint?: LintWithProgramResult;
|
|
36
38
|
}) => void;
|
|
37
|
-
/**
|
|
39
|
+
/** 컴파일의 ts.Program을 사용하여 lint 실행 */
|
|
38
40
|
enableLint?: boolean;
|
|
39
41
|
/** browserslist 타겟 (정규화된 배열) */
|
|
40
42
|
browserslist?: string[];
|
|
@@ -68,7 +70,7 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
68
70
|
) as { name?: string };
|
|
69
71
|
pkgName = pkgJson.name ?? "unknown";
|
|
70
72
|
} catch {
|
|
71
|
-
//
|
|
73
|
+
// 무시
|
|
72
74
|
}
|
|
73
75
|
lintRunner = new LintWithProgramRunner({
|
|
74
76
|
cwd: process.cwd(),
|
|
@@ -83,12 +85,20 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
83
85
|
let hmrLock: Promise<void> = Promise.resolve();
|
|
84
86
|
const scssDependencies = new Map<string, Set<string>>();
|
|
85
87
|
|
|
88
|
+
const enableSourcemap = options.sourcemap ?? options.dev;
|
|
89
|
+
|
|
90
|
+
// Pre-bundle transformer: optimizeDeps의 esbuild 단계에서 Angular Linker 실행
|
|
91
|
+
const prebundleTransformer = new JavaScriptTransformer(
|
|
92
|
+
{ sourcemap: enableSourcemap, jit: false, thirdPartySourcemaps: enableSourcemap },
|
|
93
|
+
1,
|
|
94
|
+
);
|
|
95
|
+
|
|
86
96
|
function createJsTransformer(): JavaScriptTransformer {
|
|
87
97
|
const maxThreads = Math.max(1, Math.floor((os.cpus().length * 2) / 3));
|
|
88
98
|
return new JavaScriptTransformer(
|
|
89
99
|
{
|
|
90
|
-
sourcemap:
|
|
91
|
-
thirdPartySourcemaps:
|
|
100
|
+
sourcemap: enableSourcemap,
|
|
101
|
+
thirdPartySourcemaps: enableSourcemap,
|
|
92
102
|
advancedOptimizations: !options.dev,
|
|
93
103
|
jit: false,
|
|
94
104
|
},
|
|
@@ -107,6 +117,24 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
107
117
|
ngJitMode: "false",
|
|
108
118
|
ngHmrMode: options.dev ? undefined : "false",
|
|
109
119
|
},
|
|
120
|
+
optimizeDeps: {
|
|
121
|
+
esbuildOptions: {
|
|
122
|
+
plugins: [
|
|
123
|
+
{
|
|
124
|
+
name: "angular-vite-optimize-deps",
|
|
125
|
+
setup(build: { onLoad: Function }) {
|
|
126
|
+
build.onLoad(
|
|
127
|
+
{ filter: /\.[cm]?js$/ },
|
|
128
|
+
async (args: { path: string }) => ({
|
|
129
|
+
contents: await prebundleTransformer.transformFile(args.path),
|
|
130
|
+
loader: "js" as const,
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
110
138
|
};
|
|
111
139
|
},
|
|
112
140
|
|
|
@@ -188,7 +216,7 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
188
216
|
logger.error(err);
|
|
189
217
|
}
|
|
190
218
|
|
|
191
|
-
//
|
|
219
|
+
// lint 실행 (활성화된 경우)
|
|
192
220
|
let initialLintResult: LintWithProgramResult | undefined;
|
|
193
221
|
if (options.enableLint === true) {
|
|
194
222
|
initialLintResult = await getOrCreateLintRunner().lint({
|
|
@@ -196,7 +224,7 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
196
224
|
});
|
|
197
225
|
}
|
|
198
226
|
|
|
199
|
-
//
|
|
227
|
+
// 초기 빌드 결과 보고 (dev, prod 공통)
|
|
200
228
|
options.onBuild?.({
|
|
201
229
|
success: diagnosticResult.errors.length === 0,
|
|
202
230
|
errors: diagnosticResult.errors.map((e) => e.message),
|
|
@@ -218,14 +246,13 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
218
246
|
if (compiler == null || !options.dev) return;
|
|
219
247
|
if (
|
|
220
248
|
!file.endsWith(".ts") &&
|
|
221
|
-
!file.endsWith(".tsx") &&
|
|
222
249
|
!file.endsWith(".html") &&
|
|
223
250
|
!file.endsWith(".scss")
|
|
224
251
|
) {
|
|
225
252
|
return;
|
|
226
253
|
}
|
|
227
254
|
|
|
228
|
-
//
|
|
255
|
+
// 의존성 필터: TypeScript program에 포함되지 않은 파일은 건너뜀
|
|
229
256
|
const normalizedFile = pathx.posix(file);
|
|
230
257
|
const programFiles = compiler.getTsProgram().getSourceFiles();
|
|
231
258
|
const isInProgram = programFiles.some(
|
|
@@ -269,13 +296,13 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
269
296
|
const diagnosticResult = collectAndFormatDiagnostics(compiler, process.cwd());
|
|
270
297
|
reportDiagnostics(diagnosticResult);
|
|
271
298
|
|
|
272
|
-
//
|
|
299
|
+
// 영향받은 ts.SourceFile 집합을 파일명 문자열로 변환 (incremental lint용)
|
|
273
300
|
const affectedFileNames = new Set<string>();
|
|
274
301
|
for (const sf of updateResult.affectedFiles) {
|
|
275
302
|
affectedFileNames.add(pathx.posix(sf.fileName));
|
|
276
303
|
}
|
|
277
304
|
|
|
278
|
-
//
|
|
305
|
+
// lint 실행 (활성화된 경우)
|
|
279
306
|
let lintResult: LintWithProgramResult | undefined;
|
|
280
307
|
if (options.enableLint === true) {
|
|
281
308
|
lintResult = await getOrCreateLintRunner().lint({
|
|
@@ -306,21 +333,36 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
306
333
|
},
|
|
307
334
|
|
|
308
335
|
async transform(_code, id) {
|
|
309
|
-
if (
|
|
336
|
+
if (jsTransformer == null) return;
|
|
310
337
|
|
|
311
|
-
|
|
312
|
-
const emittedContent = emittedFiles.get(normalizedId);
|
|
313
|
-
if (emittedContent == null) return;
|
|
338
|
+
let code = _code;
|
|
314
339
|
|
|
315
|
-
|
|
316
|
-
|
|
340
|
+
// Phase 1: TS 컴파일 — .ts 파일은 AngularCompiler가 emit한 JS로 교체
|
|
341
|
+
if (id.endsWith(".ts")) {
|
|
342
|
+
const normalizedId = pathx.posix(id);
|
|
343
|
+
const emittedContent = emittedFiles.get(normalizedId);
|
|
344
|
+
if (emittedContent == null) return;
|
|
345
|
+
code = emittedContent;
|
|
346
|
+
} else if (!id.endsWith(".mjs") && !id.endsWith(".js")) {
|
|
347
|
+
return;
|
|
317
348
|
}
|
|
318
349
|
|
|
319
|
-
// AOT
|
|
320
|
-
const transformed = await jsTransformer.transformData(
|
|
321
|
-
const
|
|
350
|
+
// Phase 2: JS 변환 — Angular Linker로 partial → full AOT 링킹 + 최적화
|
|
351
|
+
const transformed = await jsTransformer.transformData(pathx.posix(id), code, false);
|
|
352
|
+
const transformedCode = new TextDecoder().decode(transformed);
|
|
322
353
|
|
|
323
|
-
|
|
354
|
+
// 인라인 소스맵 분리 (Rollup 경고 방지)
|
|
355
|
+
const inlineMapMatch = transformedCode.match(
|
|
356
|
+
/\/\/# sourceMappingURL=data:application\/json;(?:charset=utf-8;)?base64,(.+)$/m,
|
|
357
|
+
);
|
|
358
|
+
if (inlineMapMatch != null) {
|
|
359
|
+
const mapJson = atob(inlineMapMatch[1]);
|
|
360
|
+
return {
|
|
361
|
+
code: transformedCode.slice(0, inlineMapMatch.index),
|
|
362
|
+
map: JSON.parse(mapJson),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
return { code: transformedCode, map: null };
|
|
324
366
|
},
|
|
325
367
|
|
|
326
368
|
async buildEnd() {
|
|
@@ -330,6 +372,7 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
330
372
|
await jsTransformer.close();
|
|
331
373
|
jsTransformer = undefined;
|
|
332
374
|
}
|
|
375
|
+
await prebundleTransformer.close();
|
|
333
376
|
compiler = undefined;
|
|
334
377
|
emittedFiles.clear();
|
|
335
378
|
}
|
|
@@ -337,24 +380,24 @@ export function sdAngularPlugin(options: SdAngularPluginOptions): Plugin {
|
|
|
337
380
|
|
|
338
381
|
configureServer(server: ViteDevServer) {
|
|
339
382
|
// component-middleware 등록 (HMR template updates 서빙)
|
|
340
|
-
server.middlewares.use(angularComponentMiddleware(templateUpdates));
|
|
383
|
+
server.middlewares.use(angularComponentMiddleware(templateUpdates, server.config.base));
|
|
341
384
|
|
|
342
385
|
// dev server 종료 시 리소스 정리
|
|
343
386
|
server.httpServer?.on("close", () => {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
387
|
+
void Promise.all([
|
|
388
|
+
jsTransformer?.close(),
|
|
389
|
+
prebundleTransformer.close(),
|
|
390
|
+
])
|
|
391
|
+
.catch((err: unknown) => {
|
|
392
|
+
logger.error(
|
|
393
|
+
`Resource dispose failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
394
|
+
);
|
|
395
|
+
})
|
|
396
|
+
.finally(() => {
|
|
397
|
+
jsTransformer = undefined;
|
|
398
|
+
compiler = undefined;
|
|
399
|
+
emittedFiles.clear();
|
|
400
|
+
});
|
|
358
401
|
});
|
|
359
402
|
},
|
|
360
403
|
};
|
|
@@ -401,15 +444,22 @@ function collectAndFormatDiagnostics(compiler: AngularCompiler, cwd: string): Di
|
|
|
401
444
|
|
|
402
445
|
function angularComponentMiddleware(
|
|
403
446
|
templateUpdates: Map<string, string>,
|
|
447
|
+
basePath: string,
|
|
404
448
|
): (req: IncomingMessage, res: ServerResponse, next: () => void) => void {
|
|
405
449
|
return (req, res, next) => {
|
|
406
|
-
|
|
450
|
+
const rawUrl = req.url ?? "";
|
|
451
|
+
const parsedUrl = new URL(rawUrl, "http://localhost");
|
|
452
|
+
const pathname = decodeURIComponent(parsedUrl.pathname);
|
|
453
|
+
const strippedPathname =
|
|
454
|
+
basePath !== "/" && pathname.startsWith(basePath)
|
|
455
|
+
? pathname.slice(basePath.length - 1)
|
|
456
|
+
: pathname;
|
|
457
|
+
if (!strippedPathname.includes("/@ng/component")) {
|
|
407
458
|
next();
|
|
408
459
|
return;
|
|
409
460
|
}
|
|
410
461
|
|
|
411
|
-
const
|
|
412
|
-
const componentId = url.searchParams.get("c") ?? "";
|
|
462
|
+
const componentId = parsedUrl.searchParams.get("c") ?? "";
|
|
413
463
|
const body = templateUpdates.get(encodeURIComponent(componentId)) ?? "";
|
|
414
464
|
|
|
415
465
|
res.writeHead(200, {
|
|
@@ -9,7 +9,7 @@ export interface SdPostCssInlinePluginOptions {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* JS 파일 내 Angular @Component 인라인 스타일에 PostCSS를 적용하는 Vite 플러그인.
|
|
13
13
|
*
|
|
14
14
|
* TS AST로 @Component decorator의 `styles` 배열에서 CSS 문자열을 추출하고,
|
|
15
15
|
* PostCSS를 적용한 후 교체한다.
|