@nativescript/vite 8.0.0-beta.0 → 8.0.0-rc.0
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 +73 -14
- package/bin/cli.cjs +8 -14
- package/configuration/angular.d.ts +35 -2
- package/configuration/angular.js +541 -216
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +227 -77
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +17 -96
- package/configuration/javascript.js.map +1 -1
- package/configuration/react.js +41 -73
- package/configuration/react.js.map +1 -1
- package/configuration/solid.js +58 -6
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +15 -96
- package/configuration/typescript.js.map +1 -1
- package/helpers/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-refresh.d.ts +31 -0
- package/helpers/app-css-refresh.js +43 -0
- package/helpers/app-css-refresh.js.map +1 -0
- package/helpers/app-css-state.d.ts +17 -0
- package/helpers/app-css-state.js +51 -0
- package/helpers/app-css-state.js.map +1 -0
- package/helpers/bundler-context.d.ts +11 -0
- package/helpers/bundler-context.js +71 -0
- package/helpers/bundler-context.js.map +1 -0
- package/helpers/cli-flags.d.ts +12 -0
- package/helpers/cli-flags.js +34 -0
- package/helpers/cli-flags.js.map +1 -1
- package/helpers/commonjs-plugins.d.ts +5 -2
- package/helpers/commonjs-plugins.js +126 -0
- package/helpers/commonjs-plugins.js.map +1 -1
- package/helpers/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/css-platform-plugin.d.ts +14 -0
- package/helpers/css-platform-plugin.js +43 -25
- package/helpers/css-platform-plugin.js.map +1 -1
- package/helpers/dev-host.d.ts +360 -0
- package/helpers/dev-host.js +694 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/dynamic-import-plugin.d.ts +2 -1
- package/helpers/dynamic-import-plugin.js +59 -53
- package/helpers/dynamic-import-plugin.js.map +1 -1
- package/helpers/esbuild-platform-resolver.js +9 -6
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/external-configs.d.ts +10 -4
- package/helpers/external-configs.js +63 -15
- package/helpers/external-configs.js.map +1 -1
- package/helpers/flavor.d.ts +13 -0
- package/helpers/flavor.js +18 -1
- package/helpers/flavor.js.map +1 -1
- package/helpers/global-defines.d.ts +117 -0
- package/helpers/global-defines.js +209 -11
- package/helpers/global-defines.js.map +1 -1
- package/helpers/hmr-scope.d.ts +26 -0
- package/helpers/hmr-scope.js +67 -0
- package/helpers/hmr-scope.js.map +1 -0
- package/helpers/import-meta-path.d.ts +4 -0
- package/helpers/import-meta-path.js +5 -0
- package/helpers/import-meta-path.js.map +1 -0
- package/helpers/import-specifier.d.ts +1 -0
- package/helpers/import-specifier.js +18 -0
- package/helpers/import-specifier.js.map +1 -0
- package/helpers/init.js +6 -20
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +1 -0
- package/helpers/logging.js +65 -4
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +8 -2
- package/helpers/main-entry.js +622 -120
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js +6 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.d.ts +13 -0
- package/helpers/nativeclass-transform.js +42 -131
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +19 -1
- package/helpers/nativeclass-transformer-plugin.js +324 -37
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +10 -62
- package/helpers/nativescript-package-resolver.js.map +1 -1
- package/helpers/normalize-id.d.ts +42 -0
- package/helpers/normalize-id.js +60 -0
- package/helpers/normalize-id.js.map +1 -0
- package/helpers/ns-core-external-urls.d.ts +32 -0
- package/helpers/ns-core-external-urls.js +107 -0
- package/helpers/ns-core-external-urls.js.map +1 -0
- package/helpers/ns-core-url.d.ts +106 -0
- package/helpers/ns-core-url.js +225 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/optimize-deps.d.ts +16 -0
- package/helpers/optimize-deps.js +17 -0
- package/helpers/optimize-deps.js.map +1 -0
- package/helpers/package-platform-aliases.js +34 -49
- package/helpers/package-platform-aliases.js.map +1 -1
- package/helpers/platform-types.d.ts +2 -0
- package/helpers/platform-types.js +2 -0
- package/helpers/platform-types.js.map +1 -0
- package/helpers/postcss-platform-config.d.ts +17 -1
- package/helpers/postcss-platform-config.js +20 -37
- package/helpers/postcss-platform-config.js.map +1 -1
- package/helpers/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/resolve-main-field-platform.d.ts +20 -0
- package/helpers/resolve-main-field-platform.js +49 -0
- package/helpers/resolve-main-field-platform.js.map +1 -0
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/theme-core-plugins.js +1 -1
- package/helpers/theme-core-plugins.js.map +1 -1
- package/helpers/ts-config-paths.d.ts +32 -0
- package/helpers/ts-config-paths.js +156 -27
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +2 -1
- package/helpers/typescript-check.js +4 -4
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/ui-registration.d.ts +21 -0
- package/helpers/ui-registration.js +156 -0
- package/helpers/ui-registration.js.map +1 -0
- package/helpers/utils.d.ts +9 -0
- package/helpers/utils.js +22 -2
- package/helpers/utils.js.map +1 -1
- package/helpers/vite-package-version.d.ts +7 -0
- package/helpers/vite-package-version.js +44 -0
- package/helpers/vite-package-version.js.map +1 -0
- package/helpers/workers.d.ts +40 -19
- package/helpers/workers.js +312 -13
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +2 -1
- package/hmr/client/css-handler.js +95 -23
- package/hmr/client/css-handler.js.map +1 -1
- package/hmr/client/css-update-overlay.d.ts +18 -0
- package/hmr/client/css-update-overlay.js +27 -0
- package/hmr/client/css-update-overlay.js.map +1 -0
- package/hmr/client/framework-client-strategy.d.ts +87 -0
- package/hmr/client/framework-client-strategy.js +18 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +13 -0
- package/hmr/client/hmr-pending-overlay.js +41 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/hot-context.d.ts +67 -0
- package/hmr/client/hot-context.js +307 -0
- package/hmr/client/hot-context.js.map +1 -0
- package/hmr/client/index.d.ts +9 -1
- package/hmr/client/index.js +91 -1418
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/overlay-driver.d.ts +10 -0
- package/hmr/client/overlay-driver.js +33 -0
- package/hmr/client/overlay-driver.js.map +1 -0
- package/hmr/client/protocol-dispatch.d.ts +8 -0
- package/hmr/client/protocol-dispatch.js +308 -0
- package/hmr/client/protocol-dispatch.js.map +1 -0
- package/hmr/client/root-reset.d.ts +15 -0
- package/hmr/client/root-reset.js +358 -0
- package/hmr/client/root-reset.js.map +1 -0
- package/hmr/client/strategy-loader.d.ts +24 -0
- package/hmr/client/strategy-loader.js +100 -0
- package/hmr/client/strategy-loader.js.map +1 -0
- package/hmr/client/update-pipeline.d.ts +27 -0
- package/hmr/client/update-pipeline.js +464 -0
- package/hmr/client/update-pipeline.js.map +1 -0
- package/hmr/client/utils.d.ts +14 -1
- package/hmr/client/utils.js +265 -54
- package/hmr/client/utils.js.map +1 -1
- package/hmr/client/ws-transport.d.ts +21 -0
- package/hmr/client/ws-transport.js +323 -0
- package/hmr/client/ws-transport.js.map +1 -0
- package/hmr/entry-runtime.d.ts +11 -0
- package/hmr/entry-runtime.js +566 -43
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
- package/hmr/frameworks/angular/build/angular-linker.js +113 -0
- package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.d.ts +3 -0
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js +231 -0
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
- package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
- package/hmr/frameworks/angular/build/js-lexer.js +182 -0
- package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
- package/hmr/frameworks/angular/build/linker-stats.d.ts +18 -0
- package/hmr/frameworks/angular/build/linker-stats.js +29 -0
- package/hmr/frameworks/angular/build/linker-stats.js.map +1 -0
- package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
- package/hmr/frameworks/angular/build/shared-linker.js +128 -0
- package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.d.ts +1 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.d.ts +3 -0
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js +241 -0
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.d.ts +5 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.js +138 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
- package/hmr/frameworks/angular/build/util.js +155 -0
- package/hmr/frameworks/angular/build/util.js.map +1 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.d.ts +5 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.js +140 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.js.map +1 -0
- package/hmr/frameworks/angular/client/index.d.ts +2 -1
- package/hmr/frameworks/angular/client/index.js +637 -23
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
- package/hmr/frameworks/angular/client/strategy.js +19 -0
- package/hmr/frameworks/angular/client/strategy.js.map +1 -0
- package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
- package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
- package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
- package/hmr/frameworks/angular/server/linker.js +37 -6
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/ng-component-route.d.ts +43 -0
- package/hmr/frameworks/angular/server/ng-component-route.js +113 -0
- package/hmr/frameworks/angular/server/ng-component-route.js.map +1 -0
- package/hmr/frameworks/angular/server/strategy.js +697 -18
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/angular/server/websocket-angular-entry.d.ts +2 -0
- package/hmr/frameworks/angular/server/websocket-angular-entry.js +68 -0
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.d.ts +94 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +485 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/frameworks/react/client/strategy.d.ts +12 -0
- package/hmr/frameworks/react/client/strategy.js +27 -0
- package/hmr/frameworks/react/client/strategy.js.map +1 -0
- package/hmr/frameworks/react/server/strategy.d.ts +2 -0
- package/hmr/frameworks/react/server/strategy.js +230 -0
- package/hmr/frameworks/react/server/strategy.js.map +1 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
- package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
- package/hmr/frameworks/solid/client/app-runtime.js +252 -0
- package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
- package/hmr/frameworks/solid/client/strategy.d.ts +7 -0
- package/hmr/frameworks/solid/client/strategy.js +391 -0
- package/hmr/frameworks/solid/client/strategy.js.map +1 -0
- package/hmr/frameworks/solid/server/strategy.js +293 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/client/strategy.d.ts +7 -0
- package/hmr/frameworks/typescript/client/strategy.js +418 -0
- package/hmr/frameworks/typescript/client/strategy.js.map +1 -0
- package/hmr/frameworks/typescript/server/strategy.js +48 -16
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
- package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
- package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +10 -1
- package/hmr/frameworks/vue/client/index.js +287 -562
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/navigate-app.d.ts +3 -0
- package/hmr/frameworks/vue/client/navigate-app.js +178 -0
- package/hmr/frameworks/vue/client/navigate-app.js.map +1 -0
- package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
- package/hmr/frameworks/vue/client/strategy.js +152 -0
- package/hmr/frameworks/vue/client/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +124 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
- package/hmr/frameworks/vue/server/compiler.js +3 -1
- package/hmr/frameworks/vue/server/compiler.js.map +1 -1
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
- package/hmr/frameworks/vue/server/strategy.js +291 -7
- package/hmr/frameworks/vue/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
- package/hmr/helpers/ast-normalizer.d.ts +3 -1
- package/hmr/helpers/ast-normalizer.js +131 -24
- package/hmr/helpers/ast-normalizer.js.map +1 -1
- package/hmr/helpers/cjs-named-exports.d.ts +23 -0
- package/hmr/helpers/cjs-named-exports.js +152 -0
- package/hmr/helpers/cjs-named-exports.js.map +1 -0
- package/hmr/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/helpers/vendor-rewrite.d.ts +1 -1
- package/hmr/helpers/vendor-rewrite.js +5 -3
- package/hmr/helpers/vendor-rewrite.js.map +1 -1
- package/hmr/server/boot-recording.d.ts +51 -0
- package/hmr/server/boot-recording.js +214 -0
- package/hmr/server/boot-recording.js.map +1 -0
- package/hmr/server/constants.d.ts +1 -0
- package/hmr/server/constants.js +21 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/content-css-update.d.ts +54 -0
- package/hmr/server/content-css-update.js +78 -0
- package/hmr/server/content-css-update.js.map +1 -0
- package/hmr/server/core-bundle.d.ts +140 -0
- package/hmr/server/core-bundle.js +614 -0
- package/hmr/server/core-bundle.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +130 -4
- package/hmr/server/core-sanitize.js +393 -32
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/css-connect-sync.d.ts +28 -0
- package/hmr/server/css-connect-sync.js +59 -0
- package/hmr/server/css-connect-sync.js.map +1 -0
- package/hmr/server/css-device-module.d.ts +28 -0
- package/hmr/server/css-device-module.js +44 -0
- package/hmr/server/css-device-module.js.map +1 -0
- package/hmr/server/css-update-message.d.ts +23 -0
- package/hmr/server/css-update-message.js +41 -0
- package/hmr/server/css-update-message.js.map +1 -0
- package/hmr/server/deps-bundle.d.ts +233 -0
- package/hmr/server/deps-bundle.js +1022 -0
- package/hmr/server/deps-bundle.js.map +1 -0
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +408 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +182 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +215 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +99 -0
- package/hmr/server/import-map.js +294 -0
- package/hmr/server/import-map.js.map +1 -0
- package/hmr/server/index.d.ts +2 -1
- package/hmr/server/index.js +7 -16
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/node-builtins-route.d.ts +12 -0
- package/hmr/server/node-builtins-route.js +86 -0
- package/hmr/server/node-builtins-route.js.map +1 -0
- package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
- package/hmr/server/ns-core-cjs-shape.js +271 -0
- package/hmr/server/ns-core-cjs-shape.js.map +1 -0
- package/hmr/server/ns-m-response-memo.d.ts +10 -0
- package/hmr/server/ns-m-response-memo.js +33 -0
- package/hmr/server/ns-m-response-memo.js.map +1 -0
- package/hmr/server/ns-rt-bridge.d.ts +51 -0
- package/hmr/server/ns-rt-bridge.js +131 -0
- package/hmr/server/ns-rt-bridge.js.map +1 -0
- package/hmr/server/ns-rt-route.d.ts +5 -0
- package/hmr/server/ns-rt-route.js +39 -0
- package/hmr/server/ns-rt-route.js.map +1 -0
- package/hmr/server/perf-instrumentation.d.ts +114 -0
- package/hmr/server/perf-instrumentation.js +197 -0
- package/hmr/server/perf-instrumentation.js.map +1 -0
- package/hmr/server/process-code-for-device.d.ts +44 -0
- package/hmr/server/process-code-for-device.js +834 -0
- package/hmr/server/process-code-for-device.js.map +1 -0
- package/hmr/server/require-guard.d.ts +1 -0
- package/hmr/server/require-guard.js +12 -0
- package/hmr/server/require-guard.js.map +1 -0
- package/hmr/server/rewrite-imports.d.ts +2 -0
- package/hmr/server/rewrite-imports.js +631 -0
- package/hmr/server/rewrite-imports.js.map +1 -0
- package/hmr/server/route-helpers.d.ts +7 -0
- package/hmr/server/route-helpers.js +13 -0
- package/hmr/server/route-helpers.js.map +1 -0
- package/hmr/server/runtime-graph-filter.d.ts +5 -0
- package/hmr/server/runtime-graph-filter.js +28 -0
- package/hmr/server/runtime-graph-filter.js.map +1 -0
- package/hmr/server/server-origin.d.ts +2 -0
- package/hmr/server/server-origin.js +88 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.d.ts +12 -0
- package/hmr/server/shared-transform-request.js +143 -0
- package/hmr/server/shared-transform-request.js.map +1 -0
- package/hmr/server/socket-utils.d.ts +10 -0
- package/hmr/server/socket-utils.js +14 -0
- package/hmr/server/socket-utils.js.map +1 -0
- package/hmr/server/transform-cache-invalidation.d.ts +37 -0
- package/hmr/server/transform-cache-invalidation.js +156 -0
- package/hmr/server/transform-cache-invalidation.js.map +1 -0
- package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
- package/hmr/server/vendor-bare-module-shims.js +80 -0
- package/hmr/server/vendor-bare-module-shims.js.map +1 -0
- package/hmr/server/vite-plugin.d.ts +22 -1
- package/hmr/server/vite-plugin.js +655 -58
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +68 -0
- package/hmr/server/websocket-core-bridge.js +370 -0
- package/hmr/server/websocket-core-bridge.js.map +1 -0
- package/hmr/server/websocket-device-transform.d.ts +3 -0
- package/hmr/server/websocket-device-transform.js +7 -0
- package/hmr/server/websocket-device-transform.js.map +1 -0
- package/hmr/server/websocket-graph-upsert.d.ts +21 -0
- package/hmr/server/websocket-graph-upsert.js +33 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -0
- package/hmr/server/websocket-hmr-pending.d.ts +29 -0
- package/hmr/server/websocket-hmr-pending.js +33 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-hot-update.d.ts +80 -0
- package/hmr/server/websocket-hot-update.js +295 -0
- package/hmr/server/websocket-hot-update.js.map +1 -0
- package/hmr/server/websocket-import-map-route.d.ts +15 -0
- package/hmr/server/websocket-import-map-route.js +51 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.d.ts +21 -0
- package/hmr/server/websocket-module-bindings.js +504 -0
- package/hmr/server/websocket-module-bindings.js.map +1 -0
- package/hmr/server/websocket-module-specifiers.d.ts +96 -0
- package/hmr/server/websocket-module-specifiers.js +819 -0
- package/hmr/server/websocket-module-specifiers.js.map +1 -0
- package/hmr/server/websocket-ns-core.d.ts +34 -0
- package/hmr/server/websocket-ns-core.js +414 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +21 -0
- package/hmr/server/websocket-ns-entry.js +163 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +19 -0
- package/hmr/server/websocket-ns-m-paths.js +115 -0
- package/hmr/server/websocket-ns-m-paths.js.map +1 -0
- package/hmr/server/websocket-ns-m-request.d.ts +46 -0
- package/hmr/server/websocket-ns-m-request.js +197 -0
- package/hmr/server/websocket-ns-m-request.js.map +1 -0
- package/hmr/server/websocket-ns-m.d.ts +52 -0
- package/hmr/server/websocket-ns-m.js +590 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +89 -0
- package/hmr/server/websocket-served-module-helpers.js +935 -0
- package/hmr/server/websocket-served-module-helpers.js.map +1 -0
- package/hmr/server/websocket-txn.d.ts +6 -0
- package/hmr/server/websocket-txn.js +42 -0
- package/hmr/server/websocket-txn.js.map +1 -0
- package/hmr/server/websocket-vendor-unifier.d.ts +9 -0
- package/hmr/server/websocket-vendor-unifier.js +46 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket.d.ts +7 -17
- package/hmr/server/websocket.js +723 -5376
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +107 -0
- package/hmr/shared/ns-globals.js +29 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/package-classifier.d.ts +9 -0
- package/hmr/shared/package-classifier.js +58 -0
- package/hmr/shared/package-classifier.js.map +1 -0
- package/hmr/shared/protocol.d.ts +157 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.js.map +1 -0
- package/hmr/shared/runtime/boot-complete.d.ts +14 -0
- package/hmr/shared/runtime/boot-complete.js +32 -0
- package/hmr/shared/runtime/boot-complete.js.map +1 -0
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.d.ts +44 -0
- package/hmr/shared/runtime/boot-progress.js +134 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +17 -0
- package/hmr/shared/runtime/boot-timeline.js +40 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/browser-runtime-contract.d.ts +97 -0
- package/hmr/shared/runtime/browser-runtime-contract.js +66 -0
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-ios.d.ts +87 -0
- package/hmr/shared/runtime/dev-overlay-ios.js +521 -0
- package/hmr/shared/runtime/dev-overlay-ios.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-shared.d.ts +58 -0
- package/hmr/shared/runtime/dev-overlay-shared.js +116 -0
- package/hmr/shared/runtime/dev-overlay-shared.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-tree.d.ts +59 -0
- package/hmr/shared/runtime/dev-overlay-tree.js +712 -0
- package/hmr/shared/runtime/dev-overlay-tree.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +39 -0
- package/hmr/shared/runtime/dev-overlay.js +292 -0
- package/hmr/shared/runtime/dev-overlay.js.map +1 -0
- package/hmr/shared/runtime/global-scope.d.ts +18 -0
- package/hmr/shared/runtime/global-scope.js +21 -0
- package/hmr/shared/runtime/global-scope.js.map +1 -0
- package/hmr/shared/runtime/hooks.js +2 -1
- package/hmr/shared/runtime/hooks.js.map +1 -1
- package/hmr/shared/runtime/launch-bridge.d.ts +9 -0
- package/hmr/shared/runtime/launch-bridge.js +98 -0
- package/hmr/shared/runtime/launch-bridge.js.map +1 -0
- package/hmr/shared/runtime/module-provenance.d.ts +1 -0
- package/hmr/shared/runtime/module-provenance.js +64 -0
- package/hmr/shared/runtime/module-provenance.js.map +1 -0
- package/hmr/shared/runtime/ns-runtime-test-double.d.ts +21 -0
- package/hmr/shared/runtime/ns-runtime-test-double.js +20 -0
- package/hmr/shared/runtime/ns-runtime-test-double.js.map +1 -0
- package/hmr/shared/runtime/overlay-flag.d.ts +9 -0
- package/hmr/shared/runtime/overlay-flag.js +34 -0
- package/hmr/shared/runtime/overlay-flag.js.map +1 -0
- package/hmr/shared/runtime/platform-polyfills.d.ts +26 -0
- package/hmr/shared/runtime/platform-polyfills.js +122 -0
- package/hmr/shared/runtime/platform-polyfills.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +311 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
- package/hmr/shared/runtime/root-placeholder.js +778 -83
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.d.ts +1 -0
- package/hmr/shared/runtime/session-bootstrap.js +350 -0
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.js +54 -16
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-resolve.d.ts +22 -0
- package/hmr/shared/runtime/vendor-resolve.js +45 -0
- package/hmr/shared/runtime/vendor-resolve.js.map +1 -0
- package/hmr/shared/runtime/worker-tracking.d.ts +28 -0
- package/hmr/shared/runtime/worker-tracking.js +114 -0
- package/hmr/shared/runtime/worker-tracking.js.map +1 -0
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +909 -0
- package/hmr/shared/vendor/manifest-collect.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
- package/hmr/shared/vendor/manifest-loader.js +5 -3
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +12 -0
- package/hmr/shared/vendor/manifest.js +341 -545
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/registry.d.ts +2 -0
- package/hmr/shared/vendor/registry.js +118 -7
- package/hmr/shared/vendor/registry.js.map +1 -1
- package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
- package/hmr/shared/vendor/vendor-device-shim.js +208 -0
- package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +107 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +540 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +76 -14
- package/runtime/core-aliases-early.js +103 -81
- package/runtime/core-aliases-early.js.map +1 -1
- package/shims/react-jsx-runtime.d.ts +4 -0
- package/shims/react-jsx-runtime.js +61 -0
- package/shims/react-jsx-runtime.js.map +1 -0
- package/shims/solid-jsx-runtime.d.ts +7 -0
- package/shims/solid-jsx-runtime.js +17 -0
- package/shims/solid-jsx-runtime.js.map +1 -0
- package/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -189
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -4
- package/helpers/angular/shared-linker.js +0 -39
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/util.js +0 -67
- package/helpers/angular/util.js.map +0 -1
- package/helpers/module-runner-patch.d.ts +0 -3
- package/helpers/module-runner-patch.js +0 -63
- package/helpers/module-runner-patch.js.map +0 -1
- package/helpers/prelink-angular.d.ts +0 -2
- package/helpers/prelink-angular.js +0 -117
- package/helpers/prelink-angular.js.map +0 -1
- package/hmr/shared/runtime/http-only-boot.d.ts +0 -1
- package/hmr/shared/runtime/http-only-boot.js +0 -124
- package/hmr/shared/runtime/http-only-boot.js.map +0 -1
- package/hmr/vendor-bootstrap.d.ts +0 -3
- package/hmr/vendor-bootstrap.js +0 -32
- package/hmr/vendor-bootstrap.js.map +0 -1
- package/shims/react-reconciler-constants.d.ts +0 -14
- package/shims/react-reconciler-constants.js +0 -21
- package/shims/react-reconciler-constants.js.map +0 -1
- package/shims/react-reconciler.d.ts +0 -8
- package/shims/react-reconciler.js +0 -15
- package/shims/react-reconciler.js.map +0 -1
- package/transformers/NativeClass/index.d.ts +0 -2
- package/transformers/NativeClass/index.js +0 -222
- package/transformers/NativeClass/index.js.map +0 -1
package/configuration/angular.js
CHANGED
|
@@ -1,114 +1,72 @@
|
|
|
1
1
|
import { mergeConfig } from 'vite';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
4
|
import angular from '@analogjs/vite-plugin-angular';
|
|
6
|
-
import { angularLinkerVitePlugin, angularLinkerVitePluginPost } from '../
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { angularLinkerVitePlugin, angularLinkerVitePluginPost } from '../hmr/frameworks/angular/build/angular-linker.js';
|
|
6
|
+
import { synthesizeMissingInjectableFactories } from '../hmr/frameworks/angular/build/synthesize-injectable-factories.js';
|
|
7
|
+
import { getAngularLinkerFactory, runAngularLinker } from '../hmr/frameworks/angular/build/shared-linker.js';
|
|
8
|
+
import { recordLinkerHit, reportLinkerLayerStats } from '../hmr/frameworks/angular/build/linker-stats.js';
|
|
9
|
+
import { inlineDecoratorComponentTemplates } from '../hmr/frameworks/angular/build/inline-decorator-component-templates.js';
|
|
10
|
+
import { appendComponentHmrRegistration, findComponentClassNames, INJECTION_MARKER as HMR_REGISTER_MARKER } from '../hmr/frameworks/angular/build/inject-component-hmr-registration.js';
|
|
11
|
+
import { injectAngularHmrViteIgnore } from '../hmr/frameworks/angular/build/inject-hmr-vite-ignore.js';
|
|
12
|
+
import { synthesizeDecoratorCtorParameters } from '../hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js';
|
|
13
|
+
import { containsRealNgDeclare, stripJsComments } from '../hmr/frameworks/angular/build/util.js';
|
|
9
14
|
import { baseConfig } from './base.js';
|
|
10
15
|
import { getCliFlags } from '../helpers/cli-flags.js';
|
|
16
|
+
import { getMonorepoWorkspaceRoot } from '../helpers/project.js';
|
|
17
|
+
import { resolveRelativeToImportMeta } from '../helpers/import-meta-path.js';
|
|
18
|
+
import { resolveVerboseFlag } from '../helpers/logging.js';
|
|
19
|
+
import { NS_OPTIMIZE_DEPS_EXCLUDE } from '../helpers/optimize-deps.js';
|
|
20
|
+
function hasNgDeclarePartial(code) {
|
|
21
|
+
return code.indexOf('\u0275\u0275ngDeclare') !== -1 || code.indexOf('ɵɵngDeclare') !== -1 || code.indexOf('ngDeclare') !== -1;
|
|
22
|
+
}
|
|
11
23
|
// Rollup-level linker to guarantee Angular libraries are linked when included in the bundle graph.
|
|
12
24
|
function angularRollupLinker(projectRoot) {
|
|
13
|
-
let babel = null;
|
|
14
|
-
let createLinker = null;
|
|
15
25
|
const FILTER = /node_modules\/(?:@angular|@nativescript\/angular)\/.*\.[mc]?js$/;
|
|
16
|
-
|
|
17
|
-
if (babel && createLinker)
|
|
18
|
-
return;
|
|
19
|
-
try {
|
|
20
|
-
const req = createRequire((projectRoot ? projectRoot + '/package.json' : import.meta.url));
|
|
21
|
-
const babelPath = req.resolve('@babel/core');
|
|
22
|
-
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
23
|
-
babel = await import(babelPath);
|
|
24
|
-
const linkerMod = await import(linkerPath);
|
|
25
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
try {
|
|
29
|
-
babel = await import('@babel/core');
|
|
30
|
-
}
|
|
31
|
-
catch { }
|
|
32
|
-
try {
|
|
33
|
-
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
34
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin;
|
|
35
|
-
}
|
|
36
|
-
catch { }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
26
|
+
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
39
27
|
return {
|
|
40
28
|
name: 'ns-angular-linker-rollup',
|
|
41
29
|
enforce: 'pre',
|
|
42
30
|
apply: 'build',
|
|
43
31
|
async load(id) {
|
|
44
|
-
const
|
|
45
|
-
const cleanId = id.split('?', 1)[0];
|
|
32
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
46
33
|
if (!FILTER.test(cleanId))
|
|
47
34
|
return null;
|
|
48
35
|
try {
|
|
49
|
-
await ensureDeps();
|
|
50
|
-
if (!babel || !createLinker)
|
|
51
|
-
return null;
|
|
52
36
|
const fs = await import('node:fs/promises');
|
|
53
37
|
const code = await fs.readFile(cleanId, 'utf8');
|
|
54
38
|
const forceLink = cleanId.includes('/node_modules/@nativescript/angular/') && cleanId.includes('polyfills');
|
|
55
39
|
if (!code)
|
|
56
40
|
return null;
|
|
57
|
-
if (!forceLink &&
|
|
41
|
+
if (!forceLink && !hasNgDeclarePartial(code))
|
|
58
42
|
return null;
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
const result = await babel.transformAsync(code, {
|
|
67
|
-
filename: cleanId,
|
|
68
|
-
configFile: false,
|
|
69
|
-
babelrc: false,
|
|
70
|
-
sourceMaps: false,
|
|
71
|
-
compact: false,
|
|
72
|
-
plugins: [plugin],
|
|
73
|
-
});
|
|
74
|
-
if (result?.code && result.code !== code) {
|
|
75
|
-
return { code: result.code, map: null };
|
|
43
|
+
const linked = await runAngularLinker(code, { filename: cleanId, projectRoot, freshPlugin: true });
|
|
44
|
+
if (linked) {
|
|
45
|
+
recordLinkerHit('rollup-load');
|
|
46
|
+
if (debug)
|
|
47
|
+
console.log('[ns-angular-linker][rollup-load] linked', cleanId);
|
|
48
|
+
return { code: linked, map: null };
|
|
76
49
|
}
|
|
77
50
|
}
|
|
78
51
|
catch { }
|
|
79
52
|
return null;
|
|
80
53
|
},
|
|
81
54
|
async transform(code, id) {
|
|
82
|
-
const
|
|
83
|
-
const cleanId = id.split('?', 1)[0];
|
|
55
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
84
56
|
if (!FILTER.test(cleanId))
|
|
85
57
|
return null;
|
|
86
58
|
const forceLink = cleanId.includes('/node_modules/@nativescript/angular/') && cleanId.includes('polyfills');
|
|
87
59
|
if (!code)
|
|
88
60
|
return null;
|
|
89
|
-
if (!forceLink &&
|
|
90
|
-
return null;
|
|
91
|
-
await ensureDeps();
|
|
92
|
-
if (!babel || !createLinker)
|
|
61
|
+
if (!forceLink && !hasNgDeclarePartial(code))
|
|
93
62
|
return null;
|
|
94
63
|
try {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
const result = await babel.transformAsync(code, {
|
|
103
|
-
filename: cleanId,
|
|
104
|
-
configFile: false,
|
|
105
|
-
babelrc: false,
|
|
106
|
-
sourceMaps: false,
|
|
107
|
-
compact: false,
|
|
108
|
-
plugins: [plugin],
|
|
109
|
-
});
|
|
110
|
-
if (result?.code && result.code !== code) {
|
|
111
|
-
return { code: result.code, map: null };
|
|
64
|
+
const linked = await runAngularLinker(code, { filename: cleanId, projectRoot, freshPlugin: true });
|
|
65
|
+
if (linked) {
|
|
66
|
+
recordLinkerHit('rollup');
|
|
67
|
+
if (debug)
|
|
68
|
+
console.log('[ns-angular-linker][rollup] linked', cleanId);
|
|
69
|
+
return { code: linked, map: null };
|
|
112
70
|
}
|
|
113
71
|
}
|
|
114
72
|
catch { }
|
|
@@ -119,6 +77,24 @@ function angularRollupLinker(projectRoot) {
|
|
|
119
77
|
const cliFlags = getCliFlags();
|
|
120
78
|
const isDevEnv = process.env.NODE_ENV !== 'production';
|
|
121
79
|
const hmrActive = isDevEnv && !!cliFlags.hmr;
|
|
80
|
+
/**
|
|
81
|
+
* Web-style template HMR opt-out (`NS_VITE_ANGULAR_LIVE_RELOAD=0`).
|
|
82
|
+
*
|
|
83
|
+
* With HMR active we default to the in-place template-replacement pipeline
|
|
84
|
+
* (see the `liveReload` option below). If a project hits a regression
|
|
85
|
+
* (broken styling, unresolved `?ngcomp=` imports), this env flag rolls back
|
|
86
|
+
* to the legacy reboot pipeline without an upstream patch. `0`, `false`,
|
|
87
|
+
* `off`, and `no` (case-insensitive) mean "off"; anything else — including
|
|
88
|
+
* unset — keeps the new path on. Read once at module load, like `hmrActive`.
|
|
89
|
+
*/
|
|
90
|
+
const angularLiveReloadDisabledByEnv = (() => {
|
|
91
|
+
const raw = process.env.NS_VITE_ANGULAR_LIVE_RELOAD;
|
|
92
|
+
if (typeof raw !== 'string')
|
|
93
|
+
return false;
|
|
94
|
+
const v = raw.trim().toLowerCase();
|
|
95
|
+
return v === '0' || v === 'false' || v === 'off' || v === 'no';
|
|
96
|
+
})();
|
|
97
|
+
const hmrAngularLiveReload = hmrActive && !angularLiveReloadDisabledByEnv;
|
|
122
98
|
const projectRoot = process.cwd();
|
|
123
99
|
const tsConfigAppPath = path.resolve(projectRoot, 'tsconfig.app.json');
|
|
124
100
|
const tsConfigPath = path.resolve(projectRoot, 'tsconfig.json');
|
|
@@ -126,93 +102,441 @@ let tsConfig = tsConfigAppPath;
|
|
|
126
102
|
if (!fs.existsSync(tsConfigAppPath) && fs.existsSync(tsConfigPath)) {
|
|
127
103
|
tsConfig = tsConfigPath;
|
|
128
104
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
105
|
+
function normalizeAngularWatchPath(filePath) {
|
|
106
|
+
return filePath
|
|
107
|
+
.split('?', 1)[0]
|
|
108
|
+
.replace(/\\/g, '/')
|
|
109
|
+
.replace(/^file:\/\//, '');
|
|
110
|
+
}
|
|
111
|
+
function normalizeAngularWatchKey(filePath) {
|
|
112
|
+
const normalizedPath = normalizeAngularWatchPath(filePath);
|
|
113
|
+
const fileSystemPath = normalizedPath.startsWith('/@fs/') ? normalizedPath.slice('/@fs'.length) : normalizedPath;
|
|
114
|
+
const normalizedProjectRoot = projectRoot.replace(/\\/g, '/').replace(/\/$/, '');
|
|
115
|
+
if (normalizedProjectRoot && fileSystemPath.startsWith(normalizedProjectRoot)) {
|
|
116
|
+
const relative = fileSystemPath.slice(normalizedProjectRoot.length);
|
|
117
|
+
return relative.startsWith('/') ? relative : `/${relative}`;
|
|
118
|
+
}
|
|
119
|
+
return fileSystemPath;
|
|
120
|
+
}
|
|
121
|
+
function getAngularWatchKeys(filePath) {
|
|
122
|
+
const normalizedPath = normalizeAngularWatchPath(filePath);
|
|
123
|
+
const keys = new Set();
|
|
124
|
+
keys.add(normalizedPath);
|
|
125
|
+
keys.add(normalizeAngularWatchKey(normalizedPath));
|
|
126
|
+
return Array.from(keys).filter(Boolean);
|
|
127
|
+
}
|
|
128
|
+
function resolveAngularWatchFilePath(filePath) {
|
|
129
|
+
const normalizedPath = normalizeAngularWatchPath(filePath);
|
|
130
|
+
const fileSystemPath = normalizedPath.startsWith('/@fs/') ? normalizedPath.slice('/@fs'.length) : normalizedPath;
|
|
131
|
+
if (path.isAbsolute(fileSystemPath) && fs.existsSync(fileSystemPath)) {
|
|
132
|
+
return fileSystemPath;
|
|
133
|
+
}
|
|
134
|
+
if (fileSystemPath.startsWith('/')) {
|
|
135
|
+
return path.resolve(projectRoot, `.${fileSystemPath}`);
|
|
136
|
+
}
|
|
137
|
+
return path.resolve(projectRoot, fileSystemPath);
|
|
138
|
+
}
|
|
139
|
+
function extractComponentAssetPaths(code, componentId) {
|
|
140
|
+
const componentPath = normalizeAngularWatchPath(componentId);
|
|
141
|
+
const assetPaths = new Set();
|
|
142
|
+
const resolveAssetPath = (assetPath) => normalizeAngularWatchPath(path.resolve(path.dirname(componentPath), assetPath));
|
|
143
|
+
// Blank out `//` and `/* */` comments before scanning. The regexes below
|
|
144
|
+
// are intentionally simple (no JS parser) so they would otherwise match
|
|
145
|
+
// commented-out `templateUrl` / `styleUrls` declarations and register
|
|
146
|
+
// phantom asset deps via `addWatchFile`. In current Rolldown-Vite that
|
|
147
|
+
// also enrolls them as `_addedImports`, which `vite:import-analysis`
|
|
148
|
+
// then tries to resolve — surfacing as a misleading
|
|
149
|
+
// `Failed to resolve import "<file>" from "<importer>". Does the file
|
|
150
|
+
// exist?` pre-transform error if the file (predictably) doesn't exist.
|
|
151
|
+
const scanCode = stripJsComments(code);
|
|
152
|
+
const templateUrlMatch = scanCode.match(/templateUrl\s*:\s*['"](.+?\.(?:html|htm))['"]/);
|
|
153
|
+
if (templateUrlMatch) {
|
|
154
|
+
assetPaths.add(resolveAssetPath(templateUrlMatch[1]));
|
|
155
|
+
}
|
|
156
|
+
const styleUrlMatch = scanCode.match(/styleUrl\s*:\s*['"](.+?\.(?:css|less|sass|scss))['"]/);
|
|
157
|
+
if (styleUrlMatch) {
|
|
158
|
+
assetPaths.add(resolveAssetPath(styleUrlMatch[1]));
|
|
159
|
+
}
|
|
160
|
+
const styleUrlsMatch = scanCode.match(/styleUrls\s*:\s*\[([\s\S]*?)\]/m);
|
|
161
|
+
if (styleUrlsMatch) {
|
|
162
|
+
for (const match of styleUrlsMatch[1].matchAll(/['"](.+?\.(?:css|less|sass|scss))['"]/g)) {
|
|
163
|
+
assetPaths.add(resolveAssetPath(match[1]));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return Array.from(assetPaths);
|
|
167
|
+
}
|
|
168
|
+
function createAngularPlugins(opts) {
|
|
169
|
+
const verbose = resolveVerboseFlag();
|
|
170
|
+
const assetToComponents = new Map();
|
|
171
|
+
const componentToAssets = new Map();
|
|
172
|
+
const pendingComponentInvalidations = new Set();
|
|
173
|
+
// Shared state between the `enforce: 'pre'` discovery plugin and the
|
|
174
|
+
// `enforce: 'post'` injection plugin. Maps a clean (no-querystring)
|
|
175
|
+
// .ts file id to the list of `@Component`-decorated class names found
|
|
176
|
+
// in its RAW TypeScript source. The pre plugin populates this map;
|
|
177
|
+
// the post plugin reads it to know which class names to register
|
|
178
|
+
// against the compiled output. Cleared on each pre-plugin invocation
|
|
179
|
+
// so renames or `@Component` removals don't leave stale entries.
|
|
180
|
+
const componentsByCleanId = new Map();
|
|
181
|
+
const untrackComponentAssets = (componentPath) => {
|
|
182
|
+
const previousAssets = componentToAssets.get(componentPath);
|
|
183
|
+
if (!previousAssets)
|
|
184
|
+
return;
|
|
185
|
+
for (const assetPath of previousAssets) {
|
|
186
|
+
const components = assetToComponents.get(assetPath);
|
|
187
|
+
if (!components)
|
|
188
|
+
continue;
|
|
189
|
+
components.delete(componentPath);
|
|
190
|
+
if (components.size === 0) {
|
|
191
|
+
assetToComponents.delete(assetPath);
|
|
142
192
|
}
|
|
143
|
-
|
|
193
|
+
}
|
|
194
|
+
componentToAssets.delete(componentPath);
|
|
195
|
+
};
|
|
196
|
+
const trackComponentAssets = (componentPath, assetPaths) => {
|
|
197
|
+
untrackComponentAssets(componentPath);
|
|
198
|
+
if (assetPaths.length === 0)
|
|
199
|
+
return;
|
|
200
|
+
const normalizedAssets = new Set(assetPaths.flatMap((assetPath) => getAngularWatchKeys(assetPath)));
|
|
201
|
+
componentToAssets.set(componentPath, normalizedAssets);
|
|
202
|
+
for (const assetPath of normalizedAssets) {
|
|
203
|
+
const components = assetToComponents.get(assetPath) || new Set();
|
|
204
|
+
components.add(componentPath);
|
|
205
|
+
assetToComponents.set(assetPath, components);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const isCandidateComponentTs = (cleanId) => {
|
|
209
|
+
if (!cleanId.endsWith('.ts'))
|
|
210
|
+
return false;
|
|
211
|
+
if (cleanId.includes('/node_modules/'))
|
|
212
|
+
return false;
|
|
213
|
+
if (cleanId.endsWith('.d.ts'))
|
|
214
|
+
return false;
|
|
215
|
+
if (cleanId.endsWith('.spec.ts') || cleanId.endsWith('.test.ts'))
|
|
216
|
+
return false;
|
|
217
|
+
return true;
|
|
218
|
+
};
|
|
219
|
+
return [
|
|
220
|
+
// HMR self-registration runs in two steps:
|
|
221
|
+
//
|
|
222
|
+
// 1. (this plugin, `enforce: 'pre'`) Record the names of
|
|
223
|
+
// `@Component`-decorated classes from the RAW TypeScript source
|
|
224
|
+
// into `componentsByCleanId` — discovery must happen pre-compile
|
|
225
|
+
// because the Analog plugin rewrites the textual decorator away.
|
|
226
|
+
// 2. (`ns-component-hmr-register-post`, `enforce: 'post'`) Append the
|
|
227
|
+
// `__NS_HMR_REGISTER_COMPONENT__` calls to the COMPILED output.
|
|
228
|
+
//
|
|
229
|
+
// The split is mandatory: Analog's `transform` returns its own compiled
|
|
230
|
+
// output (from its `outputFiles` cache), silently discarding any code
|
|
231
|
+
// modification made earlier in the pipeline — appending in the pre
|
|
232
|
+
// plugin leaves the HMR class registry empty.
|
|
233
|
+
//
|
|
234
|
+
// `apply: 'serve'` (registry hook is dev-only) but intentionally NOT
|
|
235
|
+
// gated on `hmrActive`: the injected snippet self-guards on
|
|
236
|
+
// `typeof globalThis.__NS_HMR_REGISTER_COMPONENT__ === 'function'`, and
|
|
237
|
+
// gating the transform itself left `--no-hmr` users with an empty
|
|
238
|
+
// registry.
|
|
239
|
+
{
|
|
240
|
+
name: 'ns-component-hmr-register',
|
|
241
|
+
enforce: 'pre',
|
|
242
|
+
apply: 'serve',
|
|
243
|
+
transform(code, id) {
|
|
244
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
245
|
+
if (!isCandidateComponentTs(cleanId))
|
|
246
|
+
return null;
|
|
247
|
+
const componentNames = findComponentClassNames(code);
|
|
248
|
+
if (componentNames.length === 0) {
|
|
249
|
+
// Drop any stale entry from a previous transform
|
|
250
|
+
// pass; the file may have lost its `@Component`
|
|
251
|
+
// decorator across a rename/refactor.
|
|
252
|
+
componentsByCleanId.delete(cleanId);
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
componentsByCleanId.set(cleanId, componentNames);
|
|
256
|
+
if (verbose) {
|
|
257
|
+
console.info(`[ns-hmr][ns-component-hmr-register] discovered ${componentNames.length} component(s) in ${cleanId} (${componentNames.join(', ')})`);
|
|
258
|
+
}
|
|
259
|
+
// Discovery only — never modify the raw TS source. Any
|
|
260
|
+
// modification here is discarded by the Analog Angular
|
|
261
|
+
// plugin downstream; the actual snippet append happens
|
|
262
|
+
// in `ns-component-hmr-register-post`.
|
|
263
|
+
return null;
|
|
264
|
+
},
|
|
144
265
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
266
|
+
// Step 2: append the HMR registration snippet to the compiled output
|
|
267
|
+
// (post-Analog), keyed by the names recorded in step 1.
|
|
268
|
+
{
|
|
269
|
+
name: 'ns-component-hmr-register-post',
|
|
270
|
+
enforce: 'post',
|
|
271
|
+
apply: 'serve',
|
|
272
|
+
transform(code, id) {
|
|
273
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
274
|
+
if (!isCandidateComponentTs(cleanId))
|
|
275
|
+
return null;
|
|
276
|
+
const componentNames = componentsByCleanId.get(cleanId);
|
|
277
|
+
if (!componentNames || componentNames.length === 0)
|
|
278
|
+
return null;
|
|
279
|
+
// Idempotency: Vite may replay transforms on cached modules; the
|
|
280
|
+
// marker guards against double-injection.
|
|
281
|
+
if (code.includes(HMR_REGISTER_MARKER))
|
|
282
|
+
return null;
|
|
283
|
+
const result = appendComponentHmrRegistration(code, componentNames);
|
|
284
|
+
if (!result.code)
|
|
285
|
+
return null;
|
|
286
|
+
if (verbose) {
|
|
287
|
+
console.info(`[ns-hmr][ns-component-hmr-register-post] appended registrations for ${result.componentNames.length} component(s) in ${cleanId} (${result.componentNames.join(', ')})`);
|
|
288
|
+
}
|
|
289
|
+
// map: null is fine for dev — the appended snippet sits after the
|
|
290
|
+
// original body, so upstream line mappings stay valid.
|
|
291
|
+
return { code: result.code, map: null };
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
// Allow external html template changes to trigger hot reload: Make .ts files depend on their .html templates
|
|
295
|
+
{
|
|
296
|
+
name: 'angular-template-deps',
|
|
297
|
+
enforce: 'pre',
|
|
298
|
+
transform(code, id) {
|
|
299
|
+
const componentPath = normalizeAngularWatchPath(id);
|
|
300
|
+
const componentKey = normalizeAngularWatchKey(id);
|
|
301
|
+
if (!componentKey.endsWith('.ts'))
|
|
302
|
+
return null;
|
|
303
|
+
const assetPaths = extractComponentAssetPaths(code, componentPath);
|
|
304
|
+
trackComponentAssets(componentKey, assetPaths);
|
|
305
|
+
for (const assetPath of assetPaths) {
|
|
306
|
+
this.addWatchFile(assetPath);
|
|
307
|
+
}
|
|
308
|
+
// First fence of the HTML→TS invalidation pipeline: no [tracking]
|
|
309
|
+
// log for a component means the watcher can never fire for it.
|
|
310
|
+
if (verbose) {
|
|
311
|
+
console.info(`[ns-hmr][angular-template-deps] [tracking] componentKey=${componentKey} assets=${assetPaths.length} (${assetPaths.slice(0, 4).join(', ')})`);
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
},
|
|
315
|
+
watchChange(id) {
|
|
316
|
+
const changedPath = normalizeAngularWatchPath(id);
|
|
317
|
+
const components = new Set();
|
|
318
|
+
for (const assetKey of getAngularWatchKeys(changedPath)) {
|
|
319
|
+
for (const componentPath of assetToComponents.get(assetKey) || []) {
|
|
320
|
+
components.add(componentPath);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (components?.size) {
|
|
324
|
+
for (const componentPath of components) {
|
|
325
|
+
pendingComponentInvalidations.add(componentPath);
|
|
326
|
+
}
|
|
327
|
+
if (verbose) {
|
|
328
|
+
console.info(`[ns-hmr][angular-template-deps] watchChange [via assetToComponents] changed=${changedPath} → invalidating ${components.size} component(s):`, Array.from(components));
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (/\.(html|htm)$/i.test(changedPath)) {
|
|
333
|
+
const componentPath = changedPath.replace(/\.(html|htm)$/i, '.ts');
|
|
334
|
+
const exists = fs.existsSync(resolveAngularWatchFilePath(componentPath));
|
|
335
|
+
if (exists) {
|
|
336
|
+
const componentKey = normalizeAngularWatchKey(componentPath);
|
|
337
|
+
pendingComponentInvalidations.add(componentKey);
|
|
338
|
+
if (verbose) {
|
|
339
|
+
console.info(`[ns-hmr][angular-template-deps] watchChange [via fallback .html→.ts] changed=${changedPath} componentKey=${componentKey}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
// Truly anomalous: a watched template/style asset has no companion
|
|
344
|
+
// `.ts` file, so we cannot route the edit through the Angular
|
|
345
|
+
// HMR pipeline. Always-on warning so it surfaces in non-verbose
|
|
346
|
+
// runs — silent fallback would hide a real wiring break.
|
|
347
|
+
console.warn(`[ns-hmr][angular-template-deps] watchChange [no companion .ts found] changed=${changedPath} expectedTs=${componentPath}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
shouldTransformCachedModule({ id }) {
|
|
352
|
+
const componentPath = normalizeAngularWatchKey(id);
|
|
353
|
+
if (!pendingComponentInvalidations.has(componentPath))
|
|
354
|
+
return null;
|
|
355
|
+
pendingComponentInvalidations.delete(componentPath);
|
|
356
|
+
if (verbose) {
|
|
357
|
+
console.info(`[ns-hmr][angular-template-deps] shouldTransformCachedModule → re-transform componentKey=${componentPath}`);
|
|
358
|
+
}
|
|
359
|
+
return true;
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
// Transform Angular partial declarations in node_modules to avoid runtime JIT
|
|
363
|
+
// Pass the project root so linker deps resolve from the app, not the plugin package.
|
|
364
|
+
angularLinkerVitePlugin(process.cwd()),
|
|
365
|
+
// A Rollup-phase linker safety net (angularRollupLinker) is additionally
|
|
366
|
+
// appended for HMR sessions — see `enableRollupLinker` below.
|
|
367
|
+
...angular({
|
|
368
|
+
experimental: {
|
|
369
|
+
useAngularCompilationAPI: opts.useAngularCompilationAPI,
|
|
370
|
+
},
|
|
371
|
+
// `liveReload` enables Angular's web-style in-place template HMR:
|
|
372
|
+
// 1. `_enableHmr = true` on the TS compiler — each compiled component
|
|
373
|
+
// `.mjs` emits `<ClassName>_HmrLoad` plus an
|
|
374
|
+
// `import.meta.hot.on('angular:component-update', ...)` listener.
|
|
375
|
+
// 2. A `/@ng/component?c=<id>` middleware serving recompiled
|
|
376
|
+
// `_UpdateMetadata` sources on demand.
|
|
377
|
+
// 3. `angular:component-update` broadcasts on `.html`/style edits so
|
|
378
|
+
// the runtime calls `ɵɵreplaceMetadata` on the live class — views
|
|
379
|
+
// recreate in-place with NO reboot and NO route navigation (the
|
|
380
|
+
// reboot path via `__reboot_ng_modules__` remains for `.ts` edits).
|
|
381
|
+
//
|
|
382
|
+
// Load-bearing interactions:
|
|
383
|
+
// - Analog's middleware matches `req.url.includes('/@ng/component')`
|
|
384
|
+
// (substring), so the `/ns/m/`-prefixed device fetch still hits it.
|
|
385
|
+
// - The device client (`hmr/client/protocol-dispatch.ts`) forwards
|
|
386
|
+
// `{ type: 'custom', event, data }` to `import.meta.hot.on`
|
|
387
|
+
// listeners and short-circuits before the reboot path for
|
|
388
|
+
// `angular:component-update`.
|
|
389
|
+
// - `hmr/server/websocket.ts` skips its own `ns:angular-update`
|
|
390
|
+
// broadcast for `.html`/component-style edits to avoid double-fire.
|
|
391
|
+
// - Rollback to reboot-only: set `NS_VITE_ANGULAR_LIVE_RELOAD=0`.
|
|
392
|
+
liveReload: hmrAngularLiveReload,
|
|
393
|
+
// NativeScript can't consume `externalRuntimeStyles` (runtime-loaded
|
|
394
|
+
// `<hash>.css` URLs need a browser CSSOM/`<link>` pipeline), so keep
|
|
395
|
+
// component styles inlined in the metadata's `styles: [...]` array.
|
|
396
|
+
// Independent of `liveReload` — template HMR stays on. The option is
|
|
397
|
+
// honored by our patched Analog plugin (upstream PR pending) and is a
|
|
398
|
+
// no-op on stock releases; not yet in the published `PluginOptions`.
|
|
399
|
+
// @ts-expect-error -- pending upstream Analog type publish
|
|
400
|
+
externalRuntimeStyles: false,
|
|
401
|
+
tsconfig: tsConfig,
|
|
402
|
+
// Forward Angular-style file replacements (e.g. `environment.ts`
|
|
403
|
+
// → `environment.stg.ts`) directly into the Analog plugin so the
|
|
404
|
+
// Angular TypeScript host (which reads source files via its own
|
|
405
|
+
// CompilerHost, bypassing Vite's load chain) sees the swap. This
|
|
406
|
+
// is the same hook Angular CLI uses for `fileReplacements` in
|
|
407
|
+
// `angular.json` build configurations.
|
|
408
|
+
fileReplacements: opts.fileReplacements ?? [],
|
|
409
|
+
// Component-HMR id alignment. Angular's compiler embeds each
|
|
410
|
+
// component's HMR id relative to the TS compilation's base path —
|
|
411
|
+
// in an Nx monorepo that's the WORKSPACE root (tsconfig.base.json's
|
|
412
|
+
// baseUrl), not the app dir. Analog uses `workspaceRoot` both to
|
|
413
|
+
// build the `angular:component-update` broadcast id
|
|
414
|
+
// (`relative(workspaceRoot, file)`) and to resolve `/@ng/component?c=`
|
|
415
|
+
// fetches back to absolute paths (`resolve(workspaceRoot, id)`).
|
|
416
|
+
// Defaulting to `process.cwd()` (the app dir) makes the broadcast id
|
|
417
|
+
// `src/...` while every compiled listener guards on
|
|
418
|
+
// `apps/<app>/src/...` — `d.id === id` never matches, so template
|
|
419
|
+
// edits dispatch cleanly but visually apply nothing. Default to the
|
|
420
|
+
// monorepo root when one exists so all three id producers agree;
|
|
421
|
+
// standalone apps (no monorepo root) keep the cwd behavior.
|
|
422
|
+
workspaceRoot: opts.workspaceRoot ?? getMonorepoWorkspaceRoot(process.cwd()) ?? process.cwd(),
|
|
423
|
+
}),
|
|
424
|
+
// Post-phase linker to catch any declarations introduced after other transforms (including project code)
|
|
425
|
+
angularLinkerVitePluginPost(process.cwd()),
|
|
426
|
+
// Re-inject `/* @vite-ignore */` onto Angular's HMR initializer dynamic
|
|
427
|
+
// imports. Angular emits `import(/* @vite-ignore */ i0.ɵɵgetReplaceMetadataURL(...))`,
|
|
428
|
+
// but the annotation gets stripped in the post-Angular pipeline
|
|
429
|
+
// (empirically the linker's `compact: false` Babel pass) — Vite's static
|
|
430
|
+
// analyzer then rewrites the call through its runtime resolver, which
|
|
431
|
+
// throws `TypeError at ɵɵgetReplaceMetadataURL` on the iOS device.
|
|
432
|
+
// `enforce: 'post'` sees the file after every comment-stripping
|
|
433
|
+
// transform; `apply: 'serve'` because the initializer is `ngDevMode`-
|
|
434
|
+
// gated and never runs in production. Idempotent.
|
|
435
|
+
{
|
|
436
|
+
name: 'ns-angular-hmr-vite-ignore',
|
|
437
|
+
enforce: 'post',
|
|
438
|
+
apply: 'serve',
|
|
439
|
+
transform(code, id) {
|
|
440
|
+
if (!hmrAngularLiveReload)
|
|
441
|
+
return null;
|
|
442
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
443
|
+
if (!cleanId.endsWith('.ts') && !cleanId.endsWith('.mjs') && !cleanId.endsWith('.js'))
|
|
444
|
+
return null;
|
|
445
|
+
if (cleanId.includes('/node_modules/'))
|
|
446
|
+
return null;
|
|
447
|
+
const next = injectAngularHmrViteIgnore(code);
|
|
448
|
+
if (next === code)
|
|
449
|
+
return null;
|
|
450
|
+
return { code: next, map: null };
|
|
451
|
+
},
|
|
179
452
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
deps
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
453
|
+
// Enforce: fully disable dependency optimization during serve to avoid rxjs esm5 crawling and OOM
|
|
454
|
+
{
|
|
455
|
+
name: 'ns-disable-optimize-deps',
|
|
456
|
+
enforce: 'post',
|
|
457
|
+
apply: 'serve',
|
|
458
|
+
config(userConfig) {
|
|
459
|
+
const od = userConfig?.optimizeDeps || {};
|
|
460
|
+
const prevExclude = Array.isArray(od.exclude) ? od.exclude : [];
|
|
461
|
+
const exclude = new Set(prevExclude);
|
|
462
|
+
[...NS_OPTIMIZE_DEPS_EXCLUDE, 'rxjs'].forEach((x) => exclude.add(x));
|
|
463
|
+
return {
|
|
464
|
+
optimizeDeps: {
|
|
465
|
+
noDiscovery: true,
|
|
466
|
+
entries: [],
|
|
467
|
+
include: [],
|
|
468
|
+
exclude: Array.from(exclude),
|
|
469
|
+
rolldownOptions: {
|
|
470
|
+
...(od.rolldownOptions || {}),
|
|
471
|
+
plugins: [],
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
},
|
|
476
|
+
configResolved(resolved) {
|
|
477
|
+
const resolvedConfig = resolved;
|
|
478
|
+
const deps = (resolvedConfig.optimizeDeps || (resolvedConfig.optimizeDeps = {}));
|
|
479
|
+
deps.noDiscovery = true;
|
|
480
|
+
deps.entries = [];
|
|
481
|
+
deps.include = [];
|
|
482
|
+
const exclude = new Set(Array.isArray(deps.exclude) ? deps.exclude : []);
|
|
483
|
+
[...NS_OPTIMIZE_DEPS_EXCLUDE, 'rxjs'].forEach((x) => exclude.add(x));
|
|
484
|
+
deps.exclude = Array.from(exclude);
|
|
485
|
+
const rolldownOptions = (deps.rolldownOptions || (deps.rolldownOptions = {}));
|
|
486
|
+
rolldownOptions.plugins = [];
|
|
487
|
+
},
|
|
190
488
|
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
export const angularConfig = ({ mode }) => {
|
|
489
|
+
];
|
|
490
|
+
}
|
|
491
|
+
export const angularConfig = ({ mode, fileReplacements, workspaceRoot, }) => {
|
|
492
|
+
const useSingleBundleDevOutput = mode === 'development' && !hmrActive;
|
|
493
|
+
const plugins = createAngularPlugins({
|
|
494
|
+
// Vite build --watch with the legacy Analog compilation path can regress
|
|
495
|
+
// Angular app sources from Ivy output back to decorator emit on rebuild.
|
|
496
|
+
// Restrict the newer compilation API to NativeScript's development no-HMR
|
|
497
|
+
// flow, which is where the unstable rebuilds occur today.
|
|
498
|
+
useAngularCompilationAPI: useSingleBundleDevOutput,
|
|
499
|
+
fileReplacements,
|
|
500
|
+
workspaceRoot,
|
|
501
|
+
});
|
|
502
|
+
// Angular browser animations are never used in NativeScript; the stub alias below is unconditional.
|
|
194
503
|
const disableAnimations = true;
|
|
195
|
-
//process.env.NS_DISABLE_NG_ANIMATIONS === "1" ||
|
|
196
|
-
//process.env.NS_DISABLE_NG_ANIMATIONS === "true";
|
|
197
504
|
// Post-link emitted chunks to catch any remaining partial declarations that slipped through
|
|
198
505
|
// due to plugin order or external transforms.
|
|
506
|
+
const applyAngularChunkPostProcessing = (code, options = {}) => {
|
|
507
|
+
const codeWithInjectables = synthesizeMissingInjectableFactories(code, {
|
|
508
|
+
vendorInjectExport: options.vendorInjectExport,
|
|
509
|
+
});
|
|
510
|
+
const codeWithCtorParameters = synthesizeDecoratorCtorParameters(codeWithInjectables);
|
|
511
|
+
return inlineDecoratorComponentTemplates(codeWithCtorParameters, {
|
|
512
|
+
projectRoot: process.cwd(),
|
|
513
|
+
});
|
|
514
|
+
};
|
|
199
515
|
const postLinker = {
|
|
200
516
|
name: 'ns-angular-linker-post',
|
|
201
517
|
apply: 'build',
|
|
202
518
|
enforce: 'post',
|
|
203
519
|
async generateBundle(_options, bundle) {
|
|
520
|
+
function isNsAngularPolyfillsModule(id) {
|
|
521
|
+
return normalizeAngularWatchPath(id).includes('node_modules/@nativescript/angular/fesm2022/nativescript-angular-polyfills.mjs');
|
|
522
|
+
}
|
|
204
523
|
function isNsAngularPolyfillsChunk(chunk) {
|
|
205
524
|
if (!chunk || !chunk.modules)
|
|
206
525
|
return false;
|
|
207
|
-
return Object.keys(chunk.modules).some(
|
|
526
|
+
return Object.keys(chunk.modules).some(isNsAngularPolyfillsModule);
|
|
208
527
|
}
|
|
209
|
-
const { babel,
|
|
210
|
-
if (!babel || !
|
|
528
|
+
const { babel, createLinker } = await getAngularLinkerFactory(process.cwd());
|
|
529
|
+
if (!babel || !createLinker)
|
|
211
530
|
return;
|
|
212
531
|
const strict = process.env.NS_STRICT_NG_LINK === '1' || process.env.NS_STRICT_NG_LINK === 'true';
|
|
213
532
|
const enforceStrict = process.env.NS_STRICT_NG_LINK_ENFORCE === '1' || process.env.NS_STRICT_NG_LINK_ENFORCE === 'true';
|
|
214
533
|
const debug = process.env.VITE_DEBUG_LOGS === '1' || process.env.VITE_DEBUG_LOGS === 'true';
|
|
215
534
|
const unlinked = [];
|
|
535
|
+
const vendorInjectExport = (() => {
|
|
536
|
+
const vendorChunk = Object.entries(bundle).find(([name, value]) => value && value.type === 'chunk' && /(^|\/)vendor\.mjs$/.test(name));
|
|
537
|
+
const vendorCode = vendorChunk ? vendorChunk[1].code : undefined;
|
|
538
|
+
return vendorCode?.match(/\binject as ([A-Za-z_$][\w$]*)/)?.[1];
|
|
539
|
+
})();
|
|
216
540
|
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
217
541
|
if (!fileName.endsWith('.mjs') && !fileName.endsWith('.js'))
|
|
218
542
|
continue;
|
|
@@ -222,44 +546,41 @@ export const angularConfig = ({ mode }) => {
|
|
|
222
546
|
continue;
|
|
223
547
|
const isNsPolyfills = isNsAngularPolyfillsChunk(chunk);
|
|
224
548
|
try {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
babelrc: false,
|
|
229
|
-
sourceMaps: false,
|
|
230
|
-
compact: false,
|
|
231
|
-
plugins: [linkerPlugin],
|
|
232
|
-
});
|
|
233
|
-
const finalCode = res?.code && res.code !== code ? res.code : code;
|
|
549
|
+
// Fresh plugin per chunk — avoids stale linker state across watch-mode rebuilds.
|
|
550
|
+
const linked = await runAngularLinker(code, { filename: fileName, projectRoot: process.cwd(), freshPlugin: true });
|
|
551
|
+
const finalCode = applyAngularChunkPostProcessing(linked ?? code, { vendorInjectExport });
|
|
234
552
|
if (finalCode !== code) {
|
|
235
553
|
chunk.code = finalCode;
|
|
554
|
+
recordLinkerHit('post');
|
|
236
555
|
if (debug) {
|
|
237
|
-
|
|
238
|
-
console.log('[ns-angular-linker][post] linked', fileName, isNsPolyfills ? '(polyfills)' : '');
|
|
239
|
-
}
|
|
240
|
-
catch { }
|
|
556
|
+
console.log('[ns-angular-linker][post] linked', fileName, isNsPolyfills ? '(polyfills)' : '');
|
|
241
557
|
}
|
|
242
558
|
}
|
|
243
559
|
if (strict && !isNsPolyfills && containsRealNgDeclare(finalCode)) {
|
|
244
560
|
unlinked.push(fileName);
|
|
245
561
|
}
|
|
246
562
|
}
|
|
247
|
-
catch {
|
|
563
|
+
catch (e) {
|
|
564
|
+
console.warn(`[ns-angular-linker][post] linking FAILED for ${fileName}:`, e?.message || e);
|
|
248
565
|
if (strict)
|
|
249
566
|
unlinked.push(fileName);
|
|
250
567
|
}
|
|
251
568
|
}
|
|
252
569
|
}
|
|
570
|
+
// Evidence for pruning the stacked linker layers: print which of the
|
|
571
|
+
// five layers actually linked anything this build. A layer that
|
|
572
|
+
// reports 0 across the full flavor matrix is a candidate for removal.
|
|
573
|
+
reportLinkerLayerStats();
|
|
253
574
|
if (strict && unlinked.length) {
|
|
254
575
|
const details = [];
|
|
255
576
|
for (const fname of unlinked) {
|
|
256
577
|
const chunk = bundle[fname];
|
|
257
578
|
const modIds = chunk?.modules
|
|
258
579
|
? Object.keys(chunk.modules)
|
|
259
|
-
.filter((m) => /node_modules\/(?:@angular|@nativescript\/angular)\//.test(m))
|
|
580
|
+
.filter((m) => /node_modules\/(?:@angular|@nativescript\/angular)\//.test(normalizeAngularWatchPath(m)))
|
|
260
581
|
.slice(0, 8)
|
|
261
582
|
: [];
|
|
262
|
-
const isOnlyPolyfills = modIds.length > 0 && modIds.every(
|
|
583
|
+
const isOnlyPolyfills = modIds.length > 0 && modIds.every(isNsAngularPolyfillsModule);
|
|
263
584
|
if (isOnlyPolyfills)
|
|
264
585
|
continue;
|
|
265
586
|
let snippet = '';
|
|
@@ -282,89 +603,79 @@ export const angularConfig = ({ mode }) => {
|
|
|
282
603
|
throw new Error(message);
|
|
283
604
|
}
|
|
284
605
|
else {
|
|
285
|
-
|
|
286
|
-
console.warn(`[ns-angular-linker-post] ${message}`);
|
|
287
|
-
}
|
|
288
|
-
catch { }
|
|
606
|
+
console.warn(`[ns-angular-linker-post] ${message}`);
|
|
289
607
|
}
|
|
290
608
|
}
|
|
291
609
|
},
|
|
292
610
|
};
|
|
293
|
-
// Safety net: transform each rendered chunk to link any remaining ɵɵngDeclare* call sites
|
|
611
|
+
// Safety net: transform each rendered chunk to link any remaining ɵɵngDeclare* call sites.
|
|
612
|
+
// IMPORTANT: create a FRESH linker plugin per invocation — the shared instance may have
|
|
613
|
+
// stale internal state from a prior build cycle, causing silent failures in watch-mode rebuilds.
|
|
294
614
|
const renderChunkLinker = {
|
|
295
615
|
name: 'ns-angular-linker-render',
|
|
296
616
|
apply: 'build',
|
|
297
617
|
enforce: 'post',
|
|
298
618
|
async renderChunk(code, chunk) {
|
|
619
|
+
if (!code)
|
|
620
|
+
return null;
|
|
621
|
+
const filename = chunk.fileName || chunk.name || 'chunk.mjs';
|
|
622
|
+
const debug = process.env.VITE_DEBUG_LOGS === '1' || process.env.VITE_DEBUG_LOGS === 'true';
|
|
299
623
|
try {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const result = await babel.transformAsync(input, {
|
|
311
|
-
filename,
|
|
312
|
-
configFile: false,
|
|
313
|
-
babelrc: false,
|
|
314
|
-
sourceMaps: false,
|
|
315
|
-
compact: false,
|
|
316
|
-
plugins: [linkerPlugin],
|
|
317
|
-
});
|
|
318
|
-
return result?.code ?? input;
|
|
319
|
-
};
|
|
320
|
-
let transformed = await runLink(code);
|
|
321
|
-
if (containsRealNgDeclare(transformed)) {
|
|
322
|
-
transformed = await runLink(transformed);
|
|
624
|
+
let transformed = code;
|
|
625
|
+
if (containsRealNgDeclare(code)) {
|
|
626
|
+
const { babel, createLinker } = await getAngularLinkerFactory(process.cwd());
|
|
627
|
+
if (!babel || !createLinker)
|
|
628
|
+
return null;
|
|
629
|
+
// Fresh plugin per pass — avoids stale linker state across watch-mode rebuilds.
|
|
630
|
+
transformed = (await runAngularLinker(code, { filename, projectRoot: process.cwd(), freshPlugin: true })) ?? code;
|
|
631
|
+
if (containsRealNgDeclare(transformed)) {
|
|
632
|
+
transformed = (await runAngularLinker(transformed, { filename, projectRoot: process.cwd(), freshPlugin: true })) ?? transformed;
|
|
633
|
+
}
|
|
323
634
|
}
|
|
635
|
+
transformed = applyAngularChunkPostProcessing(transformed);
|
|
324
636
|
if (transformed !== code) {
|
|
637
|
+
recordLinkerHit('render');
|
|
325
638
|
if (debug) {
|
|
326
|
-
|
|
327
|
-
console.log('[ns-angular-linker][render] linked', filename);
|
|
328
|
-
}
|
|
329
|
-
catch { }
|
|
639
|
+
console.log('[ns-angular-linker][render] linked', filename);
|
|
330
640
|
}
|
|
331
641
|
return { code: transformed, map: null };
|
|
332
642
|
}
|
|
333
643
|
}
|
|
334
|
-
catch {
|
|
644
|
+
catch (e) {
|
|
645
|
+
console.warn(`[ns-angular-linker][render] linking FAILED for ${filename}:`, e?.message || e);
|
|
646
|
+
}
|
|
335
647
|
return null;
|
|
336
648
|
},
|
|
337
649
|
};
|
|
338
650
|
const enableRollupLinker = process.env.NS_ENABLE_ROLLUP_LINKER === '1' || process.env.NS_ENABLE_ROLLUP_LINKER === 'true' || hmrActive;
|
|
339
|
-
|
|
651
|
+
// Single merged alias array — a second `resolve` key from a conditional
|
|
652
|
+
// spread would silently clobber the fesm2022 and RxJS aliases.
|
|
653
|
+
const angularAliases = [
|
|
654
|
+
// Map Angular deep ESM paths to bare package ids
|
|
655
|
+
{ find: /^@angular\/([^/]+)\/fesm2022\/.*\.mjs$/, replacement: '@angular/$1' },
|
|
656
|
+
{ find: /^@nativescript\/angular\/fesm2022\/.*\.mjs$/, replacement: '@nativescript/angular' },
|
|
657
|
+
// RxJS esm5 → esm redirects removed: Vite 8 enforces the rxjs `exports` field,
|
|
658
|
+
// blocking deep path aliases. Instead, the `es2015` resolve condition is added
|
|
659
|
+
// below so rxjs resolves to its modern ESM builds via the exports map.
|
|
660
|
+
];
|
|
661
|
+
if (disableAnimations) {
|
|
662
|
+
angularAliases.push({
|
|
663
|
+
find: /^@angular\/animations(\/.+)?$/, // match subpaths too
|
|
664
|
+
replacement: resolveRelativeToImportMeta(import.meta.url, '../shims/angular-animations-stub.js'),
|
|
665
|
+
}, {
|
|
666
|
+
find: /^@angular\/platform-browser\/animations(\/.+)?$/,
|
|
667
|
+
replacement: resolveRelativeToImportMeta(import.meta.url, '../shims/angular-animations-stub.js'),
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
const config = mergeConfig(baseConfig({ mode, flavor: 'angular' }), {
|
|
340
671
|
plugins: [...plugins, ...(enableRollupLinker ? [angularRollupLinker(process.cwd())] : []), renderChunkLinker, postLinker],
|
|
341
|
-
// Always alias fesm2022 deep imports to package root so vendor bridge can externalize properly
|
|
342
672
|
resolve: {
|
|
343
|
-
alias:
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
{ find: /^rxjs\/dist\/esm5\/(.*)$/, replacement: 'rxjs/dist/esm2015/$1' },
|
|
349
|
-
{ find: /^rxjs\/operators$/, replacement: 'rxjs/dist/esm2015/operators/index.js' },
|
|
350
|
-
{ find: /^rxjs$/, replacement: 'rxjs/dist/esm2015/index.js' },
|
|
351
|
-
// Existing optional animations shims
|
|
352
|
-
],
|
|
673
|
+
alias: angularAliases,
|
|
674
|
+
// Add 'es2015' condition so RxJS resolves to dist/esm (modern ESM) rather
|
|
675
|
+
// than dist/esm5 via the 'default' condition. This avoids the esm5 module
|
|
676
|
+
// explosion and OOM while respecting the package's exports field in Vite 8.
|
|
677
|
+
conditions: ['es2015'],
|
|
353
678
|
},
|
|
354
|
-
...(disableAnimations && {
|
|
355
|
-
resolve: {
|
|
356
|
-
alias: [
|
|
357
|
-
{
|
|
358
|
-
find: /^@angular\/animations(\/.+)?$/, // match subpaths too
|
|
359
|
-
replacement: new URL('../shims/angular-animations-stub.js', import.meta.url).pathname,
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
find: /^@angular\/platform-browser\/animations(\/.+)?$/,
|
|
363
|
-
replacement: new URL('../shims/angular-animations-stub.js', import.meta.url).pathname,
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
},
|
|
367
|
-
}),
|
|
368
679
|
// Disable dependency optimization entirely for NativeScript Angular HMR.
|
|
369
680
|
// Vite 5.1+: use noDiscovery with an empty include list (disabled was removed).
|
|
370
681
|
// The HTTP loader + vendor bridge manage dependencies; pre-bundling can OOM.
|
|
@@ -376,5 +687,19 @@ export const angularConfig = ({ mode }) => {
|
|
|
376
687
|
rolldownOptions: { plugins: [] },
|
|
377
688
|
},
|
|
378
689
|
});
|
|
690
|
+
if (useSingleBundleDevOutput) {
|
|
691
|
+
const build = (config.build ?? (config.build = {}));
|
|
692
|
+
const rolldownOptions = (build.rolldownOptions ?? (build.rolldownOptions = {}));
|
|
693
|
+
const outputConfigs = Array.isArray(rolldownOptions.output) ? rolldownOptions.output : [rolldownOptions.output ?? {}];
|
|
694
|
+
for (const output of outputConfigs) {
|
|
695
|
+
// Angular non-HMR reloads are more reliable when rebuilds keep a single boot bundle.
|
|
696
|
+
// This avoids watch-time chunk alias/name drift that can leave the native app reloading into stale split points.
|
|
697
|
+
delete output.manualChunks;
|
|
698
|
+
delete output.chunkFileNames;
|
|
699
|
+
output.codeSplitting = false;
|
|
700
|
+
}
|
|
701
|
+
rolldownOptions.output = Array.isArray(rolldownOptions.output) ? outputConfigs : outputConfigs[0];
|
|
702
|
+
}
|
|
703
|
+
return config;
|
|
379
704
|
};
|
|
380
705
|
//# sourceMappingURL=angular.js.map
|