@nativescript/vite 8.0.0-alpha.7 → 8.0.0-alpha.71
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 +54 -14
- package/bin/cli.cjs +8 -14
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +293 -172
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +177 -110
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +14 -93
- package/configuration/javascript.js.map +1 -1
- package/configuration/react.js +41 -73
- package/configuration/react.js.map +1 -1
- package/configuration/solid.js +51 -6
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +12 -93
- 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/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 +4 -1
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/external-configs.d.ts +10 -12
- package/helpers/external-configs.js +58 -35
- 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 +101 -33
- package/helpers/global-defines.js +187 -64
- 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/init.js +6 -20
- package/helpers/init.js.map +1 -1
- package/helpers/logging.js +29 -1
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +4 -1
- package/helpers/main-entry.js +366 -47
- 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 +37 -7
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
- package/helpers/nativeclass-transformer-plugin.js +163 -15
- 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 +26 -3
- package/helpers/ns-core-url.js +66 -8
- package/helpers/ns-core-url.js.map +1 -1
- 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 +324 -13
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +2 -1
- package/hmr/client/css-handler.js +63 -32
- 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 +0 -14
- package/hmr/client/hmr-pending-overlay.js +2 -11
- package/hmr/client/hmr-pending-overlay.js.map +1 -1
- 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 +70 -1970
- 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 +83 -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 +9 -1
- package/hmr/client/utils.js +117 -97
- 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 +2 -1
- package/hmr/entry-runtime.js +282 -71
- 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/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
- 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/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
- 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.js +88 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
- 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 +0 -1
- package/hmr/frameworks/angular/client/index.js +459 -223
- 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 +1 -4
- 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 +677 -13
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +28 -11
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.js +191 -105
- 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 +40 -14
- 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 +109 -14
- 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.js +20 -5
- 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 +86 -7
- package/hmr/server/core-sanitize.js +164 -39
- 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 +51 -19
- package/hmr/server/import-map.js +136 -66
- package/hmr/server/import-map.js.map +1 -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.js +1 -1
- package/hmr/server/ns-core-cjs-shape.js.map +1 -1
- 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 +1 -1
- package/hmr/server/perf-instrumentation.js +3 -1
- package/hmr/server/perf-instrumentation.js.map +1 -1
- 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.js +8 -1
- package/hmr/server/runtime-graph-filter.js.map +1 -1
- 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.js +1 -2
- package/hmr/server/shared-transform-request.js.map +1 -1
- 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 +1 -0
- package/hmr/server/vite-plugin.js +227 -53
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +51 -4
- package/hmr/server/websocket-core-bridge.js +62 -49
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- 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-hmr-pending.d.ts +2 -16
- package/hmr/server/websocket-hmr-pending.js +0 -22
- package/hmr/server/websocket-hmr-pending.js.map +1 -1
- 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 +15 -0
- package/hmr/server/websocket-module-bindings.js +38 -5
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +66 -7
- package/hmr/server/websocket-module-specifiers.js +219 -49
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- 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 +164 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +19 -3
- package/hmr/server/websocket-ns-m-paths.js +98 -75
- package/hmr/server/websocket-ns-m-paths.js.map +1 -1
- package/hmr/server/websocket-ns-m-request.d.ts +13 -2
- package/hmr/server/websocket-ns-m-request.js +20 -11
- package/hmr/server/websocket-ns-m-request.js.map +1 -1
- 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 +57 -4
- package/hmr/server/websocket-served-module-helpers.js +462 -141
- package/hmr/server/websocket-served-module-helpers.js.map +1 -1
- package/hmr/server/websocket-txn.js +6 -9
- package/hmr/server/websocket-txn.js.map +1 -1
- package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
- package/hmr/server/websocket-vendor-unifier.js +4 -9
- package/hmr/server/websocket-vendor-unifier.js.map +1 -1
- package/hmr/server/websocket.d.ts +7 -40
- package/hmr/server/websocket.js +653 -6734
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +106 -0
- package/hmr/shared/ns-globals.js +29 -0
- package/hmr/shared/ns-globals.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 +1 -1
- package/hmr/shared/runtime/boot-timeline.js +8 -19
- package/hmr/shared/runtime/boot-timeline.js.map +1 -1
- package/hmr/shared/runtime/browser-runtime-contract.d.ts +43 -24
- package/hmr/shared/runtime/browser-runtime-contract.js +21 -9
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
- 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 +23 -69
- package/hmr/shared/runtime/dev-overlay.js +67 -1023
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- 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.js +4 -6
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- 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/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.js +401 -206
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +203 -58
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
- 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/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 -7
- package/hmr/shared/vendor/manifest.js +180 -826
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/registry.d.ts +2 -0
- package/hmr/shared/vendor/registry.js +14 -0
- 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 +65 -13
- package/runtime/core-aliases-early.js +28 -57
- 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/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -194
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -11
- package/helpers/angular/shared-linker.js +0 -75
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
- package/helpers/angular/synthesize-injectable-factories.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/server/websocket-angular-entry.js.map +0 -1
- package/hmr/server/websocket-angular-hot-update.js.map +0 -1
- package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
- package/hmr/server/websocket-ns-m-finalize.js +0 -88
- package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
- package/hmr/server/websocket-runtime-compat.d.ts +0 -19
- package/hmr/server/websocket-runtime-compat.js +0 -287
- package/hmr/server/websocket-runtime-compat.js.map +0 -1
- package/hmr/server/websocket-vue-sfc.d.ts +0 -27
- package/hmr/server/websocket-vue-sfc.js +0 -1114
- package/hmr/server/websocket-vue-sfc.js.map +0 -1
- package/hmr/shared/runtime/http-only-boot.d.ts +0 -2
- package/hmr/shared/runtime/http-only-boot.js +0 -171
- 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/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
- /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
package/configuration/angular.js
CHANGED
|
@@ -1,143 +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 { synthesizeMissingInjectableFactories } from '../
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
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';
|
|
12
14
|
import { baseConfig } from './base.js';
|
|
13
15
|
import { getCliFlags } from '../helpers/cli-flags.js';
|
|
16
|
+
import { getMonorepoWorkspaceRoot } from '../helpers/project.js';
|
|
14
17
|
import { resolveRelativeToImportMeta } from '../helpers/import-meta-path.js';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (_cachedLinkerFactory)
|
|
20
|
-
return _cachedLinkerFactory;
|
|
21
|
-
const req = createRequire(process.cwd() + '/package.json');
|
|
22
|
-
try {
|
|
23
|
-
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
24
|
-
const linkerMod = await import(linkerPath);
|
|
25
|
-
_cachedLinkerFactory = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
try {
|
|
29
|
-
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
30
|
-
_cachedLinkerFactory = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
31
|
-
}
|
|
32
|
-
catch { }
|
|
33
|
-
}
|
|
34
|
-
return _cachedLinkerFactory;
|
|
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;
|
|
35
22
|
}
|
|
36
23
|
// Rollup-level linker to guarantee Angular libraries are linked when included in the bundle graph.
|
|
37
24
|
function angularRollupLinker(projectRoot) {
|
|
38
|
-
let babel = null;
|
|
39
|
-
let createLinker = null;
|
|
40
|
-
let angularFileSystem = null;
|
|
41
25
|
const FILTER = /node_modules\/(?:@angular|@nativescript\/angular)\/.*\.[mc]?js$/;
|
|
42
|
-
|
|
43
|
-
if (babel && createLinker)
|
|
44
|
-
return;
|
|
45
|
-
try {
|
|
46
|
-
const req = createRequire((projectRoot ? projectRoot + '/package.json' : import.meta.url));
|
|
47
|
-
const babelPath = req.resolve('@babel/core');
|
|
48
|
-
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
49
|
-
babel = await import(babelPath);
|
|
50
|
-
const linkerMod = await import(linkerPath);
|
|
51
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin;
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
try {
|
|
55
|
-
babel = await import('@babel/core');
|
|
56
|
-
}
|
|
57
|
-
catch { }
|
|
58
|
-
try {
|
|
59
|
-
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
60
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin;
|
|
61
|
-
}
|
|
62
|
-
catch { }
|
|
63
|
-
}
|
|
64
|
-
if (!angularFileSystem) {
|
|
65
|
-
angularFileSystem = await resolveAngularFileSystem(projectRoot);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
26
|
+
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
68
27
|
return {
|
|
69
28
|
name: 'ns-angular-linker-rollup',
|
|
70
29
|
enforce: 'pre',
|
|
71
30
|
apply: 'build',
|
|
72
31
|
async load(id) {
|
|
73
|
-
const
|
|
74
|
-
const cleanId = id.split('?', 1)[0];
|
|
32
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
75
33
|
if (!FILTER.test(cleanId))
|
|
76
34
|
return null;
|
|
77
35
|
try {
|
|
78
|
-
await ensureDeps();
|
|
79
|
-
if (!babel || !createLinker)
|
|
80
|
-
return null;
|
|
81
36
|
const fs = await import('node:fs/promises');
|
|
82
37
|
const code = await fs.readFile(cleanId, 'utf8');
|
|
83
38
|
const forceLink = cleanId.includes('/node_modules/@nativescript/angular/') && cleanId.includes('polyfills');
|
|
84
39
|
if (!code)
|
|
85
40
|
return null;
|
|
86
|
-
if (!forceLink &&
|
|
41
|
+
if (!forceLink && !hasNgDeclarePartial(code))
|
|
87
42
|
return null;
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
const result = await babel.transformAsync(code, {
|
|
96
|
-
filename: cleanId,
|
|
97
|
-
configFile: false,
|
|
98
|
-
babelrc: false,
|
|
99
|
-
sourceMaps: false,
|
|
100
|
-
compact: false,
|
|
101
|
-
plugins: [plugin],
|
|
102
|
-
});
|
|
103
|
-
if (result?.code && result.code !== code) {
|
|
104
|
-
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 };
|
|
105
49
|
}
|
|
106
50
|
}
|
|
107
51
|
catch { }
|
|
108
52
|
return null;
|
|
109
53
|
},
|
|
110
54
|
async transform(code, id) {
|
|
111
|
-
const
|
|
112
|
-
const cleanId = id.split('?', 1)[0];
|
|
55
|
+
const cleanId = normalizeAngularWatchPath(id);
|
|
113
56
|
if (!FILTER.test(cleanId))
|
|
114
57
|
return null;
|
|
115
58
|
const forceLink = cleanId.includes('/node_modules/@nativescript/angular/') && cleanId.includes('polyfills');
|
|
116
59
|
if (!code)
|
|
117
60
|
return null;
|
|
118
|
-
if (!forceLink &&
|
|
119
|
-
return null;
|
|
120
|
-
await ensureDeps();
|
|
121
|
-
if (!babel || !createLinker)
|
|
61
|
+
if (!forceLink && !hasNgDeclarePartial(code))
|
|
122
62
|
return null;
|
|
123
63
|
try {
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
const result = await babel.transformAsync(code, {
|
|
132
|
-
filename: cleanId,
|
|
133
|
-
configFile: false,
|
|
134
|
-
babelrc: false,
|
|
135
|
-
sourceMaps: false,
|
|
136
|
-
compact: false,
|
|
137
|
-
plugins: [plugin],
|
|
138
|
-
});
|
|
139
|
-
if (result?.code && result.code !== code) {
|
|
140
|
-
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 };
|
|
141
70
|
}
|
|
142
71
|
}
|
|
143
72
|
catch { }
|
|
@@ -148,6 +77,24 @@ function angularRollupLinker(projectRoot) {
|
|
|
148
77
|
const cliFlags = getCliFlags();
|
|
149
78
|
const isDevEnv = process.env.NODE_ENV !== 'production';
|
|
150
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;
|
|
151
98
|
const projectRoot = process.cwd();
|
|
152
99
|
const tsConfigAppPath = path.resolve(projectRoot, 'tsconfig.app.json');
|
|
153
100
|
const tsConfigPath = path.resolve(projectRoot, 'tsconfig.json');
|
|
@@ -193,15 +140,24 @@ function extractComponentAssetPaths(code, componentId) {
|
|
|
193
140
|
const componentPath = normalizeAngularWatchPath(componentId);
|
|
194
141
|
const assetPaths = new Set();
|
|
195
142
|
const resolveAssetPath = (assetPath) => normalizeAngularWatchPath(path.resolve(path.dirname(componentPath), assetPath));
|
|
196
|
-
|
|
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))['"]/);
|
|
197
153
|
if (templateUrlMatch) {
|
|
198
154
|
assetPaths.add(resolveAssetPath(templateUrlMatch[1]));
|
|
199
155
|
}
|
|
200
|
-
const styleUrlMatch =
|
|
156
|
+
const styleUrlMatch = scanCode.match(/styleUrl\s*:\s*['"](.+?\.(?:css|less|sass|scss))['"]/);
|
|
201
157
|
if (styleUrlMatch) {
|
|
202
158
|
assetPaths.add(resolveAssetPath(styleUrlMatch[1]));
|
|
203
159
|
}
|
|
204
|
-
const styleUrlsMatch =
|
|
160
|
+
const styleUrlsMatch = scanCode.match(/styleUrls\s*:\s*\[([\s\S]*?)\]/m);
|
|
205
161
|
if (styleUrlsMatch) {
|
|
206
162
|
for (const match of styleUrlsMatch[1].matchAll(/['"](.+?\.(?:css|less|sass|scss))['"]/g)) {
|
|
207
163
|
assetPaths.add(resolveAssetPath(match[1]));
|
|
@@ -210,9 +166,18 @@ function extractComponentAssetPaths(code, componentId) {
|
|
|
210
166
|
return Array.from(assetPaths);
|
|
211
167
|
}
|
|
212
168
|
function createAngularPlugins(opts) {
|
|
169
|
+
const verbose = resolveVerboseFlag();
|
|
213
170
|
const assetToComponents = new Map();
|
|
214
171
|
const componentToAssets = new Map();
|
|
215
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();
|
|
216
181
|
const untrackComponentAssets = (componentPath) => {
|
|
217
182
|
const previousAssets = componentToAssets.get(componentPath);
|
|
218
183
|
if (!previousAssets)
|
|
@@ -240,7 +205,92 @@ function createAngularPlugins(opts) {
|
|
|
240
205
|
assetToComponents.set(assetPath, components);
|
|
241
206
|
}
|
|
242
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
|
+
};
|
|
243
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
|
+
},
|
|
265
|
+
},
|
|
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
|
+
},
|
|
244
294
|
// Allow external html template changes to trigger hot reload: Make .ts files depend on their .html templates
|
|
245
295
|
{
|
|
246
296
|
name: 'angular-template-deps',
|
|
@@ -255,6 +305,11 @@ function createAngularPlugins(opts) {
|
|
|
255
305
|
for (const assetPath of assetPaths) {
|
|
256
306
|
this.addWatchFile(assetPath);
|
|
257
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
|
+
}
|
|
258
313
|
return null;
|
|
259
314
|
},
|
|
260
315
|
watchChange(id) {
|
|
@@ -269,12 +324,27 @@ function createAngularPlugins(opts) {
|
|
|
269
324
|
for (const componentPath of components) {
|
|
270
325
|
pendingComponentInvalidations.add(componentPath);
|
|
271
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
|
+
}
|
|
272
330
|
return;
|
|
273
331
|
}
|
|
274
332
|
if (/\.(html|htm)$/i.test(changedPath)) {
|
|
275
333
|
const componentPath = changedPath.replace(/\.(html|htm)$/i, '.ts');
|
|
276
|
-
|
|
277
|
-
|
|
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}`);
|
|
278
348
|
}
|
|
279
349
|
}
|
|
280
350
|
},
|
|
@@ -283,23 +353,103 @@ function createAngularPlugins(opts) {
|
|
|
283
353
|
if (!pendingComponentInvalidations.has(componentPath))
|
|
284
354
|
return null;
|
|
285
355
|
pendingComponentInvalidations.delete(componentPath);
|
|
356
|
+
if (verbose) {
|
|
357
|
+
console.info(`[ns-hmr][angular-template-deps] shouldTransformCachedModule → re-transform componentKey=${componentPath}`);
|
|
358
|
+
}
|
|
286
359
|
return true;
|
|
287
360
|
},
|
|
288
361
|
},
|
|
289
362
|
// Transform Angular partial declarations in node_modules to avoid runtime JIT
|
|
290
363
|
// Pass the project root so linker deps resolve from the app, not the plugin package.
|
|
291
364
|
angularLinkerVitePlugin(process.cwd()),
|
|
292
|
-
//
|
|
293
|
-
//
|
|
365
|
+
// A Rollup-phase linker safety net (angularRollupLinker) is additionally
|
|
366
|
+
// appended for HMR sessions — see `enableRollupLinker` below.
|
|
294
367
|
...angular({
|
|
295
368
|
experimental: {
|
|
296
369
|
useAngularCompilationAPI: opts.useAngularCompilationAPI,
|
|
297
370
|
},
|
|
298
|
-
liveReload
|
|
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,
|
|
299
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(),
|
|
300
423
|
}),
|
|
301
424
|
// Post-phase linker to catch any declarations introduced after other transforms (including project code)
|
|
302
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
|
+
},
|
|
452
|
+
},
|
|
303
453
|
// Enforce: fully disable dependency optimization during serve to avoid rxjs esm5 crawling and OOM
|
|
304
454
|
{
|
|
305
455
|
name: 'ns-disable-optimize-deps',
|
|
@@ -309,7 +459,7 @@ function createAngularPlugins(opts) {
|
|
|
309
459
|
const od = userConfig?.optimizeDeps || {};
|
|
310
460
|
const prevExclude = Array.isArray(od.exclude) ? od.exclude : [];
|
|
311
461
|
const exclude = new Set(prevExclude);
|
|
312
|
-
[
|
|
462
|
+
[...NS_OPTIMIZE_DEPS_EXCLUDE, 'rxjs'].forEach((x) => exclude.add(x));
|
|
313
463
|
return {
|
|
314
464
|
optimizeDeps: {
|
|
315
465
|
noDiscovery: true,
|
|
@@ -330,7 +480,7 @@ function createAngularPlugins(opts) {
|
|
|
330
480
|
deps.entries = [];
|
|
331
481
|
deps.include = [];
|
|
332
482
|
const exclude = new Set(Array.isArray(deps.exclude) ? deps.exclude : []);
|
|
333
|
-
[
|
|
483
|
+
[...NS_OPTIMIZE_DEPS_EXCLUDE, 'rxjs'].forEach((x) => exclude.add(x));
|
|
334
484
|
deps.exclude = Array.from(exclude);
|
|
335
485
|
const rolldownOptions = (deps.rolldownOptions || (deps.rolldownOptions = {}));
|
|
336
486
|
rolldownOptions.plugins = [];
|
|
@@ -338,7 +488,7 @@ function createAngularPlugins(opts) {
|
|
|
338
488
|
},
|
|
339
489
|
];
|
|
340
490
|
}
|
|
341
|
-
export const angularConfig = ({ mode }) => {
|
|
491
|
+
export const angularConfig = ({ mode, fileReplacements, workspaceRoot, }) => {
|
|
342
492
|
const useSingleBundleDevOutput = mode === 'development' && !hmrActive;
|
|
343
493
|
const plugins = createAngularPlugins({
|
|
344
494
|
// Vite build --watch with the legacy Analog compilation path can regress
|
|
@@ -346,10 +496,11 @@ export const angularConfig = ({ mode }) => {
|
|
|
346
496
|
// Restrict the newer compilation API to NativeScript's development no-HMR
|
|
347
497
|
// flow, which is where the unstable rebuilds occur today.
|
|
348
498
|
useAngularCompilationAPI: useSingleBundleDevOutput,
|
|
499
|
+
fileReplacements,
|
|
500
|
+
workspaceRoot,
|
|
349
501
|
});
|
|
502
|
+
// Angular browser animations are never used in NativeScript; the stub alias below is unconditional.
|
|
350
503
|
const disableAnimations = true;
|
|
351
|
-
//process.env.NS_DISABLE_NG_ANIMATIONS === "1" ||
|
|
352
|
-
//process.env.NS_DISABLE_NG_ANIMATIONS === "true";
|
|
353
504
|
// Post-link emitted chunks to catch any remaining partial declarations that slipped through
|
|
354
505
|
// due to plugin order or external transforms.
|
|
355
506
|
const applyAngularChunkPostProcessing = (code, options = {}) => {
|
|
@@ -366,17 +517,16 @@ export const angularConfig = ({ mode }) => {
|
|
|
366
517
|
apply: 'build',
|
|
367
518
|
enforce: 'post',
|
|
368
519
|
async generateBundle(_options, bundle) {
|
|
520
|
+
function isNsAngularPolyfillsModule(id) {
|
|
521
|
+
return normalizeAngularWatchPath(id).includes('node_modules/@nativescript/angular/fesm2022/nativescript-angular-polyfills.mjs');
|
|
522
|
+
}
|
|
369
523
|
function isNsAngularPolyfillsChunk(chunk) {
|
|
370
524
|
if (!chunk || !chunk.modules)
|
|
371
525
|
return false;
|
|
372
|
-
return Object.keys(chunk.modules).some(
|
|
526
|
+
return Object.keys(chunk.modules).some(isNsAngularPolyfillsModule);
|
|
373
527
|
}
|
|
374
|
-
const { babel } = await
|
|
375
|
-
if (!babel)
|
|
376
|
-
return;
|
|
377
|
-
const fileSystem = await resolveAngularFileSystem(process.cwd());
|
|
378
|
-
const linkerFactory = await importLinkerFactory();
|
|
379
|
-
if (!linkerFactory)
|
|
528
|
+
const { babel, createLinker } = await getAngularLinkerFactory(process.cwd());
|
|
529
|
+
if (!babel || !createLinker)
|
|
380
530
|
return;
|
|
381
531
|
const strict = process.env.NS_STRICT_NG_LINK === '1' || process.env.NS_STRICT_NG_LINK === 'true';
|
|
382
532
|
const enforceStrict = process.env.NS_STRICT_NG_LINK_ENFORCE === '1' || process.env.NS_STRICT_NG_LINK_ENFORCE === 'true';
|
|
@@ -396,26 +546,14 @@ export const angularConfig = ({ mode }) => {
|
|
|
396
546
|
continue;
|
|
397
547
|
const isNsPolyfills = isNsAngularPolyfillsChunk(chunk);
|
|
398
548
|
try {
|
|
399
|
-
//
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
const res = await babel.transformAsync(code, {
|
|
403
|
-
filename: fileName,
|
|
404
|
-
configFile: false,
|
|
405
|
-
babelrc: false,
|
|
406
|
-
sourceMaps: false,
|
|
407
|
-
compact: false,
|
|
408
|
-
plugins: [freshPlugin],
|
|
409
|
-
});
|
|
410
|
-
const linkedCode = res?.code && res.code !== code ? res.code : code;
|
|
411
|
-
const finalCode = applyAngularChunkPostProcessing(linkedCode, { vendorInjectExport });
|
|
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 });
|
|
412
552
|
if (finalCode !== code) {
|
|
413
553
|
chunk.code = finalCode;
|
|
554
|
+
recordLinkerHit('post');
|
|
414
555
|
if (debug) {
|
|
415
|
-
|
|
416
|
-
console.log('[ns-angular-linker][post] linked', fileName, isNsPolyfills ? '(polyfills)' : '');
|
|
417
|
-
}
|
|
418
|
-
catch { }
|
|
556
|
+
console.log('[ns-angular-linker][post] linked', fileName, isNsPolyfills ? '(polyfills)' : '');
|
|
419
557
|
}
|
|
420
558
|
}
|
|
421
559
|
if (strict && !isNsPolyfills && containsRealNgDeclare(finalCode)) {
|
|
@@ -429,16 +567,20 @@ export const angularConfig = ({ mode }) => {
|
|
|
429
567
|
}
|
|
430
568
|
}
|
|
431
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();
|
|
432
574
|
if (strict && unlinked.length) {
|
|
433
575
|
const details = [];
|
|
434
576
|
for (const fname of unlinked) {
|
|
435
577
|
const chunk = bundle[fname];
|
|
436
578
|
const modIds = chunk?.modules
|
|
437
579
|
? Object.keys(chunk.modules)
|
|
438
|
-
.filter((m) => /node_modules\/(?:@angular|@nativescript\/angular)\//.test(m))
|
|
580
|
+
.filter((m) => /node_modules\/(?:@angular|@nativescript\/angular)\//.test(normalizeAngularWatchPath(m)))
|
|
439
581
|
.slice(0, 8)
|
|
440
582
|
: [];
|
|
441
|
-
const isOnlyPolyfills = modIds.length > 0 && modIds.every(
|
|
583
|
+
const isOnlyPolyfills = modIds.length > 0 && modIds.every(isNsAngularPolyfillsModule);
|
|
442
584
|
if (isOnlyPolyfills)
|
|
443
585
|
continue;
|
|
444
586
|
let snippet = '';
|
|
@@ -461,10 +603,7 @@ export const angularConfig = ({ mode }) => {
|
|
|
461
603
|
throw new Error(message);
|
|
462
604
|
}
|
|
463
605
|
else {
|
|
464
|
-
|
|
465
|
-
console.warn(`[ns-angular-linker-post] ${message}`);
|
|
466
|
-
}
|
|
467
|
-
catch { }
|
|
606
|
+
console.warn(`[ns-angular-linker-post] ${message}`);
|
|
468
607
|
}
|
|
469
608
|
}
|
|
470
609
|
},
|
|
@@ -484,37 +623,20 @@ export const angularConfig = ({ mode }) => {
|
|
|
484
623
|
try {
|
|
485
624
|
let transformed = code;
|
|
486
625
|
if (containsRealNgDeclare(code)) {
|
|
487
|
-
const { babel } = await
|
|
488
|
-
if (!babel)
|
|
626
|
+
const { babel, createLinker } = await getAngularLinkerFactory(process.cwd());
|
|
627
|
+
if (!babel || !createLinker)
|
|
489
628
|
return null;
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const freshPlugin = (await importLinkerFactory())?.({ sourceMapping: false, fileSystem });
|
|
493
|
-
if (!freshPlugin)
|
|
494
|
-
return null;
|
|
495
|
-
const runLink = async (input) => {
|
|
496
|
-
const result = await babel.transformAsync(input, {
|
|
497
|
-
filename,
|
|
498
|
-
configFile: false,
|
|
499
|
-
babelrc: false,
|
|
500
|
-
sourceMaps: false,
|
|
501
|
-
compact: false,
|
|
502
|
-
plugins: [freshPlugin],
|
|
503
|
-
});
|
|
504
|
-
return result?.code ?? input;
|
|
505
|
-
};
|
|
506
|
-
transformed = await runLink(code);
|
|
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;
|
|
507
631
|
if (containsRealNgDeclare(transformed)) {
|
|
508
|
-
transformed = await
|
|
632
|
+
transformed = (await runAngularLinker(transformed, { filename, projectRoot: process.cwd(), freshPlugin: true })) ?? transformed;
|
|
509
633
|
}
|
|
510
634
|
}
|
|
511
635
|
transformed = applyAngularChunkPostProcessing(transformed);
|
|
512
636
|
if (transformed !== code) {
|
|
637
|
+
recordLinkerHit('render');
|
|
513
638
|
if (debug) {
|
|
514
|
-
|
|
515
|
-
console.log('[ns-angular-linker][render] linked', filename);
|
|
516
|
-
}
|
|
517
|
-
catch { }
|
|
639
|
+
console.log('[ns-angular-linker][render] linked', filename);
|
|
518
640
|
}
|
|
519
641
|
return { code: transformed, map: null };
|
|
520
642
|
}
|
|
@@ -526,9 +648,8 @@ export const angularConfig = ({ mode }) => {
|
|
|
526
648
|
},
|
|
527
649
|
};
|
|
528
650
|
const enableRollupLinker = process.env.NS_ENABLE_ROLLUP_LINKER === '1' || process.env.NS_ENABLE_ROLLUP_LINKER === 'true' || hmrActive;
|
|
529
|
-
//
|
|
530
|
-
//
|
|
531
|
-
// that silently clobbered the fesm2022 and RxJS aliases.
|
|
651
|
+
// Single merged alias array — a second `resolve` key from a conditional
|
|
652
|
+
// spread would silently clobber the fesm2022 and RxJS aliases.
|
|
532
653
|
const angularAliases = [
|
|
533
654
|
// Map Angular deep ESM paths to bare package ids
|
|
534
655
|
{ find: /^@angular\/([^/]+)\/fesm2022\/.*\.mjs$/, replacement: '@angular/$1' },
|