@simplysm/sd-cli 14.0.29 → 14.0.32
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/{utils → angular}/angular-build-pipeline.d.ts +0 -2
- package/dist/angular/angular-build-pipeline.d.ts.map +1 -0
- package/dist/{utils → angular}/angular-build-pipeline.js +3 -6
- package/dist/angular/angular-build-pipeline.js.map +1 -0
- package/dist/{utils → angular}/angular-build.d.ts +1 -1
- package/dist/angular/angular-build.d.ts.map +1 -0
- package/dist/{utils → angular}/angular-build.js +1 -1
- package/dist/angular/angular-build.js.map +1 -0
- package/dist/{utils → angular}/angular-compiler.d.ts +0 -3
- package/dist/angular/angular-compiler.d.ts.map +1 -0
- package/dist/{utils → angular}/angular-compiler.js +1 -45
- package/dist/angular/angular-compiler.js.map +1 -0
- package/dist/angular/client-transform-stylesheet.js +1 -1
- package/dist/angular/client-transform-stylesheet.js.map +1 -1
- package/dist/{utils → angular}/ngtsc-build-core.d.ts +3 -3
- package/dist/angular/ngtsc-build-core.d.ts.map +1 -0
- package/dist/angular/ngtsc-build-core.js.map +1 -0
- package/dist/angular/scss-compiler.d.ts.map +1 -0
- package/dist/angular/scss-compiler.js.map +1 -0
- package/dist/angular/vite-angular-plugin.d.ts +2 -10
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +20 -286
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/capacitor/capacitor-build.d.ts +14 -0
- package/dist/capacitor/capacitor-build.d.ts.map +1 -0
- package/dist/capacitor/capacitor-build.js +105 -0
- package/dist/capacitor/capacitor-build.js.map +1 -0
- package/dist/capacitor/capacitor-config-writer.d.ts +11 -0
- package/dist/capacitor/capacitor-config-writer.d.ts.map +1 -0
- package/dist/capacitor/capacitor-config-writer.js +54 -0
- package/dist/capacitor/capacitor-config-writer.js.map +1 -0
- package/dist/capacitor/capacitor-icon.d.ts +5 -0
- package/dist/capacitor/capacitor-icon.d.ts.map +1 -0
- package/dist/capacitor/capacitor-icon.js +58 -0
- package/dist/capacitor/capacitor-icon.js.map +1 -0
- package/dist/capacitor/capacitor-npm-config.d.ts +11 -0
- package/dist/capacitor/capacitor-npm-config.d.ts.map +1 -0
- package/dist/capacitor/capacitor-npm-config.js +145 -0
- package/dist/capacitor/capacitor-npm-config.js.map +1 -0
- package/dist/capacitor/capacitor.d.ts +0 -45
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +15 -354
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.js +2 -2
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -3
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -3
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/lint.d.ts +1 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +1 -1
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish/deployment-phase.d.ts +12 -0
- package/dist/commands/publish/deployment-phase.d.ts.map +1 -0
- package/dist/commands/publish/deployment-phase.js +94 -0
- package/dist/commands/publish/deployment-phase.js.map +1 -0
- package/dist/commands/publish/env-utils.d.ts +10 -0
- package/dist/commands/publish/env-utils.d.ts.map +1 -0
- package/dist/commands/publish/env-utils.js +41 -0
- package/dist/commands/publish/env-utils.js.map +1 -0
- package/dist/commands/publish/git-phase.d.ts +12 -0
- package/dist/commands/publish/git-phase.d.ts.map +1 -0
- package/dist/commands/publish/git-phase.js +79 -0
- package/dist/commands/publish/git-phase.js.map +1 -0
- package/dist/commands/{publish.d.ts → publish/index.d.ts} +1 -1
- package/dist/commands/publish/index.d.ts.map +1 -0
- package/dist/commands/publish/index.js +211 -0
- package/dist/commands/publish/index.js.map +1 -0
- package/dist/commands/publish/local-publisher.d.ts +6 -0
- package/dist/commands/publish/local-publisher.d.ts.map +1 -0
- package/dist/commands/publish/local-publisher.js +16 -0
- package/dist/commands/publish/local-publisher.js.map +1 -0
- package/dist/commands/publish/npm-publisher.d.ts +6 -0
- package/dist/commands/publish/npm-publisher.d.ts.map +1 -0
- package/dist/commands/publish/npm-publisher.js +21 -0
- package/dist/commands/publish/npm-publisher.js.map +1 -0
- package/dist/commands/publish/post-publish-phase.d.ts +8 -0
- package/dist/commands/publish/post-publish-phase.d.ts.map +1 -0
- package/dist/commands/publish/post-publish-phase.js +34 -0
- package/dist/commands/publish/post-publish-phase.js.map +1 -0
- package/dist/commands/publish/storage-publisher.d.ts +18 -0
- package/dist/commands/publish/storage-publisher.d.ts.map +1 -0
- package/dist/commands/publish/storage-publisher.js +173 -0
- package/dist/commands/publish/storage-publisher.js.map +1 -0
- package/dist/commands/publish/version-upgrade.d.ts +28 -0
- package/dist/commands/publish/version-upgrade.d.ts.map +1 -0
- package/dist/commands/publish/version-upgrade.js +96 -0
- package/dist/commands/publish/version-upgrade.js.map +1 -0
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/commands/watch.d.ts +3 -4
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +3 -4
- package/dist/commands/watch.js.map +1 -1
- package/dist/deps/replace-deps/collect-deps.d.ts +6 -0
- package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -0
- package/dist/deps/replace-deps/collect-deps.js +71 -0
- package/dist/deps/replace-deps/collect-deps.js.map +1 -0
- package/dist/{utils/replace-deps.d.ts → deps/replace-deps/replace-deps-resolve.d.ts} +7 -24
- package/dist/deps/replace-deps/replace-deps-resolve.d.ts.map +1 -0
- package/dist/{utils/replace-deps.js → deps/replace-deps/replace-deps-resolve.js} +4 -152
- package/dist/deps/replace-deps/replace-deps-resolve.js.map +1 -0
- package/dist/deps/replace-deps/replace-deps.d.ts +36 -0
- package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -0
- package/dist/deps/replace-deps/replace-deps.js +155 -0
- package/dist/deps/replace-deps/replace-deps.js.map +1 -0
- package/dist/{utils → deps/server-externals}/server-production-files.d.ts +1 -1
- package/dist/deps/server-externals/server-production-files.d.ts.map +1 -0
- package/dist/{utils → deps/server-externals}/server-production-files.js +1 -1
- package/dist/deps/server-externals/server-production-files.js.map +1 -0
- package/dist/dev-server/dev-http-server.d.ts +23 -0
- package/dist/dev-server/dev-http-server.d.ts.map +1 -0
- package/dist/dev-server/dev-http-server.js +116 -0
- package/dist/dev-server/dev-http-server.js.map +1 -0
- package/dist/dev-server/hmr-client-script.d.ts +13 -0
- package/dist/dev-server/hmr-client-script.d.ts.map +1 -0
- package/dist/dev-server/hmr-client-script.js +73 -0
- package/dist/dev-server/hmr-client-script.js.map +1 -0
- package/dist/dev-server/hmr-service.d.ts +23 -0
- package/dist/dev-server/hmr-service.d.ts.map +1 -0
- package/dist/dev-server/hmr-service.js +139 -0
- package/dist/dev-server/hmr-service.js.map +1 -0
- package/dist/electron/electron.d.ts +5 -0
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +17 -24
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts +18 -4
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +45 -66
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/{ViteEngine.d.ts → EsbuildClientEngine.d.ts} +11 -18
- package/dist/engines/EsbuildClientEngine.d.ts.map +1 -0
- package/dist/engines/{ViteEngine.js → EsbuildClientEngine.js} +28 -55
- package/dist/engines/EsbuildClientEngine.js.map +1 -0
- package/dist/engines/NgtscEngine.d.ts +2 -2
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +1 -9
- package/dist/engines/NgtscEngine.js.map +1 -1
- package/dist/engines/ServerEsbuildEngine.d.ts +2 -2
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
- package/dist/engines/ServerEsbuildEngine.js +1 -9
- package/dist/engines/ServerEsbuildEngine.js.map +1 -1
- package/dist/engines/TscEngine.d.ts +2 -2
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +1 -9
- package/dist/engines/TscEngine.js.map +1 -1
- package/dist/engines/index.d.ts +15 -5
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +21 -5
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/types.d.ts +3 -3
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/esbuild/esbuild-client-config.d.ts +38 -0
- package/dist/esbuild/esbuild-client-config.d.ts.map +1 -0
- package/dist/esbuild/esbuild-client-config.js +171 -0
- package/dist/esbuild/esbuild-client-config.js.map +1 -0
- package/dist/esbuild/esbuild-config.d.ts.map +1 -0
- package/dist/{utils → esbuild}/esbuild-config.js +1 -0
- package/dist/esbuild/esbuild-config.js.map +1 -0
- package/dist/esbuild/esbuild-index-html.d.ts +39 -0
- package/dist/esbuild/esbuild-index-html.d.ts.map +1 -0
- package/dist/esbuild/esbuild-index-html.js +68 -0
- package/dist/esbuild/esbuild-index-html.js.map +1 -0
- package/dist/esbuild/esbuild-pwa.d.ts +21 -0
- package/dist/esbuild/esbuild-pwa.d.ts.map +1 -0
- package/dist/esbuild/esbuild-pwa.js +105 -0
- package/dist/esbuild/esbuild-pwa.js.map +1 -0
- package/dist/esbuild/esbuild-scss-plugin.d.ts +6 -0
- package/dist/esbuild/esbuild-scss-plugin.d.ts.map +1 -0
- package/dist/esbuild/esbuild-scss-plugin.js +41 -0
- package/dist/esbuild/esbuild-scss-plugin.js.map +1 -0
- package/dist/lint/lint-core.d.ts.map +1 -0
- package/dist/lint/lint-core.js.map +1 -0
- package/dist/lint/lint-utils.d.ts.map +1 -0
- package/dist/lint/lint-utils.js.map +1 -0
- package/dist/lint/lint-with-program.d.ts.map +1 -0
- package/dist/lint/lint-with-program.js.map +1 -0
- package/dist/orchestrators/BaseOrchestrator.d.ts +44 -0
- package/dist/orchestrators/BaseOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/BaseOrchestrator.js +92 -0
- package/dist/orchestrators/BaseOrchestrator.js.map +1 -0
- package/dist/orchestrators/BuildOrchestrator.d.ts +45 -3
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +170 -143
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +39 -0
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/DevOrchestrator.js +249 -0
- package/dist/orchestrators/DevOrchestrator.js.map +1 -0
- package/dist/orchestrators/ServerRuntimeManager.d.ts +22 -0
- package/dist/orchestrators/ServerRuntimeManager.d.ts.map +1 -0
- package/dist/orchestrators/ServerRuntimeManager.js +66 -0
- package/dist/orchestrators/ServerRuntimeManager.js.map +1 -0
- package/dist/orchestrators/TypecheckOrchestrator.d.ts +17 -2
- package/dist/orchestrators/TypecheckOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/TypecheckOrchestrator.js +122 -108
- package/dist/orchestrators/TypecheckOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts +33 -0
- package/dist/orchestrators/WatchOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/WatchOrchestrator.js +158 -0
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -0
- package/dist/orchestrators/types.d.ts +17 -0
- package/dist/orchestrators/types.d.ts.map +1 -0
- package/dist/orchestrators/types.js +2 -0
- package/dist/orchestrators/types.js.map +1 -0
- package/dist/runtime/ResultCollector.d.ts.map +1 -0
- package/dist/runtime/ResultCollector.js.map +1 -0
- package/dist/runtime/SignalHandler.d.ts.map +1 -0
- package/dist/runtime/SignalHandler.js.map +1 -0
- package/dist/{utils → runtime}/engine-stop.d.ts +1 -1
- package/dist/runtime/engine-stop.d.ts.map +1 -0
- package/dist/{utils → runtime}/engine-stop.js +1 -1
- package/dist/runtime/engine-stop.js.map +1 -0
- package/dist/runtime/engine-watch-events.d.ts +43 -0
- package/dist/runtime/engine-watch-events.d.ts.map +1 -0
- package/dist/runtime/engine-watch-events.js +72 -0
- package/dist/runtime/engine-watch-events.js.map +1 -0
- package/dist/{utils → runtime}/rebuild-manager.d.ts +1 -0
- package/dist/runtime/rebuild-manager.d.ts.map +1 -0
- package/dist/{utils → runtime}/rebuild-manager.js +8 -1
- package/dist/runtime/rebuild-manager.js.map +1 -0
- package/dist/runtime/worker-events.d.ts +22 -0
- package/dist/runtime/worker-events.d.ts.map +1 -0
- package/dist/runtime/worker-events.js +2 -0
- package/dist/runtime/worker-events.js.map +1 -0
- package/dist/runtime/worker-utils.d.ts.map +1 -0
- package/dist/runtime/worker-utils.js.map +1 -0
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +61 -54
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +1 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +6 -15
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/typecheck/typecheck-non-package.d.ts.map +1 -0
- package/dist/{utils → typecheck}/typecheck-non-package.js +1 -1
- package/dist/typecheck/typecheck-non-package.js.map +1 -0
- package/dist/typecheck/typecheck-serialization.d.ts.map +1 -0
- package/dist/typecheck/typecheck-serialization.js.map +1 -0
- package/dist/utils/diagnostic-utils.d.ts +5 -0
- package/dist/utils/diagnostic-utils.d.ts.map +1 -1
- package/dist/utils/diagnostic-utils.js +15 -0
- package/dist/utils/diagnostic-utils.js.map +1 -1
- package/dist/utils/orchestrator-utils.d.ts +1 -5
- package/dist/utils/orchestrator-utils.d.ts.map +1 -1
- package/dist/utils/orchestrator-utils.js +2 -5
- package/dist/utils/orchestrator-utils.js.map +1 -1
- package/dist/utils/output-utils.d.ts +1 -1
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/package-classify.d.ts +54 -0
- package/dist/utils/package-classify.d.ts.map +1 -0
- package/dist/utils/package-classify.js +134 -0
- package/dist/utils/package-classify.js.map +1 -0
- package/dist/utils/package-utils.d.ts +1 -58
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +0 -193
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/tsc-build.d.ts +1 -1
- package/dist/utils/tsc-build.d.ts.map +1 -1
- package/dist/utils/tsc-build.js +1 -1
- package/dist/utils/tsc-build.js.map +1 -1
- package/dist/workers/build-change-filter.d.ts +8 -0
- package/dist/workers/build-change-filter.d.ts.map +1 -0
- package/dist/workers/build-change-filter.js +16 -0
- package/dist/workers/build-change-filter.js.map +1 -0
- package/dist/workers/build-watch-paths.d.ts +20 -0
- package/dist/workers/build-watch-paths.d.ts.map +1 -0
- package/dist/workers/build-watch-paths.js +29 -0
- package/dist/workers/build-watch-paths.js.map +1 -0
- package/dist/workers/client.worker.d.ts +11 -18
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +218 -289
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +2 -2
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +13 -24
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +1 -1
- package/dist/workers/lint.worker.d.ts.map +1 -1
- package/dist/workers/lint.worker.js +1 -1
- package/dist/workers/lint.worker.js.map +1 -1
- package/dist/workers/ngtsc-build.worker.d.ts +1 -1
- package/dist/workers/ngtsc-build.worker.d.ts.map +1 -1
- package/dist/workers/ngtsc-build.worker.js +19 -35
- package/dist/workers/ngtsc-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts +2 -2
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +36 -137
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-esbuild-context.d.ts +47 -0
- package/dist/workers/server-esbuild-context.d.ts.map +1 -0
- package/dist/workers/server-esbuild-context.js +92 -0
- package/dist/workers/server-esbuild-context.js.map +1 -0
- package/dist/workers/server-runtime.worker.d.ts.map +1 -1
- package/dist/workers/server-runtime.worker.js +3 -1
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/dist/workers/server-watch-manager.d.ts +44 -0
- package/dist/workers/server-watch-manager.d.ts.map +1 -0
- package/dist/workers/server-watch-manager.js +87 -0
- package/dist/workers/server-watch-manager.js.map +1 -0
- package/dist/workers/shared-worker-lifecycle.d.ts +14 -0
- package/dist/workers/shared-worker-lifecycle.d.ts.map +1 -0
- package/dist/workers/shared-worker-lifecycle.js +17 -0
- package/dist/workers/shared-worker-lifecycle.js.map +1 -0
- package/package.json +9 -9
- package/src/{utils → angular}/angular-build-pipeline.ts +3 -8
- package/src/{utils → angular}/angular-build.ts +1 -1
- package/src/{utils → angular}/angular-compiler.ts +1 -64
- package/src/angular/client-transform-stylesheet.ts +1 -1
- package/src/{utils → angular}/ngtsc-build-core.ts +3 -3
- package/src/angular/vite-angular-plugin.ts +22 -355
- package/src/capacitor/capacitor-build.ts +142 -0
- package/src/capacitor/capacitor-config-writer.ts +66 -0
- package/src/capacitor/capacitor-icon.ts +75 -0
- package/src/capacitor/capacitor-npm-config.ts +192 -0
- package/src/capacitor/capacitor.ts +32 -441
- package/src/commands/check.ts +2 -2
- package/src/commands/dev.ts +6 -6
- package/src/commands/lint.ts +1 -1
- package/src/commands/publish/deployment-phase.ts +125 -0
- package/src/commands/publish/env-utils.ts +44 -0
- package/src/commands/publish/git-phase.ts +99 -0
- package/src/commands/publish/index.ts +266 -0
- package/src/commands/publish/local-publisher.ts +23 -0
- package/src/commands/publish/npm-publisher.ts +30 -0
- package/src/commands/publish/post-publish-phase.ts +43 -0
- package/src/commands/publish/storage-publisher.ts +208 -0
- package/src/commands/publish/version-upgrade.ts +132 -0
- package/src/commands/replace-deps.ts +1 -1
- package/src/commands/watch.ts +6 -7
- package/src/deps/replace-deps/collect-deps.ts +92 -0
- package/src/{utils/replace-deps.ts → deps/replace-deps/replace-deps-resolve.ts} +4 -188
- package/src/deps/replace-deps/replace-deps.ts +193 -0
- package/src/{utils → deps/server-externals}/server-production-files.ts +2 -2
- package/src/dev-server/dev-http-server.ts +149 -0
- package/src/dev-server/hmr-client-script.ts +74 -0
- package/src/dev-server/hmr-service.ts +178 -0
- package/src/electron/electron.ts +21 -28
- package/src/engines/BaseEngine.ts +64 -83
- package/src/engines/{ViteEngine.ts → EsbuildClientEngine.ts} +33 -72
- package/src/engines/NgtscEngine.ts +3 -11
- package/src/engines/ServerEsbuildEngine.ts +3 -11
- package/src/engines/TscEngine.ts +3 -11
- package/src/engines/index.ts +29 -9
- package/src/engines/types.ts +3 -3
- package/src/esbuild/esbuild-client-config.ts +230 -0
- package/src/{utils → esbuild}/esbuild-config.ts +1 -0
- package/src/esbuild/esbuild-index-html.ts +119 -0
- package/src/esbuild/esbuild-pwa.ts +139 -0
- package/src/esbuild/esbuild-scss-plugin.ts +48 -0
- package/src/orchestrators/BaseOrchestrator.ts +118 -0
- package/src/orchestrators/BuildOrchestrator.ts +234 -171
- package/src/orchestrators/DevOrchestrator.ts +315 -0
- package/src/orchestrators/ServerRuntimeManager.ts +85 -0
- package/src/orchestrators/TypecheckOrchestrator.ts +166 -117
- package/src/orchestrators/WatchOrchestrator.ts +203 -0
- package/src/orchestrators/types.ts +18 -0
- package/src/{utils → runtime}/engine-stop.ts +1 -1
- package/src/runtime/engine-watch-events.ts +121 -0
- package/src/{utils → runtime}/rebuild-manager.ts +8 -1
- package/src/runtime/worker-events.ts +25 -0
- package/src/sd-cli-entry.ts +69 -54
- package/src/sd-cli.ts +1 -1
- package/src/sd-config.types.ts +6 -16
- package/src/{utils → typecheck}/typecheck-non-package.ts +1 -1
- package/src/utils/diagnostic-utils.ts +15 -0
- package/src/utils/orchestrator-utils.ts +2 -6
- package/src/utils/output-utils.ts +1 -1
- package/src/utils/package-classify.ts +182 -0
- package/src/utils/package-utils.ts +0 -257
- package/src/utils/tsc-build.ts +1 -1
- package/src/workers/build-change-filter.ts +27 -0
- package/src/workers/build-watch-paths.ts +54 -0
- package/src/workers/client.worker.ts +258 -328
- package/src/workers/library-build.worker.ts +15 -34
- package/src/workers/lint.worker.ts +1 -1
- package/src/workers/ngtsc-build.worker.ts +19 -46
- package/src/workers/server-build.worker.ts +38 -168
- package/src/workers/server-esbuild-context.ts +122 -0
- package/src/workers/server-runtime.worker.ts +4 -1
- package/src/workers/server-watch-manager.ts +124 -0
- package/src/workers/shared-worker-lifecycle.ts +24 -0
- package/tests/angular/angular-build-pipeline.spec.ts +2 -2
- package/tests/angular/angular-compiler-aot.acc.spec.ts +68 -0
- package/tests/angular/angular-compiler-aot.spec.ts +80 -0
- package/tests/angular/angular-compiler-hmr-removal.verify.md +16 -0
- package/tests/angular/vite-angular-plugin-legacy-watch.spec.ts +0 -17
- package/tests/angular/vite-angular-plugin-vitest.spec.ts +1 -6
- package/tests/angular/vite-angular-plugin-vitest.verify.md +20 -0
- package/tests/angular/vite-angular-plugin.spec.ts +4 -178
- package/tests/capacitor/capacitor-android.spec.ts +1 -0
- package/tests/capacitor/capacitor-build.spec.ts +1 -0
- package/tests/capacitor/capacitor-config-writer.acc.spec.ts +108 -0
- package/tests/capacitor/capacitor-config-writer.spec.ts +95 -0
- package/tests/capacitor/capacitor-icon.spec.ts +1 -0
- package/tests/capacitor/capacitor-init.spec.ts +1 -0
- package/tests/capacitor/capacitor-npm-config.acc.spec.ts +236 -0
- package/tests/capacitor/capacitor-npm-config.spec.ts +132 -0
- package/tests/capacitor/capacitor-run.spec.ts +1 -0
- package/tests/capacitor/capacitor-workspace.spec.ts +1 -0
- package/tests/commands/check.spec.ts +2 -2
- package/tests/commands/deployment-phase.acc.spec.ts +142 -0
- package/tests/commands/git-phase.acc.spec.ts +158 -0
- package/tests/commands/lint.spec.ts +1 -1
- package/tests/commands/post-publish-phase.acc.spec.ts +82 -0
- package/tests/commands/publish-npm-local-split.verify.md +9 -0
- package/tests/commands/publish-responsibility-split.verify.md +13 -0
- package/tests/commands/publish-storage-split.verify.md +8 -0
- package/tests/commands/publish.spec.ts +1 -1
- package/tests/commands/typecheck.spec.ts +18 -18
- package/tests/deps/deps-directory-separation.verify.md +15 -0
- package/tests/engines/base-engine.spec.ts +65 -6
- package/tests/engines/engine-adapter-isolation.spec.ts +11 -18
- package/tests/engines/engine-selection.spec.ts +38 -5
- package/tests/engines/engine-typecheck-selection.acc.spec.ts +85 -0
- package/tests/engines/engine-typecheck-selection.verify.md +8 -0
- package/tests/engines/esbuild-client-engine.acc.spec.ts +161 -0
- package/tests/engines/esbuild-client-engine.spec.ts +320 -0
- package/tests/engines/esbuild-client-engine.verify.md +15 -0
- package/tests/engines/normalize-result.verify.md +9 -0
- package/tests/engines/vite-dependency-cleanup.verify.md +24 -0
- package/tests/orchestrators/build-orchestrator.spec.ts +3 -3
- package/tests/orchestrators/dev-orchestrator.spec.ts +799 -0
- package/tests/orchestrators/orchestrator-baseenv.verify.md +10 -0
- package/tests/orchestrators/orchestrator-diagnostic-formatting.verify.md +10 -0
- package/tests/orchestrators/orchestrator-initializemode-signature.verify.md +9 -0
- package/tests/orchestrators/typecheck-orchestrator.spec.ts +11 -11
- package/tests/orchestrators/watch-orchestrator.spec.ts +511 -0
- package/tests/{infra → runtime}/result-collector.spec.ts +1 -1
- package/tests/{infra → runtime}/signal-handler.spec.ts +1 -1
- package/tests/sd-cli-entry.spec.ts +9 -0
- package/tests/utils/angular-build.spec.ts +15 -20
- package/tests/utils/angular-compiler-emit.spec.ts +2 -2
- package/tests/utils/angular-compiler.spec.ts +2 -2
- package/tests/utils/angular-source-file-cache.spec.ts +2 -2
- package/tests/utils/concurrency.spec.ts +2 -10
- package/tests/utils/dev-http-server.acc.spec.ts +206 -0
- package/tests/utils/dev-http-server.spec.ts +181 -0
- package/tests/utils/dev-http-server.verify.md +8 -0
- package/tests/utils/diagnostic-utils.spec.ts +42 -1
- package/tests/utils/engine-stop.spec.ts +1 -1
- package/tests/utils/engine-watch-events.acc.spec.ts +217 -0
- package/tests/utils/engine-watch-events.spec.ts +141 -0
- package/tests/utils/engine-watch-events.verify.md +17 -0
- package/tests/utils/esbuild-client-config.acc.spec.ts +443 -0
- package/tests/utils/esbuild-client-config.spec.ts +590 -0
- package/tests/utils/esbuild-client-config.verify.md +26 -0
- package/tests/utils/esbuild-config.spec.ts +11 -1
- package/tests/utils/esbuild-index-html.acc.spec.ts +166 -0
- package/tests/utils/esbuild-index-html.spec.ts +194 -0
- package/tests/utils/esbuild-index-html.verify.md +10 -0
- package/tests/utils/esbuild-pwa.acc.spec.ts +203 -0
- package/tests/utils/esbuild-pwa.spec.ts +189 -0
- package/tests/utils/esbuild-pwa.verify.md +9 -0
- package/tests/utils/esbuild-scss-plugin.acc.spec.ts +111 -0
- package/tests/utils/esbuild-scss-plugin.spec.ts +150 -0
- package/tests/utils/esbuild-scss-plugin.verify.md +8 -0
- package/tests/utils/external-modules.spec.ts +1 -1
- package/tests/utils/hmr-client-script.acc.spec.ts +128 -0
- package/tests/utils/hmr-client-script.spec.ts +44 -0
- package/tests/utils/hmr-service-dispatcher.acc.spec.ts +217 -0
- package/tests/utils/hmr-service-dispatcher.spec.ts +143 -0
- package/tests/utils/hmr-service.acc.spec.ts +139 -0
- package/tests/utils/hmr-service.spec.ts +131 -0
- package/tests/utils/hmr-service.verify.md +17 -0
- package/tests/utils/lint-core.spec.ts +2 -1
- package/tests/utils/lint-utils.spec.ts +1 -1
- package/tests/utils/lint-with-program.spec.ts +1 -1
- package/tests/utils/ngtsc-build-core-write-emit.spec.ts +19 -19
- package/tests/utils/ngtsc-build-core.spec.ts +4 -4
- package/tests/utils/orchestrator-utils.spec.ts +2 -2
- package/tests/utils/output-utils.spec.ts +1 -1
- package/tests/utils/package-utils.spec.ts +1 -1
- package/tests/utils/rebuild-manager.spec.ts +20 -7
- package/tests/utils/replace-deps-split.verify.md +15 -0
- package/tests/utils/replace-deps-watch.acc.spec.ts +131 -0
- package/tests/utils/replace-deps-watch.spec.ts +91 -0
- package/tests/utils/replace-deps-watch.verify.md +9 -0
- package/tests/utils/replace-deps.spec.ts +1 -1
- package/tests/utils/scss-compiler.spec.ts +1 -1
- package/tests/utils/tsc-build.spec.ts +1 -1
- package/tests/utils/typecheck-non-package.spec.ts +2 -2
- package/tests/utils/worker-utils.spec.ts +2 -1
- package/tests/workers/build-change-filter.acc.spec.ts +78 -0
- package/tests/workers/build-change-filter.spec.ts +39 -0
- package/tests/workers/build-watch-paths-library.verify.md +10 -0
- package/tests/workers/build-watch-paths-ngtsc-server.verify.md +12 -0
- package/tests/workers/build-watch-paths.acc.spec.ts +101 -0
- package/tests/workers/build-watch-paths.spec.ts +121 -0
- package/tests/workers/client-worker-browser-support.verify.md +7 -0
- package/tests/workers/client-worker-onend-sync.verify.md +7 -0
- package/tests/workers/client-worker.acc.spec.ts +185 -0
- package/tests/workers/client-worker.spec.ts +91 -178
- package/tests/workers/library-build-lint.spec.ts +3 -3
- package/tests/workers/library-build-worker.spec.ts +10 -11
- package/tests/workers/ngtsc-build-lint.spec.ts +4 -4
- package/tests/workers/ngtsc-build-worker.spec.ts +2 -2
- package/tests/workers/server-build-lint.spec.ts +4 -4
- package/tests/workers/server-build-worker.spec.ts +14 -15
- package/tests/workers/server-esbuild-context-integration.verify.md +10 -0
- package/tests/workers/server-esbuild-context.acc.spec.ts +98 -0
- package/tests/workers/server-esbuild-context.spec.ts +198 -0
- package/tests/workers/server-runtime-worker.spec.ts +4 -3
- package/tests/workers/server-watch-manager.acc.spec.ts +162 -0
- package/tests/workers/server-watch-manager.spec.ts +199 -0
- package/tests/workers/shared-worker-lifecycle.acc.spec.ts +27 -0
- package/tests/workers/shared-worker-lifecycle.spec.ts +47 -0
- package/dist/angular/vite-postcss-inline-plugin.d.ts +0 -18
- package/dist/angular/vite-postcss-inline-plugin.d.ts.map +0 -1
- package/dist/angular/vite-postcss-inline-plugin.js +0 -108
- package/dist/angular/vite-postcss-inline-plugin.js.map +0 -1
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/publish.js +0 -689
- package/dist/commands/publish.js.map +0 -1
- package/dist/engines/ViteEngine.d.ts.map +0 -1
- package/dist/engines/ViteEngine.js.map +0 -1
- package/dist/infra/ResultCollector.d.ts.map +0 -1
- package/dist/infra/ResultCollector.js.map +0 -1
- package/dist/infra/SignalHandler.d.ts.map +0 -1
- package/dist/infra/SignalHandler.js.map +0 -1
- package/dist/orchestrators/DevWatchOrchestrator.d.ts +0 -63
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +0 -1
- package/dist/orchestrators/DevWatchOrchestrator.js +0 -478
- package/dist/orchestrators/DevWatchOrchestrator.js.map +0 -1
- package/dist/utils/angular-build-pipeline.d.ts.map +0 -1
- package/dist/utils/angular-build-pipeline.js.map +0 -1
- package/dist/utils/angular-build.d.ts.map +0 -1
- package/dist/utils/angular-build.js.map +0 -1
- package/dist/utils/angular-compiler.d.ts.map +0 -1
- package/dist/utils/angular-compiler.js.map +0 -1
- package/dist/utils/engine-stop.d.ts.map +0 -1
- package/dist/utils/engine-stop.js.map +0 -1
- package/dist/utils/esbuild-config.d.ts.map +0 -1
- package/dist/utils/esbuild-config.js.map +0 -1
- package/dist/utils/hmr-candidates.d.ts +0 -15
- package/dist/utils/hmr-candidates.d.ts.map +0 -1
- package/dist/utils/hmr-candidates.js +0 -234
- package/dist/utils/hmr-candidates.js.map +0 -1
- package/dist/utils/lint-core.d.ts.map +0 -1
- package/dist/utils/lint-core.js.map +0 -1
- package/dist/utils/lint-utils.d.ts.map +0 -1
- package/dist/utils/lint-utils.js.map +0 -1
- package/dist/utils/lint-with-program.d.ts.map +0 -1
- package/dist/utils/lint-with-program.js.map +0 -1
- package/dist/utils/ngtsc-build-core.d.ts.map +0 -1
- package/dist/utils/ngtsc-build-core.js.map +0 -1
- package/dist/utils/rebuild-manager.d.ts.map +0 -1
- package/dist/utils/rebuild-manager.js.map +0 -1
- package/dist/utils/replace-deps.d.ts.map +0 -1
- package/dist/utils/replace-deps.js.map +0 -1
- package/dist/utils/scss-compiler.d.ts.map +0 -1
- package/dist/utils/scss-compiler.js.map +0 -1
- package/dist/utils/server-production-files.d.ts.map +0 -1
- package/dist/utils/server-production-files.js.map +0 -1
- package/dist/utils/typecheck-non-package.d.ts.map +0 -1
- package/dist/utils/typecheck-non-package.js.map +0 -1
- package/dist/utils/typecheck-serialization.d.ts.map +0 -1
- package/dist/utils/typecheck-serialization.js.map +0 -1
- package/dist/utils/vite-config.d.ts +0 -50
- package/dist/utils/vite-config.d.ts.map +0 -1
- package/dist/utils/vite-config.js +0 -242
- package/dist/utils/vite-config.js.map +0 -1
- package/dist/utils/vite-pwa-plugin.d.ts +0 -9
- package/dist/utils/vite-pwa-plugin.d.ts.map +0 -1
- package/dist/utils/vite-pwa-plugin.js +0 -139
- package/dist/utils/vite-pwa-plugin.js.map +0 -1
- package/dist/utils/vite-scope-watch-plugin.d.ts +0 -24
- package/dist/utils/vite-scope-watch-plugin.d.ts.map +0 -1
- package/dist/utils/vite-scope-watch-plugin.js +0 -51
- package/dist/utils/vite-scope-watch-plugin.js.map +0 -1
- package/dist/utils/worker-events.d.ts +0 -66
- package/dist/utils/worker-events.d.ts.map +0 -1
- package/dist/utils/worker-events.js +0 -55
- package/dist/utils/worker-events.js.map +0 -1
- package/dist/utils/worker-utils.d.ts.map +0 -1
- package/dist/utils/worker-utils.js.map +0 -1
- package/src/angular/vite-postcss-inline-plugin.ts +0 -139
- package/src/commands/publish.ts +0 -850
- package/src/orchestrators/DevWatchOrchestrator.ts +0 -594
- package/src/utils/hmr-candidates.ts +0 -327
- package/src/utils/vite-config.ts +0 -318
- package/src/utils/vite-pwa-plugin.ts +0 -168
- package/src/utils/vite-scope-watch-plugin.ts +0 -77
- package/src/utils/worker-events.ts +0 -128
- package/tests/angular/angular-compiler-hmr.spec.ts +0 -152
- package/tests/angular/hmr-candidates.spec.ts +0 -158
- package/tests/angular/linker-disk-cache.spec.ts +0 -171
- package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +0 -333
- package/tests/angular/vite-angular-plugin-hmr.spec.ts +0 -320
- package/tests/angular/vite-angular-plugin-scss-hmr.spec.ts +0 -95
- package/tests/angular/vite-postcss-inline-plugin.spec.ts +0 -60
- package/tests/engines/vite-engine.spec.ts +0 -409
- package/tests/orchestrators/dev-watch-orchestrator.spec.ts +0 -1542
- package/tests/utils/vite-config.spec.ts +0 -780
- package/tests/utils/vite-pwa-plugin.spec.ts +0 -401
- package/tests/utils/vite-scope-watch-plugin.spec.ts +0 -218
- package/tests/utils/worker-events.spec.ts +0 -147
- package/tests/workers/client-worker-legacy.spec.ts +0 -659
- /package/dist/{utils → angular}/ngtsc-build-core.js +0 -0
- /package/dist/{utils → angular}/scss-compiler.d.ts +0 -0
- /package/dist/{utils → angular}/scss-compiler.js +0 -0
- /package/dist/{utils → esbuild}/esbuild-config.d.ts +0 -0
- /package/dist/{utils → lint}/lint-core.d.ts +0 -0
- /package/dist/{utils → lint}/lint-core.js +0 -0
- /package/dist/{utils → lint}/lint-utils.d.ts +0 -0
- /package/dist/{utils → lint}/lint-utils.js +0 -0
- /package/dist/{utils → lint}/lint-with-program.d.ts +0 -0
- /package/dist/{utils → lint}/lint-with-program.js +0 -0
- /package/dist/{infra → runtime}/ResultCollector.d.ts +0 -0
- /package/dist/{infra → runtime}/ResultCollector.js +0 -0
- /package/dist/{infra → runtime}/SignalHandler.d.ts +0 -0
- /package/dist/{infra → runtime}/SignalHandler.js +0 -0
- /package/dist/{utils → runtime}/worker-utils.d.ts +0 -0
- /package/dist/{utils → runtime}/worker-utils.js +0 -0
- /package/dist/{utils → typecheck}/typecheck-non-package.d.ts +0 -0
- /package/dist/{utils → typecheck}/typecheck-serialization.d.ts +0 -0
- /package/dist/{utils → typecheck}/typecheck-serialization.js +0 -0
- /package/src/{utils → angular}/scss-compiler.ts +0 -0
- /package/src/{utils → lint}/lint-core.ts +0 -0
- /package/src/{utils → lint}/lint-utils.ts +0 -0
- /package/src/{utils → lint}/lint-with-program.ts +0 -0
- /package/src/{infra → runtime}/ResultCollector.ts +0 -0
- /package/src/{infra → runtime}/SignalHandler.ts +0 -0
- /package/src/{utils → runtime}/worker-utils.ts +0 -0
- /package/src/{utils → typecheck}/typecheck-serialization.ts +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import os from "os";
|
|
5
|
+
|
|
6
|
+
const { applyPwa, createPwaHtmlTransform } = await import(
|
|
7
|
+
"../../src/esbuild/esbuild-pwa"
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
describe("applyPwa — manifest 생성", () => {
|
|
11
|
+
let tmpDir: string;
|
|
12
|
+
let pkgDir: string;
|
|
13
|
+
let distDir: string;
|
|
14
|
+
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "sd-pwa-unit-"));
|
|
17
|
+
pkgDir = path.join(tmpDir, "pkg");
|
|
18
|
+
distDir = path.join(pkgDir, "dist");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
23
|
+
fs.writeFileSync(
|
|
24
|
+
path.join(distDir, "index.html"),
|
|
25
|
+
"<!DOCTYPE html><html><head></head><body></body></html>",
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterAll(() => {
|
|
30
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("manifest에 icons 필드 없이 생성 (원본 아이콘 없을 때)", async () => {
|
|
34
|
+
await applyPwa({
|
|
35
|
+
pkgDir,
|
|
36
|
+
pkgName: "no-icon-app",
|
|
37
|
+
cwd: tmpDir,
|
|
38
|
+
outdir: distDir,
|
|
39
|
+
baseHref: "/",
|
|
40
|
+
mode: "build",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const manifest = JSON.parse(
|
|
44
|
+
fs.readFileSync(path.join(distDir, "manifest.webmanifest"), "utf-8"),
|
|
45
|
+
) as Record<string, unknown>;
|
|
46
|
+
expect(manifest["icons"]).toBeUndefined();
|
|
47
|
+
expect(manifest["name"]).toBe("no-icon-app");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("applyPwa — mode/pwa 가드", () => {
|
|
52
|
+
let tmpDir: string;
|
|
53
|
+
let pkgDir: string;
|
|
54
|
+
let distDir: string;
|
|
55
|
+
|
|
56
|
+
beforeAll(() => {
|
|
57
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "sd-pwa-guard-"));
|
|
58
|
+
pkgDir = path.join(tmpDir, "pkg");
|
|
59
|
+
distDir = path.join(pkgDir, "dist");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
64
|
+
fs.writeFileSync(
|
|
65
|
+
path.join(distDir, "index.html"),
|
|
66
|
+
"<!DOCTYPE html><html><head></head><body></body></html>",
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
afterAll(() => {
|
|
71
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("dev 모드에서는 아무 파일도 생성하지 않는다", async () => {
|
|
75
|
+
await applyPwa({
|
|
76
|
+
pkgDir,
|
|
77
|
+
pkgName: "test",
|
|
78
|
+
cwd: tmpDir,
|
|
79
|
+
outdir: distDir,
|
|
80
|
+
baseHref: "/",
|
|
81
|
+
mode: "dev",
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(fs.existsSync(path.join(distDir, "manifest.webmanifest"))).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("pwa: false이면 아무 파일도 생성하지 않는다", async () => {
|
|
88
|
+
await applyPwa({
|
|
89
|
+
pkgDir,
|
|
90
|
+
pkgName: "test",
|
|
91
|
+
cwd: tmpDir,
|
|
92
|
+
outdir: distDir,
|
|
93
|
+
baseHref: "/",
|
|
94
|
+
mode: "build",
|
|
95
|
+
pwa: false,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
expect(fs.existsSync(path.join(distDir, "manifest.webmanifest"))).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("applyPwa — ngsw-config.json 자동 생성", () => {
|
|
103
|
+
let tmpDir: string;
|
|
104
|
+
let pkgDir: string;
|
|
105
|
+
let distDir: string;
|
|
106
|
+
|
|
107
|
+
beforeAll(() => {
|
|
108
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "sd-pwa-ngsw-"));
|
|
109
|
+
pkgDir = path.join(tmpDir, "pkg");
|
|
110
|
+
distDir = path.join(pkgDir, "dist");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
beforeEach(() => {
|
|
114
|
+
if (fs.existsSync(distDir)) {
|
|
115
|
+
fs.rmSync(distDir, { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
118
|
+
fs.writeFileSync(
|
|
119
|
+
path.join(distDir, "index.html"),
|
|
120
|
+
"<!DOCTYPE html><html><head></head><body></body></html>",
|
|
121
|
+
);
|
|
122
|
+
const ngswPath = path.join(pkgDir, "ngsw-config.json");
|
|
123
|
+
if (fs.existsSync(ngswPath)) {
|
|
124
|
+
fs.unlinkSync(ngswPath);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
afterAll(() => {
|
|
129
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("ngsw-config.json 부재 시 기본 파일을 프로젝트에 생성한다", async () => {
|
|
133
|
+
await applyPwa({
|
|
134
|
+
pkgDir,
|
|
135
|
+
pkgName: "test",
|
|
136
|
+
cwd: tmpDir,
|
|
137
|
+
outdir: distDir,
|
|
138
|
+
baseHref: "/",
|
|
139
|
+
mode: "build",
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const ngswPath = path.join(pkgDir, "ngsw-config.json");
|
|
143
|
+
expect(fs.existsSync(ngswPath)).toBe(true);
|
|
144
|
+
|
|
145
|
+
const config = JSON.parse(fs.readFileSync(ngswPath, "utf-8")) as Record<string, unknown>;
|
|
146
|
+
expect(config["index"]).toBe("/index.html");
|
|
147
|
+
const groups = config["assetGroups"] as Array<{ name: string }>;
|
|
148
|
+
expect(groups.map((g) => g.name)).toEqual(["app", "assets"]);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("ngsw-config.json 존재 시 덮어쓰지 않는다", async () => {
|
|
152
|
+
const ngswPath = path.join(pkgDir, "ngsw-config.json");
|
|
153
|
+
const customConfig = { index: "/custom.html", assetGroups: [] };
|
|
154
|
+
fs.writeFileSync(ngswPath, JSON.stringify(customConfig));
|
|
155
|
+
|
|
156
|
+
await applyPwa({
|
|
157
|
+
pkgDir,
|
|
158
|
+
pkgName: "test",
|
|
159
|
+
cwd: tmpDir,
|
|
160
|
+
outdir: distDir,
|
|
161
|
+
baseHref: "/",
|
|
162
|
+
mode: "build",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const config = JSON.parse(fs.readFileSync(ngswPath, "utf-8")) as Record<string, unknown>;
|
|
166
|
+
expect(config["index"]).toBe("/custom.html");
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("createPwaHtmlTransform — HTML 변환", () => {
|
|
171
|
+
it("head에 manifest link, body에 SW 등록 스크립트 주입", async () => {
|
|
172
|
+
const transform = createPwaHtmlTransform();
|
|
173
|
+
const input = "<!DOCTYPE html><html><head><title>App</title></head><body><div>content</div></body></html>";
|
|
174
|
+
const output = await transform(input);
|
|
175
|
+
|
|
176
|
+
expect(output).toContain('<link rel="manifest" href="manifest.webmanifest">');
|
|
177
|
+
expect(output).toContain("ngsw-worker.js");
|
|
178
|
+
expect(output).toContain("sd-pwa-update-ready");
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("등록 스크립트에 controllerchange 핸들러와 SKIP_WAITING 포함", async () => {
|
|
182
|
+
const transform = createPwaHtmlTransform();
|
|
183
|
+
const output = await transform("<html><head></head><body></body></html>");
|
|
184
|
+
|
|
185
|
+
expect(output).toContain("controllerchange");
|
|
186
|
+
expect(output).toContain("location.reload()");
|
|
187
|
+
expect(output).toContain("SKIP_WAITING");
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# esbuild-pwa — LLM 검증
|
|
2
|
+
|
|
3
|
+
## 검증 항목
|
|
4
|
+
|
|
5
|
+
- [x] augmentAppWithServiceWorker 호출 인자가 정확한가: `esbuild-pwa.ts:108-113` — `(options.pkgDir, options.cwd, options.outdir, options.baseHref)` 순서로 호출 확인
|
|
6
|
+
- [x] 기본 ngsw-config.json에 $schema, index, assetGroups(app, assets)가 포함되는가: `esbuild-pwa.ts:83-104` — `$schema`, `index: "/index.html"`, `assetGroups: [{name: "app"}, {name: "assets"}]` 확인
|
|
7
|
+
- [x] 등록 스크립트에서 ngsw-worker.js를 등록하는가: `esbuild-pwa.ts:119` — `register("ngsw-worker.js")` 확인. `sw.js` 참조 없음
|
|
8
|
+
- [x] SdPwaConfig.workbox 필드를 참조하지 않는가: grep 결과 "workbox" 0건 확인. D4 결정 준수
|
|
9
|
+
- [x] generatePwaIcons 호출 결과를 dist/icons/로 복사하는 로직이 있는가: `esbuild-pwa.ts:51-58` — `srcIconsDir(public/icons/)` → `dstIconsDir(outdir/icons/)` copyFileSync 로직 확인
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import esbuild from "esbuild";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import { createScssPlugin } from "../../src/esbuild/esbuild-scss-plugin";
|
|
7
|
+
|
|
8
|
+
describe("createScssPlugin — Acceptance", () => {
|
|
9
|
+
let tmpDir: string;
|
|
10
|
+
|
|
11
|
+
beforeAll(() => {
|
|
12
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "scss-plugin-test-"));
|
|
13
|
+
|
|
14
|
+
// --- 기본 SCSS 컴파일 fixtures ---
|
|
15
|
+
fs.writeFileSync(
|
|
16
|
+
path.join(tmpDir, "main-basic.js"),
|
|
17
|
+
`import "./global.scss";`,
|
|
18
|
+
);
|
|
19
|
+
fs.writeFileSync(
|
|
20
|
+
path.join(tmpDir, "global.scss"),
|
|
21
|
+
`$color: red;\n.body { color: $color; }`,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// --- loadPaths fixtures ---
|
|
25
|
+
fs.mkdirSync(path.join(tmpDir, "scss", "commons"), { recursive: true });
|
|
26
|
+
fs.writeFileSync(
|
|
27
|
+
path.join(tmpDir, "scss", "commons", "_variables.scss"),
|
|
28
|
+
`$primary: blue;`,
|
|
29
|
+
);
|
|
30
|
+
fs.writeFileSync(
|
|
31
|
+
path.join(tmpDir, "reset.scss"),
|
|
32
|
+
`@use "commons/variables" as vars;\n.reset { color: vars.$primary; }`,
|
|
33
|
+
);
|
|
34
|
+
fs.writeFileSync(
|
|
35
|
+
path.join(tmpDir, "main-loadpaths.js"),
|
|
36
|
+
`import "./reset.scss";`,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// --- 에러 fixtures ---
|
|
40
|
+
fs.writeFileSync(
|
|
41
|
+
path.join(tmpDir, "error.scss"),
|
|
42
|
+
`.body { color: $undefined-var; }`,
|
|
43
|
+
);
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
path.join(tmpDir, "main-error.js"),
|
|
46
|
+
`import "./error.scss";`,
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterAll(() => {
|
|
51
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Scenario: SCSS 파일이 CSS로 컴파일되어 번들에 포함된다
|
|
55
|
+
it("SCSS side-effect import가 sass 컴파일되어 CSS 번들에 포함된다", async () => {
|
|
56
|
+
const result = await esbuild.build({
|
|
57
|
+
entryPoints: [path.join(tmpDir, "main-basic.js")],
|
|
58
|
+
bundle: true,
|
|
59
|
+
write: false,
|
|
60
|
+
outdir: path.join(tmpDir, "out-basic"),
|
|
61
|
+
logLevel: "silent",
|
|
62
|
+
plugins: [createScssPlugin({ loadPaths: [] })],
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const cssOutput = result.outputFiles.find((f) => f.path.endsWith(".css"));
|
|
66
|
+
expect(cssOutput).toBeDefined();
|
|
67
|
+
expect(cssOutput!.text).toContain("color: red");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Scenario: SCSS @use/@import는 loadPaths로 해석된다
|
|
71
|
+
it("SCSS @use가 loadPaths로 해석되어 변수가 CSS에 반영된다", async () => {
|
|
72
|
+
const result = await esbuild.build({
|
|
73
|
+
entryPoints: [path.join(tmpDir, "main-loadpaths.js")],
|
|
74
|
+
bundle: true,
|
|
75
|
+
write: false,
|
|
76
|
+
outdir: path.join(tmpDir, "out-loadpaths"),
|
|
77
|
+
logLevel: "silent",
|
|
78
|
+
plugins: [
|
|
79
|
+
createScssPlugin({ loadPaths: [path.join(tmpDir, "scss")] }),
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const cssOutput = result.outputFiles.find((f) => f.path.endsWith(".css"));
|
|
84
|
+
expect(cssOutput).toBeDefined();
|
|
85
|
+
expect(cssOutput!.text).toContain("color: blue");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Scenario: SCSS 컴파일 에러가 esbuild 에러로 전파된다
|
|
89
|
+
it("SCSS 컴파일 에러가 esbuild 에러로 전파되며 파일/라인 정보를 포함한다", async () => {
|
|
90
|
+
try {
|
|
91
|
+
await esbuild.build({
|
|
92
|
+
entryPoints: [path.join(tmpDir, "main-error.js")],
|
|
93
|
+
bundle: true,
|
|
94
|
+
write: false,
|
|
95
|
+
outdir: path.join(tmpDir, "out-error"),
|
|
96
|
+
logLevel: "silent",
|
|
97
|
+
plugins: [createScssPlugin({ loadPaths: [] })],
|
|
98
|
+
});
|
|
99
|
+
expect.fail("빌드가 실패해야 한다");
|
|
100
|
+
} catch (e: any) {
|
|
101
|
+
expect(e.errors).toBeDefined();
|
|
102
|
+
expect(e.errors.length).toBeGreaterThan(0);
|
|
103
|
+
|
|
104
|
+
const error = e.errors[0];
|
|
105
|
+
expect(error.text).toBeDefined();
|
|
106
|
+
expect(error.location).toBeDefined();
|
|
107
|
+
expect(error.location.file).toContain("error.scss");
|
|
108
|
+
expect(error.location.line).toBeGreaterThan(0);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import type esbuild from "esbuild";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import { createScssPlugin } from "../../src/esbuild/esbuild-scss-plugin";
|
|
7
|
+
|
|
8
|
+
// --- onLoad 콜백 캡처 헬퍼 ---
|
|
9
|
+
|
|
10
|
+
interface OnLoadRegistration {
|
|
11
|
+
options: { filter: RegExp; namespace?: string };
|
|
12
|
+
callback: (args: esbuild.OnLoadArgs) => Promise<esbuild.OnLoadResult | null | undefined>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function captureOnLoad(plugin: esbuild.Plugin): OnLoadRegistration {
|
|
16
|
+
let registration: OnLoadRegistration | undefined;
|
|
17
|
+
const mockBuild = {
|
|
18
|
+
onLoad(opts: any, cb: any) {
|
|
19
|
+
registration = { options: opts, callback: cb };
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
void plugin.setup(mockBuild as any);
|
|
23
|
+
return registration!;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe("createScssPlugin — Unit", () => {
|
|
27
|
+
let tmpDir: string;
|
|
28
|
+
|
|
29
|
+
beforeAll(() => {
|
|
30
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "scss-unit-test-"));
|
|
31
|
+
|
|
32
|
+
// 기본 SCSS 파일
|
|
33
|
+
fs.writeFileSync(
|
|
34
|
+
path.join(tmpDir, "simple.scss"),
|
|
35
|
+
`$size: 16px;\n.text { font-size: $size; }`,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// 의존성이 있는 SCSS 파일
|
|
39
|
+
fs.mkdirSync(path.join(tmpDir, "scss"), { recursive: true });
|
|
40
|
+
fs.writeFileSync(
|
|
41
|
+
path.join(tmpDir, "scss", "_vars.scss"),
|
|
42
|
+
`$bg: white;`,
|
|
43
|
+
);
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
path.join(tmpDir, "with-dep.scss"),
|
|
46
|
+
`@use "vars";\n.box { background: vars.$bg; }`,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// 에러 SCSS 파일
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
path.join(tmpDir, "broken.scss"),
|
|
52
|
+
`.broken { color: $nonexistent; }`,
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterAll(() => {
|
|
57
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("플러그인 name이 'sd-scss'이다", () => {
|
|
61
|
+
const plugin = createScssPlugin({ loadPaths: [] });
|
|
62
|
+
expect(plugin.name).toBe("sd-scss");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("onLoad filter가 /\\.scss$/이다", () => {
|
|
66
|
+
const plugin = createScssPlugin({ loadPaths: [] });
|
|
67
|
+
const { options } = captureOnLoad(plugin);
|
|
68
|
+
expect(options.filter.test("style.scss")).toBe(true);
|
|
69
|
+
expect(options.filter.test("style.css")).toBe(false);
|
|
70
|
+
expect(options.filter.test("style.scss.ts")).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("성공 시 컴파일된 CSS를 loader: 'css'로 반환한다", async () => {
|
|
74
|
+
const plugin = createScssPlugin({ loadPaths: [] });
|
|
75
|
+
const { callback } = captureOnLoad(plugin);
|
|
76
|
+
|
|
77
|
+
const result = await callback({
|
|
78
|
+
path: path.join(tmpDir, "simple.scss"),
|
|
79
|
+
namespace: "file",
|
|
80
|
+
suffix: "",
|
|
81
|
+
pluginData: undefined,
|
|
82
|
+
with: {},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(result).toBeDefined();
|
|
86
|
+
expect(result!.contents).toContain("font-size: 16px");
|
|
87
|
+
expect(result!.loader).toBe("css");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("성공 시 watchFiles에 sass 의존성 경로를 포함한다", async () => {
|
|
91
|
+
const plugin = createScssPlugin({ loadPaths: [path.join(tmpDir, "scss")] });
|
|
92
|
+
const { callback } = captureOnLoad(plugin);
|
|
93
|
+
|
|
94
|
+
const result = await callback({
|
|
95
|
+
path: path.join(tmpDir, "with-dep.scss"),
|
|
96
|
+
namespace: "file",
|
|
97
|
+
suffix: "",
|
|
98
|
+
pluginData: undefined,
|
|
99
|
+
with: {},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(result).toBeDefined();
|
|
103
|
+
expect(result!.watchFiles).toBeDefined();
|
|
104
|
+
expect(result!.watchFiles!.length).toBeGreaterThan(0);
|
|
105
|
+
|
|
106
|
+
const hasVarsFile = result!.watchFiles!.some((f) => f.includes("_vars.scss"));
|
|
107
|
+
expect(hasVarsFile).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("sass 에러 시 esbuild errors 형식으로 파일/라인 정보를 반환한다", async () => {
|
|
111
|
+
const plugin = createScssPlugin({ loadPaths: [] });
|
|
112
|
+
const { callback } = captureOnLoad(plugin);
|
|
113
|
+
|
|
114
|
+
const result = await callback({
|
|
115
|
+
path: path.join(tmpDir, "broken.scss"),
|
|
116
|
+
namespace: "file",
|
|
117
|
+
suffix: "",
|
|
118
|
+
pluginData: undefined,
|
|
119
|
+
with: {},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(result).toBeDefined();
|
|
123
|
+
expect(result!.errors).toBeDefined();
|
|
124
|
+
expect(result!.errors!.length).toBeGreaterThan(0);
|
|
125
|
+
|
|
126
|
+
const error = result!.errors![0];
|
|
127
|
+
expect(error.text).toBeDefined();
|
|
128
|
+
expect(error.location).toBeDefined();
|
|
129
|
+
expect(error.location!.file).toContain("broken.scss");
|
|
130
|
+
expect(error.location!.line).toBeGreaterThan(0);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("loadPaths가 sass 컴파일에 올바르게 전달된다", async () => {
|
|
134
|
+
const plugin = createScssPlugin({ loadPaths: [path.join(tmpDir, "scss")] });
|
|
135
|
+
const { callback } = captureOnLoad(plugin);
|
|
136
|
+
|
|
137
|
+
const result = await callback({
|
|
138
|
+
path: path.join(tmpDir, "with-dep.scss"),
|
|
139
|
+
namespace: "file",
|
|
140
|
+
suffix: "",
|
|
141
|
+
pluginData: undefined,
|
|
142
|
+
with: {},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// loadPaths 없이는 @use "vars"가 실패하므로, 성공 = loadPaths 전달 검증
|
|
146
|
+
expect(result).toBeDefined();
|
|
147
|
+
expect(result!.errors).toBeUndefined();
|
|
148
|
+
expect(result!.contents).toContain("background: white");
|
|
149
|
+
});
|
|
150
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# createScssPlugin — LLM 검증
|
|
2
|
+
|
|
3
|
+
## 검증 항목
|
|
4
|
+
|
|
5
|
+
- [x] createCompilerPlugin 컴포넌트 스타일과 비충돌: `createCompilerPlugin`은 `BundleStylesheetOptions`를 받아 컴포넌트 `styleUrls`를 TypeScript 변환 과정에서 내부 처리한다. 이들은 esbuild의 일반 `onLoad` 경로를 타지 않으므로, `sd-scss` 플러그인의 `onLoad({ filter: /\.scss$/ })` 콜백은 side-effect `import "./global.scss"` 같은 일반 import만 인터셉트한다. 충돌 없음 확인.
|
|
6
|
+
- [x] onLoad filter 정확성: `/\.scss$/` 정규식이 `.scss` 파일만 매칭 — `.css`, `.scss.ts` 등은 매칭하지 않음. 단위 테스트(`esbuild-scss-plugin.spec.ts`)에서 검증 완료.
|
|
7
|
+
- [x] sass 라인 번호 변환: sass `span.start.line`은 0-based, esbuild `location.line`은 1-based. `line + 1` 변환 적용 확인 (`esbuild-scss-plugin.ts:31`).
|
|
8
|
+
- [x] fileURLToPath import 정상: `url` 모듈에서 import. `scss-compiler.ts`의 `pathToFileURL`과 동일 모듈.
|
|
@@ -19,7 +19,7 @@ vi.mock("module", () => ({
|
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
21
|
const { collectUninstalledOptionalPeerDeps, collectNativeModuleExternals, collectAllDependencyExternals } =
|
|
22
|
-
await import("../../src/
|
|
22
|
+
await import("../../src/esbuild/esbuild-config");
|
|
23
23
|
|
|
24
24
|
describe("collectUninstalledOptionalPeerDeps", () => {
|
|
25
25
|
beforeEach(() => {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { runInNewContext } from "node:vm";
|
|
3
|
+
import { getHmrClientScript, createHmrPostTransform } from "../../src/dev-server/hmr-client-script";
|
|
4
|
+
|
|
5
|
+
describe("HMR 클라이언트 스크립트 통합", () => {
|
|
6
|
+
describe("Scenario: HMR 클라이언트 문법 호환성", () => {
|
|
7
|
+
it("Chrome 61 비호환 문법을 사용하지 않는다", () => {
|
|
8
|
+
const script = getHmrClientScript("/app/");
|
|
9
|
+
|
|
10
|
+
// optional chaining (?.) 미사용
|
|
11
|
+
expect(script).not.toMatch(/\?\./);
|
|
12
|
+
// nullish coalescing (??) 미사용
|
|
13
|
+
expect(script).not.toMatch(/\?\?/);
|
|
14
|
+
// logical assignment (&&=, ||=, ??=) 미사용
|
|
15
|
+
expect(script).not.toMatch(/&&=|(\|\|=)|(\?\?=)/);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("WebSocket 연결 코드를 포함한다", () => {
|
|
19
|
+
const script = getHmrClientScript("/app/");
|
|
20
|
+
expect(script).toContain("WebSocket");
|
|
21
|
+
expect(script).toContain("ws://");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("component-update, css-update, full-reload 메시지 핸들러를 포함한다", () => {
|
|
25
|
+
const script = getHmrClientScript("/app/");
|
|
26
|
+
expect(script).toContain("component-update");
|
|
27
|
+
expect(script).toContain("css-update");
|
|
28
|
+
expect(script).toContain("full-reload");
|
|
29
|
+
expect(script).toContain("__hmr_dispatch");
|
|
30
|
+
expect(script).toContain("location.reload");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("자동 재연결 로직을 포함한다", () => {
|
|
34
|
+
const script = getHmrClientScript("/app/");
|
|
35
|
+
expect(script).toContain("setTimeout");
|
|
36
|
+
expect(script).toContain("connect");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("Scenario: css-update 메시지의 files와 매칭되는 link만 업데이트", () => {
|
|
41
|
+
function createScriptEnv() {
|
|
42
|
+
let wsOnMessage: ((e: { data: string }) => void) | undefined;
|
|
43
|
+
const mainLink = {
|
|
44
|
+
getAttribute: vi.fn(() => "/app/main.css?t=old"),
|
|
45
|
+
setAttribute: vi.fn(),
|
|
46
|
+
};
|
|
47
|
+
const vendorLink = {
|
|
48
|
+
getAttribute: vi.fn(() => "/app/vendor.css"),
|
|
49
|
+
setAttribute: vi.fn(),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const sandbox = {
|
|
53
|
+
WebSocket: function MockWebSocket() {
|
|
54
|
+
Object.defineProperty(this, "onmessage", {
|
|
55
|
+
set(fn: (e: { data: string }) => void) {
|
|
56
|
+
wsOnMessage = fn;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(this, "onclose", { set() {} });
|
|
60
|
+
},
|
|
61
|
+
document: { querySelectorAll: vi.fn(() => [mainLink, vendorLink]) },
|
|
62
|
+
location: { hostname: "localhost", port: "3000", reload: vi.fn() },
|
|
63
|
+
setTimeout: vi.fn(),
|
|
64
|
+
globalThis: {} as Record<string, unknown>,
|
|
65
|
+
JSON,
|
|
66
|
+
};
|
|
67
|
+
sandbox.globalThis = sandbox as Record<string, unknown>;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
sandbox,
|
|
71
|
+
triggerMessage: (msg: Record<string, unknown>) => {
|
|
72
|
+
wsOnMessage!({ data: JSON.stringify(msg) });
|
|
73
|
+
},
|
|
74
|
+
mainLink,
|
|
75
|
+
vendorLink,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
it("css-update 시 msg.files와 매칭되는 link만 cache-busting 적용", () => {
|
|
80
|
+
const script = getHmrClientScript("/app/");
|
|
81
|
+
const { sandbox, triggerMessage, mainLink, vendorLink } = createScriptEnv();
|
|
82
|
+
|
|
83
|
+
runInNewContext(script, sandbox);
|
|
84
|
+
|
|
85
|
+
triggerMessage({ type: "css-update", files: ["main.css"], timestamp: 12345 });
|
|
86
|
+
|
|
87
|
+
expect(mainLink.setAttribute).toHaveBeenCalledWith("href", "/app/main.css?t=12345");
|
|
88
|
+
expect(vendorLink.setAttribute).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("css-update 시 files에 여러 파일이 있으면 매칭되는 모든 link를 업데이트", () => {
|
|
92
|
+
const script = getHmrClientScript("/app/");
|
|
93
|
+
const { sandbox, triggerMessage, mainLink, vendorLink } = createScriptEnv();
|
|
94
|
+
|
|
95
|
+
runInNewContext(script, sandbox);
|
|
96
|
+
|
|
97
|
+
triggerMessage({
|
|
98
|
+
type: "css-update",
|
|
99
|
+
files: ["main.css", "vendor.css"],
|
|
100
|
+
timestamp: 99999,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(mainLink.setAttribute).toHaveBeenCalled();
|
|
104
|
+
expect(vendorLink.setAttribute).toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("Scenario: 스크립트 주입", () => {
|
|
109
|
+
it("postTransform이 </body> 직전에 script 태그를 삽입한다", async () => {
|
|
110
|
+
const transform = createHmrPostTransform("/app/");
|
|
111
|
+
const html = "<html><body><div>content</div></body></html>";
|
|
112
|
+
const result = await transform(html);
|
|
113
|
+
|
|
114
|
+
expect(result).toContain("<script>");
|
|
115
|
+
expect(result).toContain("</script></body>");
|
|
116
|
+
expect(result).toContain("WebSocket");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("</body>가 없는 HTML에서도 스크립트를 추가한다", async () => {
|
|
120
|
+
const transform = createHmrPostTransform("/app/");
|
|
121
|
+
const html = "<html><body><div>content</div>";
|
|
122
|
+
const result = await transform(html);
|
|
123
|
+
|
|
124
|
+
expect(result).toContain("<script>");
|
|
125
|
+
expect(result).toContain("WebSocket");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { getHmrClientScript, createHmrPostTransform } from "../../src/dev-server/hmr-client-script";
|
|
3
|
+
|
|
4
|
+
describe("getHmrClientScript", () => {
|
|
5
|
+
it("유효한 JavaScript를 생성한다", () => {
|
|
6
|
+
const script = getHmrClientScript("/app/");
|
|
7
|
+
// new Function으로 구문 오류 확인
|
|
8
|
+
expect(() => new Function(script)).not.toThrow();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("IIFE로 감싸져 있다", () => {
|
|
12
|
+
const script = getHmrClientScript("/app/");
|
|
13
|
+
expect(script.trimStart()).toMatch(/^\(function\(\)/);
|
|
14
|
+
expect(script.trimEnd()).toMatch(/\}\)\(\);$/);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("const/let 대신 var를 사용한다", () => {
|
|
18
|
+
const script = getHmrClientScript("/app/");
|
|
19
|
+
// var 사용 확인
|
|
20
|
+
expect(script).toContain("var ws");
|
|
21
|
+
// const/let 미사용 확인
|
|
22
|
+
expect(script).not.toMatch(/\bconst\b/);
|
|
23
|
+
expect(script).not.toMatch(/\blet\b/);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("createHmrPostTransform", () => {
|
|
28
|
+
it("여러 </body> 태그가 있으면 마지막 것 앞에 주입한다", async () => {
|
|
29
|
+
const transform = createHmrPostTransform("/app/");
|
|
30
|
+
const html = "<body>first</body><body>second</body>";
|
|
31
|
+
const result = await transform(html);
|
|
32
|
+
|
|
33
|
+
// 마지막 </body> 직전에 주입
|
|
34
|
+
const lastIdx = result.lastIndexOf("</body>");
|
|
35
|
+
const scriptIdx = result.lastIndexOf("<script>");
|
|
36
|
+
expect(scriptIdx).toBeLessThan(lastIdx);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("빈 HTML에도 스크립트를 추가한다", async () => {
|
|
40
|
+
const transform = createHmrPostTransform("/");
|
|
41
|
+
const result = await transform("");
|
|
42
|
+
expect(result).toContain("<script>");
|
|
43
|
+
});
|
|
44
|
+
});
|