@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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
|
-
import { readFile } from 'fs/promises';
|
|
3
2
|
import path from 'path';
|
|
4
|
-
import { readFileSync } from 'fs';
|
|
5
3
|
import { createHash } from 'crypto';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { registerVendorManifest, clearVendorManifest, getVendorManifest, getVendorRuntimeModule } from './registry.js';
|
|
5
|
+
import { collectVendorModules } from './manifest-collect.js';
|
|
6
|
+
import { generatePlatformPolyfills } from '../runtime/platform-polyfills.js';
|
|
8
7
|
import { createNativeClassEsbuildPlugin } from '../../../helpers/nativeclass-esbuild-plugin.js';
|
|
8
|
+
import { getGlobalDefines } from '../../../helpers/global-defines.js';
|
|
9
|
+
import { createVendorEsbuildPlugin, createSolidJsxEsbuildPlugin, angularLinkerEsbuildPlugin, createUnicodeRegexEsbuildPlugin, createWebpackLoaderStubEsbuildPlugin, createNodeBuiltinPolyfillEsbuildPlugin, createOptionalDependencyStubEsbuildPlugin, createNativeAddonStubEsbuildPlugin } from './vendor-esbuild-plugins.js';
|
|
9
10
|
export const VENDOR_MANIFEST_ID = '@nativescript/vendor-manifest';
|
|
10
11
|
export const VENDOR_MANIFEST_VIRTUAL_ID = '\0' + VENDOR_MANIFEST_ID;
|
|
11
12
|
export const VENDOR_BUNDLE_ID = '@nativescript/vendor';
|
|
@@ -14,50 +15,6 @@ export const SERVER_VENDOR_PATH = '/@nativescript/vendor.mjs';
|
|
|
14
15
|
export const SERVER_MANIFEST_PATH = '/@nativescript/vendor-manifest.json';
|
|
15
16
|
export const DEFAULT_VENDOR_FILENAME = 'ns-vendor.mjs';
|
|
16
17
|
export const DEFAULT_MANIFEST_FILENAME = 'ns-vendor-manifest.json';
|
|
17
|
-
// Do not force-include @nativescript/core in the dev vendor bundle.
|
|
18
|
-
// Keeping core out of vendor avoids duplicate side-effect registrations (e.g.,
|
|
19
|
-
// com.tns.FragmentClass, com.tns.NativeScriptActivity) across bundle.mjs and vendor.
|
|
20
|
-
// Reserved for any future always-include packages; keep empty by default so
|
|
21
|
-
// framework-specific tooling like @angular/compiler are only pulled in when
|
|
22
|
-
// the corresponding framework is actually used.
|
|
23
|
-
const ALWAYS_INCLUDE = new Set([]);
|
|
24
|
-
const ALWAYS_EXCLUDE = new Set([
|
|
25
|
-
'@nativescript/android',
|
|
26
|
-
'@nativescript/ios',
|
|
27
|
-
'@nativescript/types',
|
|
28
|
-
'@nativescript/webpack',
|
|
29
|
-
// Angular browser animations are not used in NativeScript; excluding reduces
|
|
30
|
-
// memory pressure and avoids bringing partial declarations into vendor.
|
|
31
|
-
'@angular/animations',
|
|
32
|
-
'@angular/platform-browser/animations',
|
|
33
|
-
// Not needed at runtime with linked partials; reduce vendor size/memory.
|
|
34
|
-
'@angular/platform-browser-dynamic',
|
|
35
|
-
// Native add-on helpers pulled by ws or others; exclude in NS dev vendor
|
|
36
|
-
'bufferutil',
|
|
37
|
-
'utf-8-validate',
|
|
38
|
-
'node-gyp-build',
|
|
39
|
-
'bufferutil',
|
|
40
|
-
'utf-8-validate',
|
|
41
|
-
'node-gyp-build',
|
|
42
|
-
'@babel/core',
|
|
43
|
-
'@babel/helper-plugin-utils',
|
|
44
|
-
'@babel/generator',
|
|
45
|
-
'@babel/helper-string-parser',
|
|
46
|
-
'@babel/helper-validator-identifier',
|
|
47
|
-
'@babel/parser',
|
|
48
|
-
'@babel/plugin-syntax-typescript',
|
|
49
|
-
'@babel/plugin-transform-typescript',
|
|
50
|
-
'@babel/types',
|
|
51
|
-
// Heavy dependency not needed in vendor dev bundle; fetch via HTTP loader instead
|
|
52
|
-
'rxjs',
|
|
53
|
-
'nativescript',
|
|
54
|
-
'typescript',
|
|
55
|
-
'ts-node',
|
|
56
|
-
'vue-tsc',
|
|
57
|
-
'ws',
|
|
58
|
-
'@types/node',
|
|
59
|
-
'nativescript-theme-core',
|
|
60
|
-
]);
|
|
61
18
|
const INDEX_ALIAS_SUFFIXES = ['/index', '/index.js', '/index.android.js', '/index.ios.js', '/index.visionos.js'];
|
|
62
19
|
export function vendorManifestPlugin(options) {
|
|
63
20
|
let cachedResult = null;
|
|
@@ -101,15 +58,47 @@ export function vendorManifestPlugin(options) {
|
|
|
101
58
|
cachedResult = null;
|
|
102
59
|
clearVendorManifest();
|
|
103
60
|
};
|
|
61
|
+
// Manifest registration without the esbuild payload build. The dev serve
|
|
62
|
+
// process only needs the manifest (module ids + aliases) for the import
|
|
63
|
+
// map and vendor-routing decisions — the payload itself is deps-backed
|
|
64
|
+
// (see getVendorRuntimeModule). The full build stays lazy, reached only
|
|
65
|
+
// through the fallback serving path or the build-process virtual modules.
|
|
66
|
+
const ensureManifestRegistered = () => {
|
|
67
|
+
if (getVendorManifest())
|
|
68
|
+
return;
|
|
69
|
+
const collected = collectVendorModules(options.projectRoot, options.platform, options.flavor);
|
|
70
|
+
const hash = createHash('sha1').update(JSON.stringify(collected.entries)).digest('hex');
|
|
71
|
+
registerVendorManifest(buildManifest(collected.entries, hash));
|
|
72
|
+
};
|
|
104
73
|
const respondWithVendor = async (_server, req, res) => {
|
|
105
74
|
try {
|
|
106
|
-
const result = await ensureResult('server');
|
|
107
75
|
if (req.url === SERVER_VENDOR_PATH) {
|
|
76
|
+
// ONE node_modules payload: when the deps bundle is active, the
|
|
77
|
+
// vendor module is a thin view over /ns/deps-bundle.mjs.
|
|
78
|
+
const depsBacked = getVendorRuntimeModule();
|
|
79
|
+
if (depsBacked !== null) {
|
|
80
|
+
res.setHeader('Content-Type', 'application/javascript');
|
|
81
|
+
res.end(depsBacked);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
// No deps bundle (build failed or NS_DEPS_PER_MODULE=1): serve a
|
|
85
|
+
// view over the SAME `/ns/m/node_modules/<pkg>` URLs the import
|
|
86
|
+
// map targets, so the registry and import-side resolution share
|
|
87
|
+
// one realm. Never a second standalone payload — that realm
|
|
88
|
+
// split is exactly what the deps bundle design forbids.
|
|
89
|
+
ensureManifestRegistered();
|
|
108
90
|
res.setHeader('Content-Type', 'application/javascript');
|
|
109
|
-
res.end(
|
|
91
|
+
res.end(createHttpVendorRuntimeModule(getVendorManifest()));
|
|
110
92
|
return true;
|
|
111
93
|
}
|
|
112
94
|
if (req.url === SERVER_MANIFEST_PATH) {
|
|
95
|
+
const registered = getVendorManifest();
|
|
96
|
+
if (registered) {
|
|
97
|
+
res.setHeader('Content-Type', 'application/json');
|
|
98
|
+
res.end(JSON.stringify(registered, null, 2));
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
const result = await ensureResult('server');
|
|
113
102
|
res.setHeader('Content-Type', 'application/json');
|
|
114
103
|
res.end(JSON.stringify(result.manifest, null, 2));
|
|
115
104
|
return true;
|
|
@@ -128,7 +117,12 @@ export function vendorManifestPlugin(options) {
|
|
|
128
117
|
enforce: 'pre',
|
|
129
118
|
configResolved() { },
|
|
130
119
|
async configureServer(server) {
|
|
131
|
-
|
|
120
|
+
try {
|
|
121
|
+
ensureManifestRegistered();
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('[vendor] failed to register vendor manifest at server start', error);
|
|
125
|
+
}
|
|
132
126
|
server.middlewares.use(async (req, res, next) => {
|
|
133
127
|
if (req.url === SERVER_VENDOR_PATH || req.url === SERVER_MANIFEST_PATH) {
|
|
134
128
|
const handled = await respondWithVendor(server, req, res);
|
|
@@ -146,9 +140,12 @@ export function vendorManifestPlugin(options) {
|
|
|
146
140
|
return;
|
|
147
141
|
}
|
|
148
142
|
resetCache();
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
143
|
+
try {
|
|
144
|
+
ensureManifestRegistered();
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('[vendor] failed to regenerate vendor manifest', error);
|
|
148
|
+
}
|
|
152
149
|
});
|
|
153
150
|
},
|
|
154
151
|
async buildStart() {
|
|
@@ -173,15 +170,8 @@ export function vendorManifestPlugin(options) {
|
|
|
173
170
|
}
|
|
174
171
|
if (id === VENDOR_BUNDLE_VIRTUAL_ID) {
|
|
175
172
|
const result = await ensureResult('load-bundle');
|
|
176
|
-
// Return a single self-contained module that includes both the vendor module map
|
|
177
|
-
// and the vendor manifest to avoid extra imports that can influence chunking.
|
|
178
|
-
// - result.code exports `__nsVendorModuleMap`
|
|
179
|
-
// - we append an inline manifest export
|
|
180
173
|
return {
|
|
181
|
-
code:
|
|
182
|
-
export const vendorManifest = ${JSON.stringify(result.manifest)};
|
|
183
|
-
export default vendorManifest;
|
|
184
|
-
`,
|
|
174
|
+
code: createVendorBundleRuntimeModule(result),
|
|
185
175
|
moduleType: 'js',
|
|
186
176
|
};
|
|
187
177
|
}
|
|
@@ -219,7 +209,73 @@ async function generateVendorBundle(options) {
|
|
|
219
209
|
const { projectRoot, platform, mode, flavor } = options;
|
|
220
210
|
const collected = collectVendorModules(projectRoot, platform, flavor);
|
|
221
211
|
const entryCode = createVendorEntry(collected.entries);
|
|
212
|
+
// Externalize @nativescript/core and its subpaths in the vendor bundle so
|
|
213
|
+
// vendored packages (e.g. @nativescript-community/ui-material-bottomsheet)
|
|
214
|
+
// do NOT bring their own copy of core with them. The iOS import map maps
|
|
215
|
+
// `@nativescript/core` → `/ns/core` (the core bridge) at runtime, and the
|
|
216
|
+
// bridge delegates to the canonical Application/View/etc. already set up
|
|
217
|
+
// by bundle.mjs via installCoreAliasesEarly + the globalThis.Application
|
|
218
|
+
// seed. Without this externalization, vendor.mjs bundles a second copy of
|
|
219
|
+
// iOSApplication/View/LayoutBase — the second iosApp never receives the
|
|
220
|
+
// iOS launch event (bundle.mjs's iosApp registered first as
|
|
221
|
+
// UIApplication.delegate), so Application.getRootView() on it returns
|
|
222
|
+
// undefined, and any vendor-internal code that reads .getRootView() or
|
|
223
|
+
// checks `instanceof View` against bundle's classes fails under HMR.
|
|
224
|
+
const nsCoreExternalPlugin = {
|
|
225
|
+
name: 'ns-core-external',
|
|
226
|
+
setup(build) {
|
|
227
|
+
build.onResolve({ filter: /^@nativescript\/core(?:\/.*)?$/ }, (args) => ({
|
|
228
|
+
path: args.path,
|
|
229
|
+
external: true,
|
|
230
|
+
}));
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
// Externalize the `solid-js` root specifier for the Solid flavor so
|
|
234
|
+
// vendor-bundled packages (e.g. `@nativescript-community/solid-js`,
|
|
235
|
+
// `solid-navigation`, transitively `solid-js/universal` and
|
|
236
|
+
// `solid-js/store`) don't bake their own copy of solid-js into
|
|
237
|
+
// vendor.mjs. The dev server's import map (see `import-map.ts`)
|
|
238
|
+
// redirects bare `solid-js` to the same `/ns/m/node_modules/solid-js/...`
|
|
239
|
+
// URL that Vite's alias produces for user code and `@solid-refresh`,
|
|
240
|
+
// so V8 dedupes the three import paths down to a single module
|
|
241
|
+
// instance — one `Owner` module-local, one reactive graph, one
|
|
242
|
+
// `$DEVCOMP`/`$PROXY` symbol identity across the whole app.
|
|
243
|
+
//
|
|
244
|
+
// Important: scope this to the EXACT bare `solid-js` specifier. Subpaths
|
|
245
|
+
// like `solid-js/store`, `solid-js/universal`, `solid-js/web` stay
|
|
246
|
+
// bundleable so vendor packages that import them keep working out of
|
|
247
|
+
// the box; those subpaths still go through the unified solid-js
|
|
248
|
+
// runtime via their own `import 'solid-js'` statements (which we just
|
|
249
|
+
// externalized).
|
|
250
|
+
const nsSolidJsExternalPlugin = {
|
|
251
|
+
name: 'ns-solid-js-external',
|
|
252
|
+
setup(build) {
|
|
253
|
+
build.onResolve({ filter: /^solid-js$/ }, (args) => ({
|
|
254
|
+
path: args.path,
|
|
255
|
+
external: true,
|
|
256
|
+
}));
|
|
257
|
+
},
|
|
258
|
+
};
|
|
222
259
|
const plugins = [
|
|
260
|
+
// Mark @nativescript/core external BEFORE other plugins so esbuild never
|
|
261
|
+
// tries to read/transform core's source files. See comment above.
|
|
262
|
+
nsCoreExternalPlugin,
|
|
263
|
+
// Stub legacy webpack-loader-prefixed requires (dead NS 6/7 branches in
|
|
264
|
+
// plugins) BEFORE resolution — a single `loader!./x` specifier would
|
|
265
|
+
// otherwise hard-fail the whole bundle. See the plugin for details.
|
|
266
|
+
createWebpackLoaderStubEsbuildPlugin(),
|
|
267
|
+
createOptionalDependencyStubEsbuildPlugin(options.projectRoot),
|
|
268
|
+
// Stub compiled `.node` addons (fsevents & co.) — unloadable by esbuild and
|
|
269
|
+
// unrunnable on device; a throwing stub preserves optional-dep semantics.
|
|
270
|
+
createNativeAddonStubEsbuildPlugin(),
|
|
271
|
+
// Bundle installed npm polyfills for node-builtin names (buffer, events,
|
|
272
|
+
// ...) instead of leaving bare externals the device cannot resolve.
|
|
273
|
+
createNodeBuiltinPolyfillEsbuildPlugin(projectRoot),
|
|
274
|
+
// For the Solid flavor, externalize `solid-js` so vendor.mjs and the
|
|
275
|
+
// HTTP-served `@solid-refresh` / user code converge on one runtime
|
|
276
|
+
// realm. See `nsSolidJsExternalPlugin`'s definition for the full
|
|
277
|
+
// duplicate-instance rationale.
|
|
278
|
+
...(flavor === 'solid' ? [nsSolidJsExternalPlugin] : []),
|
|
223
279
|
// Apply NativeClass transformer to convert @NativeClass decorated classes to ES5 IIFE pattern.
|
|
224
280
|
// This MUST run before other plugins to ensure proper transformation.
|
|
225
281
|
createNativeClassEsbuildPlugin(platform),
|
|
@@ -233,6 +289,20 @@ async function generateVendorBundle(options) {
|
|
|
233
289
|
if (flavor === 'angular') {
|
|
234
290
|
plugins.push(angularLinkerEsbuildPlugin(projectRoot));
|
|
235
291
|
}
|
|
292
|
+
// Solid packages (e.g. solid-navigation) may ship raw .jsx/.tsx source
|
|
293
|
+
// files instead of pre-compiled .js. esbuild's default JSX transform
|
|
294
|
+
// targets React (React.createElement), which crashes at runtime with
|
|
295
|
+
// "React is not defined". Add a plugin that compiles .jsx/.tsx through
|
|
296
|
+
// babel-preset-solid so the vendor bundle gets proper Solid output.
|
|
297
|
+
if (flavor === 'solid') {
|
|
298
|
+
plugins.push(createSolidJsxEsbuildPlugin(projectRoot));
|
|
299
|
+
}
|
|
300
|
+
// Registered last so the framework-specific passes above own their files
|
|
301
|
+
// first (esbuild stops at the first onLoad that returns a result). Applies
|
|
302
|
+
// to every flavor: any vendored dependency (e.g. highlight.js) may ship
|
|
303
|
+
// `\p{…}` regexes that NativeScript's non-ICU V8 cannot compile, which would
|
|
304
|
+
// otherwise abort the entire vendor.mjs compile. See the plugin for details.
|
|
305
|
+
plugins.push(createUnicodeRegexEsbuildPlugin(projectRoot));
|
|
236
306
|
const buildResult = await esbuild.build({
|
|
237
307
|
stdin: {
|
|
238
308
|
contents: entryCode,
|
|
@@ -252,23 +322,168 @@ async function generateVendorBundle(options) {
|
|
|
252
322
|
// that Rollup warns it "cannot interpret due to the position of the comment".
|
|
253
323
|
// This preserves license text while preventing noisy warnings.
|
|
254
324
|
legalComments: 'eof',
|
|
255
|
-
|
|
325
|
+
// NativeScript is always a client environment — never server-side. The conditions
|
|
326
|
+
// must include 'browser' so packages with conditional exports (e.g.,
|
|
327
|
+
// @tanstack/router-core/isServer) resolve to client-side variants.
|
|
328
|
+
//
|
|
329
|
+
// 'development'/'production' (mode) is intentionally excluded: esbuild resolves
|
|
330
|
+
// conditions in the order they appear in the package.json exports object, and
|
|
331
|
+
// many packages list 'development' before 'browser'. Including it would cause
|
|
332
|
+
// environment-ambiguous stubs (e.g., isServer = undefined) to win over the
|
|
333
|
+
// correct client-side value (isServer = false). The 'import' condition already
|
|
334
|
+
// provides the correct ESM entry points, and process.env.NODE_ENV (set via
|
|
335
|
+
// define below) handles dev/prod branching at runtime.
|
|
336
|
+
//
|
|
337
|
+
// This aligns with the non-HMR Vite build: ['module', 'react-native', 'import', 'browser', 'default'].
|
|
338
|
+
conditions: ['module', 'react-native', 'import', 'browser', 'default'],
|
|
256
339
|
mainFields: ['module', 'browser', 'main'],
|
|
257
340
|
resolveExtensions: resolveExtensionsForPlatform(platform),
|
|
258
341
|
loader: {
|
|
259
342
|
'.css': 'text',
|
|
260
343
|
'.json': 'json',
|
|
261
344
|
},
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
345
|
+
// Mirror Vite's main-bundle DefinePlugin in the vendor esbuild build.
|
|
346
|
+
//
|
|
347
|
+
// esbuild's `define` requires every value to be a JS expression
|
|
348
|
+
// expressed as a string (the same constraint Vite normalises away).
|
|
349
|
+
// `getGlobalDefines()` returns a few raw `boolean` values for
|
|
350
|
+
// historical reasons (e.g. `__COMMONJS__: false`,
|
|
351
|
+
// `__UI_USE_XML_PARSER__: true`), so coerce any non-string entries
|
|
352
|
+
// through `JSON.stringify` before handing the table to esbuild.
|
|
353
|
+
define: (() => {
|
|
354
|
+
const raw = getGlobalDefines({
|
|
355
|
+
platform,
|
|
356
|
+
targetMode: mode,
|
|
357
|
+
verbose: !!options.verbose,
|
|
358
|
+
flavor: flavor ?? '',
|
|
359
|
+
isCI: !!process.env.CI,
|
|
360
|
+
});
|
|
361
|
+
const out = {};
|
|
362
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
363
|
+
out[key] = typeof value === 'string' ? value : JSON.stringify(value);
|
|
364
|
+
}
|
|
365
|
+
// Belt-and-suspenders: keep the original NODE_ENV define explicit so
|
|
366
|
+
// future changes to `getGlobalDefines()` can't silently drop it.
|
|
367
|
+
out['process.env.NODE_ENV'] = JSON.stringify(mode);
|
|
368
|
+
// webpack-HMR idiom carried by ESM-published packages — a FREE
|
|
369
|
+
// `module.hot` reference is a ReferenceError in the ESM bundle the
|
|
370
|
+
// moment it evaluates (see the matching define in deps-bundle.ts).
|
|
371
|
+
out['module.hot'] = 'undefined';
|
|
372
|
+
return out;
|
|
373
|
+
})(),
|
|
265
374
|
plugins,
|
|
266
|
-
|
|
375
|
+
// Externalize ALL Node built-in modules. The vendor bundle runs on the
|
|
376
|
+
// NativeScript device runtime, not Node, so any Node API reference must
|
|
377
|
+
// be external. Using both bare and 'node:' prefixed forms.
|
|
378
|
+
external: [
|
|
379
|
+
'assert',
|
|
380
|
+
'async_hooks',
|
|
381
|
+
'buffer',
|
|
382
|
+
'child_process',
|
|
383
|
+
'cluster',
|
|
384
|
+
'console',
|
|
385
|
+
'constants',
|
|
386
|
+
'crypto',
|
|
387
|
+
'dgram',
|
|
388
|
+
'diagnostics_channel',
|
|
389
|
+
'dns',
|
|
390
|
+
'domain',
|
|
391
|
+
'events',
|
|
392
|
+
'fs',
|
|
393
|
+
'fs/promises',
|
|
394
|
+
'http',
|
|
395
|
+
'http2',
|
|
396
|
+
'https',
|
|
397
|
+
'inspector',
|
|
398
|
+
'module',
|
|
399
|
+
'net',
|
|
400
|
+
'os',
|
|
401
|
+
'path',
|
|
402
|
+
'path/posix',
|
|
403
|
+
'path/win32',
|
|
404
|
+
'perf_hooks',
|
|
405
|
+
'process',
|
|
406
|
+
'punycode',
|
|
407
|
+
'querystring',
|
|
408
|
+
'readline',
|
|
409
|
+
'repl',
|
|
410
|
+
'stream',
|
|
411
|
+
'stream/web',
|
|
412
|
+
'stream/promises',
|
|
413
|
+
'string_decoder',
|
|
414
|
+
'sys',
|
|
415
|
+
'timers',
|
|
416
|
+
'timers/promises',
|
|
417
|
+
'tls',
|
|
418
|
+
'trace_events',
|
|
419
|
+
'tty',
|
|
420
|
+
'url',
|
|
421
|
+
'util',
|
|
422
|
+
'v8',
|
|
423
|
+
'vm',
|
|
424
|
+
'wasi',
|
|
425
|
+
'worker_threads',
|
|
426
|
+
'zlib',
|
|
427
|
+
// node: prefixed variants
|
|
428
|
+
'node:assert',
|
|
429
|
+
'node:async_hooks',
|
|
430
|
+
'node:buffer',
|
|
431
|
+
'node:child_process',
|
|
432
|
+
'node:cluster',
|
|
433
|
+
'node:console',
|
|
434
|
+
'node:constants',
|
|
435
|
+
'node:crypto',
|
|
436
|
+
'node:dgram',
|
|
437
|
+
'node:diagnostics_channel',
|
|
438
|
+
'node:dns',
|
|
439
|
+
'node:domain',
|
|
440
|
+
'node:events',
|
|
441
|
+
'node:fs',
|
|
442
|
+
'node:fs/promises',
|
|
443
|
+
'node:http',
|
|
444
|
+
'node:http2',
|
|
445
|
+
'node:https',
|
|
446
|
+
'node:inspector',
|
|
447
|
+
'node:module',
|
|
448
|
+
'node:net',
|
|
449
|
+
'node:os',
|
|
450
|
+
'node:path',
|
|
451
|
+
'node:path/posix',
|
|
452
|
+
'node:path/win32',
|
|
453
|
+
'node:perf_hooks',
|
|
454
|
+
'node:process',
|
|
455
|
+
'node:punycode',
|
|
456
|
+
'node:querystring',
|
|
457
|
+
'node:readline',
|
|
458
|
+
'node:repl',
|
|
459
|
+
'node:stream',
|
|
460
|
+
'node:stream/web',
|
|
461
|
+
'node:stream/promises',
|
|
462
|
+
'node:string_decoder',
|
|
463
|
+
'node:sys',
|
|
464
|
+
'node:timers',
|
|
465
|
+
'node:timers/promises',
|
|
466
|
+
'node:tls',
|
|
467
|
+
'node:trace_events',
|
|
468
|
+
'node:tty',
|
|
469
|
+
'node:url',
|
|
470
|
+
'node:util',
|
|
471
|
+
'node:v8',
|
|
472
|
+
'node:vm',
|
|
473
|
+
'node:wasi',
|
|
474
|
+
'node:worker_threads',
|
|
475
|
+
'node:zlib',
|
|
476
|
+
],
|
|
267
477
|
});
|
|
268
478
|
if (!buildResult.outputFiles?.length) {
|
|
269
479
|
throw new Error('Vendor bundle generation produced no output');
|
|
270
480
|
}
|
|
271
|
-
const
|
|
481
|
+
const rawVendorCode = buildResult.outputFiles[0].text;
|
|
482
|
+
// Prepend platform polyfills so they run BEFORE any vendor module code.
|
|
483
|
+
// This ensures globals like AbortController and self are available when
|
|
484
|
+
// frameworks (TanStack Router, etc.) first execute inside the bundle.
|
|
485
|
+
const polyfillPrelude = generatePlatformPolyfills();
|
|
486
|
+
const vendorCode = polyfillPrelude + rawVendorCode;
|
|
272
487
|
const hash = createHash('sha1').update(vendorCode).digest('hex');
|
|
273
488
|
const manifest = buildManifest(collected.entries, hash);
|
|
274
489
|
return {
|
|
@@ -277,165 +492,70 @@ async function generateVendorBundle(options) {
|
|
|
277
492
|
entries: collected.entries,
|
|
278
493
|
};
|
|
279
494
|
}
|
|
280
|
-
function collectVendorModules(projectRoot, platform, flavor) {
|
|
281
|
-
const packageJsonPath = path.resolve(projectRoot, 'package.json');
|
|
282
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
283
|
-
const projectRequire = createRequire(packageJsonPath);
|
|
284
|
-
const vendor = new Set();
|
|
285
|
-
const visited = new Set();
|
|
286
|
-
const queue = [];
|
|
287
|
-
const isPackageRootSpecifier = (name) => {
|
|
288
|
-
if (!name)
|
|
289
|
-
return false;
|
|
290
|
-
if (name.startsWith('@')) {
|
|
291
|
-
// Scoped: @scope/name is root; anything deeper is subpath
|
|
292
|
-
const parts = name.split('/');
|
|
293
|
-
return parts.length === 2;
|
|
294
|
-
}
|
|
295
|
-
// Unscoped: no slash means root; any slash means subpath
|
|
296
|
-
return !name.includes('/');
|
|
297
|
-
};
|
|
298
|
-
const isAngularFlavor = flavor === 'angular';
|
|
299
|
-
const addCandidate = (name) => {
|
|
300
|
-
if (!name || shouldSkipDependency(name)) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
// Avoid pulling Angular compiler/runtime into the dev vendor bundle when
|
|
304
|
-
// the current project flavor is not Angular (for example, solid). This
|
|
305
|
-
// prevents esbuild from trying to bundle @angular/compiler and its Babel
|
|
306
|
-
// toolchain, which requires Node built-ins like fs/path/url.
|
|
307
|
-
if (!isAngularFlavor && (name === '@angular/compiler' || name.startsWith('@angular/'))) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const isRoot = isPackageRootSpecifier(name);
|
|
311
|
-
if (!visited.has(name)) {
|
|
312
|
-
visited.add(name);
|
|
313
|
-
}
|
|
314
|
-
vendor.add(name);
|
|
315
|
-
// Only traverse peer deps for package roots; subpaths should not attempt package.json resolution
|
|
316
|
-
if (isRoot) {
|
|
317
|
-
queue.push(name);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
const addDeps = (deps) => {
|
|
321
|
-
if (!deps) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
for (const name of Object.keys(deps)) {
|
|
325
|
-
addCandidate(name);
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
addDeps(pkg.dependencies);
|
|
329
|
-
addDeps(pkg.optionalDependencies);
|
|
330
|
-
for (const name of ALWAYS_INCLUDE) {
|
|
331
|
-
addCandidate(name);
|
|
332
|
-
}
|
|
333
|
-
// Ensure Android Activity proxy is present for SBG scanning in dev/HMR
|
|
334
|
-
// and non-HMR builds alike: explicitly include the side-effect module
|
|
335
|
-
// that registers `com.tns.NativeScriptActivity`.
|
|
336
|
-
if (platform === 'android') {
|
|
337
|
-
addCandidate('@nativescript/core/ui/frame/activity.android');
|
|
338
|
-
}
|
|
339
|
-
if (pkg.dependencies?.['nativescript-vue'] && pkg.devDependencies?.vue) {
|
|
340
|
-
addCandidate('vue');
|
|
341
|
-
}
|
|
342
|
-
if (pkg.dependencies?.['@nativescript/angular']) {
|
|
343
|
-
if (pkg.dependencies?.['@angular/core']) {
|
|
344
|
-
addCandidate('@angular/core');
|
|
345
|
-
}
|
|
346
|
-
if (pkg.dependencies?.['@angular/common']) {
|
|
347
|
-
addCandidate('@angular/common');
|
|
348
|
-
}
|
|
349
|
-
// RxJS is large and not required inside the vendor bundle for dev HMR.
|
|
350
|
-
// Avoid bundling to reduce memory pressure; let app import via HTTP loader.
|
|
351
|
-
}
|
|
352
|
-
if (pkg.dependencies?.['react-nativescript']) {
|
|
353
|
-
if (pkg.dependencies?.react) {
|
|
354
|
-
addCandidate('react');
|
|
355
|
-
}
|
|
356
|
-
if (pkg.dependencies?.['react-dom']) {
|
|
357
|
-
addCandidate('react-dom');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
parseEnvList(process.env.NS_VENDOR_INCLUDE).forEach(addCandidate);
|
|
361
|
-
const projectDeps = {
|
|
362
|
-
dependencies: new Set(Object.keys(pkg.dependencies ?? {})),
|
|
363
|
-
optional: new Set(Object.keys(pkg.optionalDependencies ?? {})),
|
|
364
|
-
dev: new Set(Object.keys(pkg.devDependencies ?? {})),
|
|
365
|
-
};
|
|
366
|
-
while (queue.length) {
|
|
367
|
-
const specifier = queue.shift();
|
|
368
|
-
const dependencyPkg = readDependencyPackageJson(specifier, projectRequire);
|
|
369
|
-
if (!dependencyPkg) {
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
const peerDependencies = Object.keys(dependencyPkg.peerDependencies ?? {});
|
|
373
|
-
for (const peer of peerDependencies) {
|
|
374
|
-
if (shouldSkipDependency(peer)) {
|
|
375
|
-
continue;
|
|
376
|
-
}
|
|
377
|
-
if (projectDeps.dependencies.has(peer) || projectDeps.optional.has(peer) || projectDeps.dev.has(peer)) {
|
|
378
|
-
addCandidate(peer);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
parseEnvList(process.env.NS_VENDOR_EXCLUDE).forEach((name) => {
|
|
383
|
-
vendor.delete(name);
|
|
384
|
-
});
|
|
385
|
-
return {
|
|
386
|
-
entries: Array.from(vendor).sort(),
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function shouldSkipDependency(name) {
|
|
390
|
-
if (!name) {
|
|
391
|
-
return true;
|
|
392
|
-
}
|
|
393
|
-
if (ALWAYS_EXCLUDE.has(name)) {
|
|
394
|
-
return true;
|
|
395
|
-
}
|
|
396
|
-
if (name.startsWith('.')) {
|
|
397
|
-
return true;
|
|
398
|
-
}
|
|
399
|
-
if (name.startsWith('file:')) {
|
|
400
|
-
return true;
|
|
401
|
-
}
|
|
402
|
-
if (name.startsWith('workspace:')) {
|
|
403
|
-
return true;
|
|
404
|
-
}
|
|
405
|
-
if (name.startsWith('link:')) {
|
|
406
|
-
return true;
|
|
407
|
-
}
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
function readDependencyPackageJson(specifier, projectRequire) {
|
|
411
|
-
try {
|
|
412
|
-
const packageJsonPath = projectRequire.resolve(`${specifier}/package.json`);
|
|
413
|
-
return JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
414
|
-
}
|
|
415
|
-
catch (error) {
|
|
416
|
-
if (process.env.VITE_DEBUG_LOGS) {
|
|
417
|
-
console.warn(`[vendor] unable to resolve ${specifier} package.json`, error);
|
|
418
|
-
}
|
|
419
|
-
return null;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
function parseEnvList(value) {
|
|
423
|
-
if (!value) {
|
|
424
|
-
return [];
|
|
425
|
-
}
|
|
426
|
-
return value
|
|
427
|
-
.split(',')
|
|
428
|
-
.map((token) => token.trim())
|
|
429
|
-
.filter(Boolean);
|
|
430
|
-
}
|
|
431
495
|
function createVendorEntry(entries) {
|
|
432
496
|
if (!entries.length) {
|
|
433
497
|
return `export const __nsVendorModuleMap = {};
|
|
434
498
|
`;
|
|
435
499
|
}
|
|
436
|
-
|
|
500
|
+
// Emit a side-effect-only import FIRST for each entry, then the namespace
|
|
501
|
+
// import we actually expose through `__nsVendorModuleMap`. Per the ESM
|
|
502
|
+
// spec, `import "pkg";` (no clause) guarantees module body evaluation, and
|
|
503
|
+
// esbuild treats these as DCE-immune even when the package declares
|
|
504
|
+
// `"sideEffects": false`. Without this, packages whose top-level
|
|
505
|
+
// statements install runtime patches (e.g. `@nativescript-community/text`
|
|
506
|
+
// monkey-patching `TextBase.prototype.setTextDecorationAndTransform` via
|
|
507
|
+
// `overrideSpanAndFormattedString()` invoked from
|
|
508
|
+
// `@nativescript-community/ui-label/index-common.js` line 12) can have
|
|
509
|
+
// their bodies elided by esbuild — exports stay resolvable via the
|
|
510
|
+
// namespace, but the runtime patches never fire, producing line-height /
|
|
511
|
+
// letter-spacing / formatted-text rendering divergence between HMR
|
|
512
|
+
// (vendor.mjs via HTTP) and no-HMR (single Rolldown bundle that inlines
|
|
513
|
+
// everything anyway). This affects any NS plugin that relies on top-level
|
|
514
|
+
// side-effects to wire up renderer behavior.
|
|
515
|
+
const sideEffectImports = entries.map((specifier) => `import ${JSON.stringify(specifier)};`).join('\n');
|
|
516
|
+
const namespaceImports = entries.map((specifier, index) => `import * as __nsVendor_${index} from ${JSON.stringify(specifier)};`).join('\n');
|
|
437
517
|
const modules = entries.map((specifier, index) => `${JSON.stringify(specifier)}: __nsVendor_${index}`).join(',\n ');
|
|
438
|
-
return `${
|
|
518
|
+
return `${sideEffectImports}\n\n${namespaceImports}\n\nexport const __nsVendorModuleMap = {\n ${modules}\n};\n`;
|
|
519
|
+
}
|
|
520
|
+
export function createVendorBundleRuntimeModule(result) {
|
|
521
|
+
return `${result.code}
|
|
522
|
+
export const vendorManifest = ${JSON.stringify(result.manifest)};
|
|
523
|
+
export default vendorManifest;
|
|
524
|
+
`;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Dev-session `/@nativescript/vendor.mjs` for sessions WITHOUT a deps bundle
|
|
528
|
+
* (esbuild failure or `NS_DEPS_PER_MODULE=1`): a thin view whose namespace
|
|
529
|
+
* imports go through the same `/ns/m/node_modules/<pkg>` URLs the device
|
|
530
|
+
* import map targets. Per-module serving keys module identity by URL, so the
|
|
531
|
+
* registry entries `installVendorBootstrap` creates from this map are the
|
|
532
|
+
* SAME instances import-side resolution produces — one realm, no standalone
|
|
533
|
+
* vendor payload. `@nativescript/core` stays a bare import (import map →
|
|
534
|
+
* `/ns/core` bridge realm).
|
|
535
|
+
*/
|
|
536
|
+
export function createHttpVendorRuntimeModule(manifest) {
|
|
537
|
+
const specs = Object.keys(manifest?.modules ?? {}).filter((spec) => spec !== '@nativescript/core' && !spec.startsWith('@nativescript/core/'));
|
|
538
|
+
const includeCore = !!manifest?.modules?.['@nativescript/core'];
|
|
539
|
+
const lines = [];
|
|
540
|
+
lines.push('/* /@nativescript/vendor.mjs — HTTP-backed vendor view (per-module mode) */');
|
|
541
|
+
if (includeCore) {
|
|
542
|
+
lines.push(`import * as __ns_core__ from "@nativescript/core";`);
|
|
543
|
+
}
|
|
544
|
+
specs.forEach((spec, index) => {
|
|
545
|
+
lines.push(`import * as __nsVendor_${index} from ${JSON.stringify(`/ns/m/node_modules/${spec}`)};`);
|
|
546
|
+
});
|
|
547
|
+
lines.push('export const __nsVendorModuleMap = {');
|
|
548
|
+
if (includeCore) {
|
|
549
|
+
lines.push(` ${JSON.stringify('@nativescript/core')}: __ns_core__,`);
|
|
550
|
+
}
|
|
551
|
+
specs.forEach((spec, index) => {
|
|
552
|
+
lines.push(` ${JSON.stringify(spec)}: __nsVendor_${index},`);
|
|
553
|
+
});
|
|
554
|
+
lines.push('};');
|
|
555
|
+
lines.push(`export const vendorManifest = ${JSON.stringify(manifest ?? {})};`);
|
|
556
|
+
lines.push('export default vendorManifest;');
|
|
557
|
+
lines.push('');
|
|
558
|
+
return lines.join('\n');
|
|
439
559
|
}
|
|
440
560
|
function resolveExtensionsForPlatform(platform) {
|
|
441
561
|
const base = ['.tsx', '.jsx', '.ts', '.js', '.mjs', '.cjs', '.json'];
|
|
@@ -494,330 +614,6 @@ function createSbgVendorAssetCode(platform) {
|
|
|
494
614
|
lines.push('export const __nsVendorModuleMap = {};\nexport default {};\n');
|
|
495
615
|
return lines.join('\n');
|
|
496
616
|
}
|
|
497
|
-
function createVendorEsbuildPlugin(projectRoot) {
|
|
498
|
-
return {
|
|
499
|
-
name: 'ns-vendor-resolver',
|
|
500
|
-
setup(build) {
|
|
501
|
-
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
502
|
-
build.onResolve({ filter: /^~\/package\.json$/ }, () => ({
|
|
503
|
-
path: path.resolve(projectRoot, 'package.json'),
|
|
504
|
-
}));
|
|
505
|
-
build.onResolve({ filter: /^module$/ }, () => ({
|
|
506
|
-
path: 'ns-vendor-module-shim',
|
|
507
|
-
namespace: 'ns-vendor',
|
|
508
|
-
}));
|
|
509
|
-
build.onLoad({ filter: /^ns-vendor-module-shim$/, namespace: 'ns-vendor' }, () => ({
|
|
510
|
-
contents: vendorModuleShim,
|
|
511
|
-
loader: 'js',
|
|
512
|
-
}));
|
|
513
|
-
// Stub Angular animations in vendor to avoid bundling browser-only code.
|
|
514
|
-
// Provide named exports expected by @nativescript/angular to satisfy esbuild.
|
|
515
|
-
const PB_ANIMATIONS_ID = 'ns-animations-pb-shim';
|
|
516
|
-
const ANIMATIONS_BROWSER_ID = 'ns-animations-browser-shim';
|
|
517
|
-
const ANIMATIONS_ID = 'ns-animations-noop';
|
|
518
|
-
// @angular/platform-browser/animations -> provide concrete named stubs
|
|
519
|
-
build.onResolve({ filter: /^@angular\/platform-browser\/animations(?:\/.*)?$/ }, (args) => {
|
|
520
|
-
if (debug) {
|
|
521
|
-
try {
|
|
522
|
-
console.log('[vendor] map', args.path, '->', PB_ANIMATIONS_ID);
|
|
523
|
-
}
|
|
524
|
-
catch { }
|
|
525
|
-
}
|
|
526
|
-
return { path: PB_ANIMATIONS_ID, namespace: 'ns-vendor' };
|
|
527
|
-
});
|
|
528
|
-
build.onLoad({ filter: new RegExp(`^${PB_ANIMATIONS_ID}$`), namespace: 'ns-vendor' }, () => ({
|
|
529
|
-
contents: [
|
|
530
|
-
'export default {};',
|
|
531
|
-
// Commonly imported symbols by @nativescript/angular
|
|
532
|
-
'export class AnimationBuilder {};',
|
|
533
|
-
'export const \u0275BrowserAnimationBuilder = class {};',
|
|
534
|
-
'export const \u0275AnimationEngine = class {};',
|
|
535
|
-
'export const \u0275AnimationRendererFactory = class {};',
|
|
536
|
-
'export const \u0275WebAnimationsStyleNormalizer = class {};',
|
|
537
|
-
// Typical platform-browser/animations APIs exported; safe no-ops
|
|
538
|
-
'export class BrowserAnimationsModule {};',
|
|
539
|
-
'export class NoopAnimationsModule {};',
|
|
540
|
-
'export const provideAnimations = (..._args) => [];',
|
|
541
|
-
'export const provideNoopAnimations = (..._args) => [];',
|
|
542
|
-
// Marker used by some Angular internals
|
|
543
|
-
'export const ANIMATION_MODULE_TYPE = void 0;',
|
|
544
|
-
].join('\n'),
|
|
545
|
-
loader: 'js',
|
|
546
|
-
}));
|
|
547
|
-
// @angular/animations/browser -> provide ɵ* engine/renderer/style normalizer stubs
|
|
548
|
-
build.onResolve({ filter: /^@angular\/animations\/browser(?:\/.*)?$/ }, (args) => {
|
|
549
|
-
if (debug) {
|
|
550
|
-
try {
|
|
551
|
-
console.log('[vendor] map', args.path, '->', ANIMATIONS_BROWSER_ID);
|
|
552
|
-
}
|
|
553
|
-
catch { }
|
|
554
|
-
}
|
|
555
|
-
return { path: ANIMATIONS_BROWSER_ID, namespace: 'ns-vendor' };
|
|
556
|
-
});
|
|
557
|
-
build.onLoad({ filter: new RegExp(`^${ANIMATIONS_BROWSER_ID}$`), namespace: 'ns-vendor' }, () => ({
|
|
558
|
-
contents: [
|
|
559
|
-
'export default {};',
|
|
560
|
-
'export class AnimationDriver {};',
|
|
561
|
-
'export const \u0275AnimationRendererFactory = class {};',
|
|
562
|
-
'export const \u0275AnimationStyleNormalizer = class {};',
|
|
563
|
-
'export const \u0275WebAnimationsStyleNormalizer = class {};',
|
|
564
|
-
'export const \u0275AnimationEngine = class {};',
|
|
565
|
-
// Convenience alias if any consumers import non-ɵ name
|
|
566
|
-
'export const AnimationStyleNormalizer = \u0275AnimationStyleNormalizer;',
|
|
567
|
-
].join('\n'),
|
|
568
|
-
loader: 'js',
|
|
569
|
-
}));
|
|
570
|
-
// @angular/animations -> broad no-op surface
|
|
571
|
-
build.onResolve(
|
|
572
|
-
// Keep generic mapping for @angular/animations base; /browser is handled above
|
|
573
|
-
{ filter: /^@angular\/animations(?:$|\/)$/ }, (args) => {
|
|
574
|
-
if (debug) {
|
|
575
|
-
try {
|
|
576
|
-
console.log('[vendor] map', args.path, '->', ANIMATIONS_ID);
|
|
577
|
-
}
|
|
578
|
-
catch { }
|
|
579
|
-
}
|
|
580
|
-
return { path: ANIMATIONS_ID, namespace: 'ns-vendor' };
|
|
581
|
-
});
|
|
582
|
-
build.onLoad({ filter: new RegExp(`^${ANIMATIONS_ID}$`), namespace: 'ns-vendor' }, () => ({
|
|
583
|
-
contents: [
|
|
584
|
-
'export default {};',
|
|
585
|
-
// Provide names sometimes (incorrectly) imported from @angular/animations by wrappers
|
|
586
|
-
'export class AnimationBuilder {};',
|
|
587
|
-
'export const \u0275BrowserAnimationBuilder = class {};',
|
|
588
|
-
'export const \u0275AnimationEngine = class {};',
|
|
589
|
-
'export const \u0275AnimationRendererFactory = class {};',
|
|
590
|
-
'export const \u0275WebAnimationsStyleNormalizer = class {};',
|
|
591
|
-
'export const ANIMATION_MODULE_TYPE = void 0;',
|
|
592
|
-
// Export a few common tokens as harmless stubs
|
|
593
|
-
'export const animate = (..._a) => ({});',
|
|
594
|
-
'export const state = (..._a) => ({});',
|
|
595
|
-
'export const style = (..._a) => ({});',
|
|
596
|
-
'export const transition = (..._a) => ({});',
|
|
597
|
-
'export const trigger = (..._a) => ({});',
|
|
598
|
-
'export const sequence = (..._a) => ({});',
|
|
599
|
-
'export const group = (..._a) => ({});',
|
|
600
|
-
'export const query = (..._a) => ({});',
|
|
601
|
-
'export const stagger = (..._a) => ({});',
|
|
602
|
-
'export const keyframes = (..._a) => ({});',
|
|
603
|
-
].join('\n'),
|
|
604
|
-
loader: 'js',
|
|
605
|
-
}));
|
|
606
|
-
},
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Minimal esbuild plugin to run Angular linker (Babel) over partial-compiled
|
|
611
|
-
* Angular packages in node_modules. This converts ɵɵngDeclare* calls into
|
|
612
|
-
* ɵɵdefine* so runtime doesn't require the JIT compiler.
|
|
613
|
-
*/
|
|
614
|
-
function angularLinkerEsbuildPlugin(projectRoot) {
|
|
615
|
-
// Lazily resolve Babel and Angular linker from the project to avoid hard deps
|
|
616
|
-
let babel = null;
|
|
617
|
-
let createLinker = null;
|
|
618
|
-
async function ensureDeps() {
|
|
619
|
-
if (babel && createLinker)
|
|
620
|
-
return;
|
|
621
|
-
try {
|
|
622
|
-
const req = createRequire(projectRoot + '/package.json');
|
|
623
|
-
// Resolve from the application project first
|
|
624
|
-
const babelPath = req.resolve('@babel/core');
|
|
625
|
-
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
626
|
-
babel = (await import(babelPath));
|
|
627
|
-
const linkerMod = await import(linkerPath);
|
|
628
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
629
|
-
}
|
|
630
|
-
catch {
|
|
631
|
-
// As a fallback, try local resolution (hoisted installs)
|
|
632
|
-
try {
|
|
633
|
-
babel = (await import('@babel/core'));
|
|
634
|
-
}
|
|
635
|
-
catch { }
|
|
636
|
-
try {
|
|
637
|
-
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
638
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
639
|
-
}
|
|
640
|
-
catch { }
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
// Restrict to Angular framework packages to minimize esbuild memory usage.
|
|
644
|
-
const FILTER = /node_modules\/(?:@angular|@nativescript\/angular)\/.*\.[mc]?js$/;
|
|
645
|
-
return {
|
|
646
|
-
name: 'ns-angular-linker',
|
|
647
|
-
async setup(build) {
|
|
648
|
-
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
649
|
-
await ensureDeps();
|
|
650
|
-
if (!babel || !createLinker) {
|
|
651
|
-
// Nothing to do if deps unavailable
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
build.onLoad({ filter: FILTER }, async (args) => {
|
|
655
|
-
try {
|
|
656
|
-
const source = await readFile(args.path, 'utf8');
|
|
657
|
-
// Fast-path: only run linker when partial declarations are present
|
|
658
|
-
if (!(source.includes('\u0275\u0275ngDeclare') || source.includes('ɵɵngDeclare'))) {
|
|
659
|
-
return { contents: source, loader: 'js' };
|
|
660
|
-
}
|
|
661
|
-
const plugin = createLinker({
|
|
662
|
-
// Link everything the filter captures; plugin will no-op otherwise
|
|
663
|
-
// shouldLink is inferred by plugin when left unset for Babel version
|
|
664
|
-
sourceMapping: false,
|
|
665
|
-
});
|
|
666
|
-
if (debug) {
|
|
667
|
-
try {
|
|
668
|
-
console.log('[ns-angular-linker][vendor] linking', args.path);
|
|
669
|
-
}
|
|
670
|
-
catch { }
|
|
671
|
-
}
|
|
672
|
-
const result = await babel.transformAsync(source, {
|
|
673
|
-
filename: args.path,
|
|
674
|
-
configFile: false,
|
|
675
|
-
babelrc: false,
|
|
676
|
-
sourceMaps: false,
|
|
677
|
-
compact: false,
|
|
678
|
-
plugins: [plugin],
|
|
679
|
-
});
|
|
680
|
-
return {
|
|
681
|
-
contents: (result && result.code) || source,
|
|
682
|
-
loader: 'js',
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
catch (e) {
|
|
686
|
-
// On any failure, return original source to avoid breaking the build
|
|
687
|
-
return { contents: await readFile(args.path, 'utf8'), loader: 'js' };
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
},
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
const vendorModuleShim = `
|
|
694
|
-
const g = globalThis;
|
|
695
|
-
const BACKSLASH = String.fromCharCode(92);
|
|
696
|
-
|
|
697
|
-
function toForwardSlashes(input) {
|
|
698
|
-
return String(input ?? '').split(BACKSLASH).join('/');
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
function getNativeScriptRequire() {
|
|
702
|
-
const nsRequire = typeof g.require === "function" ? g.require : null;
|
|
703
|
-
if (nsRequire) {
|
|
704
|
-
return nsRequire;
|
|
705
|
-
}
|
|
706
|
-
const legacy = g.__nsRequire;
|
|
707
|
-
if (typeof legacy === "function") {
|
|
708
|
-
return legacy;
|
|
709
|
-
}
|
|
710
|
-
return null;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
function getDocumentsPath() {
|
|
714
|
-
const cached = g.__NS_DOCUMENTS_PATH__;
|
|
715
|
-
if (typeof cached === "string" && cached.length) {
|
|
716
|
-
return toForwardSlashes(cached);
|
|
717
|
-
}
|
|
718
|
-
try {
|
|
719
|
-
const core = g.require ? g.require("@nativescript/core") : null;
|
|
720
|
-
const docsFolder = core?.knownFolders?.documents?.();
|
|
721
|
-
const docPath = docsFolder?.path;
|
|
722
|
-
if (docPath) {
|
|
723
|
-
const normalized = toForwardSlashes(docPath);
|
|
724
|
-
g.__NS_DOCUMENTS_PATH__ = normalized;
|
|
725
|
-
return normalized;
|
|
726
|
-
}
|
|
727
|
-
} catch (_err) {
|
|
728
|
-
// ignore - fallback to raw specifier
|
|
729
|
-
}
|
|
730
|
-
return null;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
function collapseSegments(input) {
|
|
734
|
-
const segments = [];
|
|
735
|
-
const parts = input.split('/');
|
|
736
|
-
for (const part of parts) {
|
|
737
|
-
if (!part || part === ".") {
|
|
738
|
-
continue;
|
|
739
|
-
}
|
|
740
|
-
if (part === "..") {
|
|
741
|
-
if (segments.length && segments[segments.length - 1] !== "..") {
|
|
742
|
-
segments.pop();
|
|
743
|
-
continue;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
segments.push(part);
|
|
747
|
-
}
|
|
748
|
-
const leadingSlash = input.startsWith('/');
|
|
749
|
-
return (leadingSlash ? '/' : '') + segments.join('/');
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
function normalizeSpecifier(spec) {
|
|
753
|
-
let value = String(spec ?? "");
|
|
754
|
-
value = toForwardSlashes(value);
|
|
755
|
-
const docsPath = getDocumentsPath();
|
|
756
|
-
if (value.startsWith("__NSDOC__/")) {
|
|
757
|
-
if (docsPath) {
|
|
758
|
-
value = docsPath + '/' + value.slice("__NSDOC__/".length);
|
|
759
|
-
} else {
|
|
760
|
-
value = value.slice("__NSDOC__/".length);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
if (value.startsWith("~/") && docsPath) {
|
|
764
|
-
value = docsPath + '/' + value.slice(2);
|
|
765
|
-
}
|
|
766
|
-
if (value.startsWith("file://")) {
|
|
767
|
-
const stripped = value.slice("file://".length);
|
|
768
|
-
value = stripped.startsWith('/') ? stripped : '/' + stripped;
|
|
769
|
-
}
|
|
770
|
-
if (value.includes("/../") || value.includes("/./")) {
|
|
771
|
-
value = collapseSegments(value);
|
|
772
|
-
}
|
|
773
|
-
return value;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
export function createRequire(_url) {
|
|
777
|
-
const nsRequire = getNativeScriptRequire();
|
|
778
|
-
if (!nsRequire) {
|
|
779
|
-
return function () {
|
|
780
|
-
throw new Error("NativeScript require() is not available in this context");
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
const req = function (id) {
|
|
784
|
-
const normalizedId = normalizeSpecifier(id);
|
|
785
|
-
if (
|
|
786
|
-
normalizedId.includes("../data/patch.json") ||
|
|
787
|
-
normalizedId.includes("css-tree/lib/data/patch.json")
|
|
788
|
-
) {
|
|
789
|
-
return {
|
|
790
|
-
atrules: {},
|
|
791
|
-
properties: {},
|
|
792
|
-
types: {},
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
if (normalizedId.includes("mdn-data/")) {
|
|
796
|
-
return {};
|
|
797
|
-
}
|
|
798
|
-
if (
|
|
799
|
-
normalizedId.endsWith("/package.json") ||
|
|
800
|
-
normalizedId.includes("../package.json")
|
|
801
|
-
) {
|
|
802
|
-
return { version: "0.0.0" };
|
|
803
|
-
}
|
|
804
|
-
if (normalizedId.endsWith(".json")) {
|
|
805
|
-
return {};
|
|
806
|
-
}
|
|
807
|
-
return nsRequire(normalizedId);
|
|
808
|
-
};
|
|
809
|
-
req.resolve = nsRequire.resolve
|
|
810
|
-
? function (id) {
|
|
811
|
-
return nsRequire.resolve(id);
|
|
812
|
-
}
|
|
813
|
-
: function (id) {
|
|
814
|
-
return id;
|
|
815
|
-
};
|
|
816
|
-
return req;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
export default { createRequire };
|
|
820
|
-
`;
|
|
821
617
|
function stripIndexSuffix(specifier) {
|
|
822
618
|
return specifier.replace(/\/(?:(?:index)(?:\.[^.\/]+)?)$/, '');
|
|
823
619
|
}
|