@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.31
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 +51 -11
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +373 -163
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +184 -14
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +5 -72
- package/configuration/javascript.js.map +1 -1
- package/configuration/solid.js +27 -1
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +5 -75
- 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-state.d.ts +8 -0
- package/helpers/app-css-state.js +8 -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/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/dev-host.d.ts +341 -0
- package/helpers/dev-host.js +617 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/esbuild-platform-resolver.js +4 -1
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/global-defines.d.ts +51 -0
- package/helpers/global-defines.js +77 -0
- 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 +0 -18
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +1 -0
- package/helpers/logging.js +63 -3
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +2 -1
- package/helpers/main-entry.js +430 -47
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
- package/helpers/nativeclass-transformer-plugin.js +157 -14
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +8 -3
- 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-url.d.ts +88 -0
- package/helpers/ns-core-url.js +191 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/package-platform-aliases.js +4 -3
- 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/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/ts-config-paths.d.ts +14 -0
- package/helpers/ts-config-paths.js +89 -8
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +2 -1
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/workers.d.ts +20 -19
- package/helpers/workers.js +624 -4
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +1 -0
- package/hmr/client/css-handler.js +33 -20
- 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 +73 -0
- package/hmr/client/framework-client-strategy.js +19 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +27 -0
- package/hmr/client/hmr-pending-overlay.js +50 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/index.js +459 -164
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.d.ts +6 -1
- package/hmr/client/utils.js +184 -8
- package/hmr/client/utils.js.map +1 -1
- package/hmr/entry-runtime.d.ts +2 -1
- package/hmr/entry-runtime.js +252 -65
- 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 +109 -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/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/{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/client/index.d.ts +1 -0
- package/hmr/frameworks/angular/client/index.js +778 -20
- 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/strategy.js +448 -12
- 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 +17 -11
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.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/server/strategy.js +360 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +28 -14
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/index.js +30 -199
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/strategy.d.ts +7 -0
- package/hmr/frameworks/vue/client/strategy.js +83 -0
- package/hmr/frameworks/vue/client/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +706 -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 +457 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +19 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +14 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.js +244 -0
- 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.js +52 -5
- 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/server/constants.js +13 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.d.ts +90 -7
- package/hmr/server/core-sanitize.js +211 -56
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +327 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +95 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +214 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +11 -2
- package/hmr/server/import-map.js +59 -40
- 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/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-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 +35 -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 +195 -0
- package/hmr/server/perf-instrumentation.js.map +1 -0
- package/hmr/server/process-code-for-device.d.ts +15 -0
- package/hmr/server/process-code-for-device.js +654 -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 +604 -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/server-origin.d.ts +12 -0
- package/hmr/server/server-origin.js +66 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.js +12 -5
- package/hmr/server/shared-transform-request.js.map +1 -1
- package/hmr/server/transform-cache-invalidation.d.ts +11 -0
- package/hmr/server/transform-cache-invalidation.js +84 -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.js +60 -42
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +41 -6
- package/hmr/server/websocket-core-bridge.js +72 -75
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-css-hot-update.d.ts +33 -0
- package/hmr/server/websocket-css-hot-update.js +65 -0
- package/hmr/server/websocket-css-hot-update.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 +15 -0
- package/hmr/server/websocket-graph-upsert.js +20 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -1
- package/hmr/server/websocket-hmr-pending.d.ts +37 -0
- package/hmr/server/websocket-hmr-pending.js +55 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-hot-update.d.ts +77 -0
- package/hmr/server/websocket-hot-update.js +330 -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 +46 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.js +3 -3
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +66 -2
- package/hmr/server/websocket-module-specifiers.js +202 -19
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-core.d.ts +21 -0
- package/hmr/server/websocket-ns-core.js +306 -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 +150 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
- package/hmr/server/websocket-ns-m-paths.js +92 -0
- package/hmr/server/websocket-ns-m-paths.js.map +1 -0
- package/hmr/server/websocket-ns-m-request.d.ts +45 -0
- package/hmr/server/websocket-ns-m-request.js +196 -0
- package/hmr/server/websocket-ns-m-request.js.map +1 -0
- package/hmr/server/websocket-ns-m.d.ts +33 -0
- package/hmr/server/websocket-ns-m.js +748 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +39 -0
- package/hmr/server/websocket-served-module-helpers.js +654 -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 +39 -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 +8 -39
- package/hmr/server/websocket.js +602 -6049
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +118 -0
- package/hmr/shared/ns-globals.js +27 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/protocol.d.ts +136 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.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 +40 -0
- package/hmr/shared/runtime/boot-progress.js +128 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
- package/hmr/shared/runtime/boot-timeline.js +52 -0
- package/hmr/shared/runtime/boot-timeline.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.d.ts +75 -26
- package/hmr/shared/runtime/dev-overlay.js +990 -260
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- package/hmr/shared/runtime/module-provenance.js +1 -4
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +310 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.js +352 -194
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +164 -1
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +512 -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 +3 -2
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +1 -7
- package/hmr/shared/vendor/manifest.js +102 -741
- package/hmr/shared/vendor/manifest.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 +16 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -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 +55 -11
- package/runtime/core-aliases-early.js +17 -41
- package/runtime/core-aliases-early.js.map +1 -1
- 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/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 +0 -239
- package/hmr/server/websocket-angular-hot-update.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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single canonical URL generator for `@nativescript/core` under HMR.
|
|
3
|
+
*
|
|
4
|
+
* Every public-facing reference to `@nativescript/core[/sub]` resolves to
|
|
5
|
+
* exactly one URL string — byte-for-byte identical across every emitter
|
|
6
|
+
* (bundle entry, external-urls plugin, rewriter, import map, runtime
|
|
7
|
+
* require). The only valid shapes are:
|
|
8
|
+
*
|
|
9
|
+
* - `/ns/core` — package main
|
|
10
|
+
* - `/ns/core/<sub>` — subpath form
|
|
11
|
+
*
|
|
12
|
+
* with `<sub>` always run through `normalizeCoreSub` (extensionless, no
|
|
13
|
+
* `/index` tail, no platform suffix). There is no version segment, no
|
|
14
|
+
* `?p=` query form, no `.js` tail.
|
|
15
|
+
*
|
|
16
|
+
* This module is the ONE site that constructs those URLs. Every caller in
|
|
17
|
+
* the repo should use `buildCoreUrl()` (or `buildCoreUrlPath()` when origin
|
|
18
|
+
* is not known yet). A single violation of canonical form produces a
|
|
19
|
+
* distinct iOS HTTP ESM cache entry for the same file — re-evaluating the
|
|
20
|
+
* module body, re-running `CssAnimationProperty.register(...)` side
|
|
21
|
+
* effects, and crashing with `Cannot redefine property`.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a user-provided subpath into the canonical form used by the
|
|
25
|
+
* /ns/core bridge. Strips:
|
|
26
|
+
* - Query and hash (`?v=…`, `#…`)
|
|
27
|
+
* - Leading / trailing slashes
|
|
28
|
+
* - Trailing `.js`/`.mjs`/`.cjs` extension (platform-suffixed forms are
|
|
29
|
+
* preserved: `.ios.js` → `.ios`)
|
|
30
|
+
* - Trailing `/index` segment (package-main sibling: `globals/index` →
|
|
31
|
+
* `globals`; `ui/core/view/index` → `ui/core/view`)
|
|
32
|
+
* - Canonical index forms (`index`, `index.js`, empty) → empty string
|
|
33
|
+
*
|
|
34
|
+
* Returns empty string for the main module (`@nativescript/core` itself).
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeCoreSub(sub?: string | null): string;
|
|
37
|
+
/**
|
|
38
|
+
* Canonical PATH (no origin) for a core module.
|
|
39
|
+
* Used by middleware/redirects where we don't have the dev-server origin.
|
|
40
|
+
*
|
|
41
|
+
* '' → '/ns/core'
|
|
42
|
+
* 'application' → '/ns/core/application'
|
|
43
|
+
* 'ui/core/view' → '/ns/core/ui/core/view'
|
|
44
|
+
* 'globals/index' → '/ns/core/globals'
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildCoreUrlPath(sub?: string | null): string;
|
|
47
|
+
/**
|
|
48
|
+
* Canonical FULL URL for a core module.
|
|
49
|
+
*
|
|
50
|
+
* origin='http://localhost:5173', sub='application'
|
|
51
|
+
* → 'http://localhost:5173/ns/core/application'
|
|
52
|
+
*
|
|
53
|
+
* Throws if origin is empty — callers that may not have origin should use
|
|
54
|
+
* `buildCoreUrlPath()` instead.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildCoreUrl(origin: string, sub?: string | null): string;
|
|
57
|
+
/**
|
|
58
|
+
* Detect whether a URL or path references the /ns/core bridge.
|
|
59
|
+
* Accepts both relative `/ns/core/...` and absolute `http(s)://.../ns/core/...`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isCoreBridgeUrl(input: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Extract the canonical sub path from a /ns/core URL.
|
|
64
|
+
* 'http://localhost:5173/ns/core' → ''
|
|
65
|
+
* 'http://localhost:5173/ns/core/application' → 'application'
|
|
66
|
+
* '/ns/core/ui/core/view' → 'ui/core/view'
|
|
67
|
+
* 'http://example.com/other' → null
|
|
68
|
+
*/
|
|
69
|
+
export declare function extractCoreSub(input: string): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Convert a bare `@nativescript/core[/sub]` specifier or an absolute path
|
|
72
|
+
* pointing into `@nativescript/core`'s node_modules install into the
|
|
73
|
+
* canonical sub path. Returns null for anything else.
|
|
74
|
+
*
|
|
75
|
+
* '@nativescript/core' → ''
|
|
76
|
+
* '@nativescript/core/application' → 'application'
|
|
77
|
+
* '/node_modules/@nativescript/core/ui/core/view.js' → 'ui/core/view'
|
|
78
|
+
* '/foo/bar/baz' → null
|
|
79
|
+
*/
|
|
80
|
+
export declare function specToCoreSub(spec: string): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Produce the set of "runtime module id" strings we expose in
|
|
83
|
+
* `globalThis.__NS_CORE_MODULES__` for a given sub. Callers of the vendor
|
|
84
|
+
* CJS shim may request any of these forms for the same module; we register
|
|
85
|
+
* all of them to the one namespace so lookups are never ambiguous.
|
|
86
|
+
*/
|
|
87
|
+
export declare function moduleRegistrationKeys(sub?: string | null): string[];
|
|
88
|
+
export declare const CORE_SCOPE = "@nativescript/core";
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single canonical URL generator for `@nativescript/core` under HMR.
|
|
3
|
+
*
|
|
4
|
+
* Every public-facing reference to `@nativescript/core[/sub]` resolves to
|
|
5
|
+
* exactly one URL string — byte-for-byte identical across every emitter
|
|
6
|
+
* (bundle entry, external-urls plugin, rewriter, import map, runtime
|
|
7
|
+
* require). The only valid shapes are:
|
|
8
|
+
*
|
|
9
|
+
* - `/ns/core` — package main
|
|
10
|
+
* - `/ns/core/<sub>` — subpath form
|
|
11
|
+
*
|
|
12
|
+
* with `<sub>` always run through `normalizeCoreSub` (extensionless, no
|
|
13
|
+
* `/index` tail, no platform suffix). There is no version segment, no
|
|
14
|
+
* `?p=` query form, no `.js` tail.
|
|
15
|
+
*
|
|
16
|
+
* This module is the ONE site that constructs those URLs. Every caller in
|
|
17
|
+
* the repo should use `buildCoreUrl()` (or `buildCoreUrlPath()` when origin
|
|
18
|
+
* is not known yet). A single violation of canonical form produces a
|
|
19
|
+
* distinct iOS HTTP ESM cache entry for the same file — re-evaluating the
|
|
20
|
+
* module body, re-running `CssAnimationProperty.register(...)` side
|
|
21
|
+
* effects, and crashing with `Cannot redefine property`.
|
|
22
|
+
*/
|
|
23
|
+
const CORE_SCOPE_PREFIX = '@nativescript/core';
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a user-provided subpath into the canonical form used by the
|
|
26
|
+
* /ns/core bridge. Strips:
|
|
27
|
+
* - Query and hash (`?v=…`, `#…`)
|
|
28
|
+
* - Leading / trailing slashes
|
|
29
|
+
* - Trailing `.js`/`.mjs`/`.cjs` extension (platform-suffixed forms are
|
|
30
|
+
* preserved: `.ios.js` → `.ios`)
|
|
31
|
+
* - Trailing `/index` segment (package-main sibling: `globals/index` →
|
|
32
|
+
* `globals`; `ui/core/view/index` → `ui/core/view`)
|
|
33
|
+
* - Canonical index forms (`index`, `index.js`, empty) → empty string
|
|
34
|
+
*
|
|
35
|
+
* Returns empty string for the main module (`@nativescript/core` itself).
|
|
36
|
+
*/
|
|
37
|
+
export function normalizeCoreSub(sub) {
|
|
38
|
+
if (!sub)
|
|
39
|
+
return '';
|
|
40
|
+
let s = String(sub).split('?')[0].split('#')[0].trim();
|
|
41
|
+
s = s.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
42
|
+
s = s.replace(/\.(?:mjs|cjs|js)$/, '');
|
|
43
|
+
// Strip a trailing platform suffix (`.ios` / `.android` / `.visionos`)
|
|
44
|
+
// so Vite-resolved platform-specific file paths canonicalize to the
|
|
45
|
+
// same form the runtime import map uses for the bare subpath.
|
|
46
|
+
//
|
|
47
|
+
// Why this matters: when the app source has
|
|
48
|
+
// `import { TextBase } from '@nativescript/core/ui/text-base'`, Vite's
|
|
49
|
+
// alias + extension resolver picks `ui/text-base/index.ios.js`. After
|
|
50
|
+
// `.js` is stripped above we have `ui/text-base/index.ios`. Vendor
|
|
51
|
+
// code, by contrast, takes the bare specifier path: the runtime
|
|
52
|
+
// import map's `@nativescript/core/` prefix maps it to
|
|
53
|
+
// `/ns/core/ui/text-base` directly (no `.ios`). The iOS HTTP ESM
|
|
54
|
+
// loader caches by URL string, so two spellings of the same file
|
|
55
|
+
// would produce two distinct V8 module records, re-evaluate
|
|
56
|
+
// `TextBase`, and create a realm split that leaves the
|
|
57
|
+
// `@nativescript-community` plugin's `setTextDecorationAndTransform`
|
|
58
|
+
// override visible to vendor code but invisible to the app.
|
|
59
|
+
//
|
|
60
|
+
// Stripping the suffix here normalises both shapes — `ui/text-base/`
|
|
61
|
+
// `index.ios` and `runtime/runtime.ios` — to the bare form. The
|
|
62
|
+
// trailing `/index` handler below then collapses
|
|
63
|
+
// `ui/text-base/index` → `ui/text-base`, and the final `index`
|
|
64
|
+
// guard collapses the package-main case to ''.
|
|
65
|
+
s = s.replace(/\.(?:ios|android|visionos)$/, '');
|
|
66
|
+
// Strip trailing `/index` so that `globals/index` → `globals`, matching
|
|
67
|
+
// the bare import form that consumers spell as `@nativescript/core/globals`.
|
|
68
|
+
// The main module case (`index` alone) is handled below.
|
|
69
|
+
if (s.endsWith('/index')) {
|
|
70
|
+
s = s.slice(0, -'/index'.length);
|
|
71
|
+
}
|
|
72
|
+
if (!s || s === 'index')
|
|
73
|
+
return '';
|
|
74
|
+
return s;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Canonical PATH (no origin) for a core module.
|
|
78
|
+
* Used by middleware/redirects where we don't have the dev-server origin.
|
|
79
|
+
*
|
|
80
|
+
* '' → '/ns/core'
|
|
81
|
+
* 'application' → '/ns/core/application'
|
|
82
|
+
* 'ui/core/view' → '/ns/core/ui/core/view'
|
|
83
|
+
* 'globals/index' → '/ns/core/globals'
|
|
84
|
+
*/
|
|
85
|
+
export function buildCoreUrlPath(sub) {
|
|
86
|
+
const s = normalizeCoreSub(sub);
|
|
87
|
+
return s ? `/ns/core/${s}` : '/ns/core';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Canonical FULL URL for a core module.
|
|
91
|
+
*
|
|
92
|
+
* origin='http://localhost:5173', sub='application'
|
|
93
|
+
* → 'http://localhost:5173/ns/core/application'
|
|
94
|
+
*
|
|
95
|
+
* Throws if origin is empty — callers that may not have origin should use
|
|
96
|
+
* `buildCoreUrlPath()` instead.
|
|
97
|
+
*/
|
|
98
|
+
export function buildCoreUrl(origin, sub) {
|
|
99
|
+
if (!origin) {
|
|
100
|
+
throw new Error('[ns-core-url] buildCoreUrl requires a non-empty origin. Use buildCoreUrlPath() when origin is not yet known.');
|
|
101
|
+
}
|
|
102
|
+
const trimmedOrigin = origin.replace(/\/+$/, '');
|
|
103
|
+
return `${trimmedOrigin}${buildCoreUrlPath(sub)}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Detect whether a URL or path references the /ns/core bridge.
|
|
107
|
+
* Accepts both relative `/ns/core/...` and absolute `http(s)://.../ns/core/...`.
|
|
108
|
+
*/
|
|
109
|
+
export function isCoreBridgeUrl(input) {
|
|
110
|
+
if (!input)
|
|
111
|
+
return false;
|
|
112
|
+
return /\/ns\/core(?:\/|$)/.test(input);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Extract the canonical sub path from a /ns/core URL.
|
|
116
|
+
* 'http://localhost:5173/ns/core' → ''
|
|
117
|
+
* 'http://localhost:5173/ns/core/application' → 'application'
|
|
118
|
+
* '/ns/core/ui/core/view' → 'ui/core/view'
|
|
119
|
+
* 'http://example.com/other' → null
|
|
120
|
+
*/
|
|
121
|
+
export function extractCoreSub(input) {
|
|
122
|
+
if (!isCoreBridgeUrl(input))
|
|
123
|
+
return null;
|
|
124
|
+
try {
|
|
125
|
+
const u = new URL(input, 'http://placeholder.invalid');
|
|
126
|
+
const pathname = u.pathname;
|
|
127
|
+
const afterCore = pathname.replace(/^.*\/ns\/core(?:\/|$)/, '');
|
|
128
|
+
return normalizeCoreSub(afterCore);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
const m = input.match(/\/ns\/core(?:\/([^?#]*))?/);
|
|
132
|
+
if (!m)
|
|
133
|
+
return null;
|
|
134
|
+
return normalizeCoreSub(m[1] || '');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Convert a bare `@nativescript/core[/sub]` specifier or an absolute path
|
|
139
|
+
* pointing into `@nativescript/core`'s node_modules install into the
|
|
140
|
+
* canonical sub path. Returns null for anything else.
|
|
141
|
+
*
|
|
142
|
+
* '@nativescript/core' → ''
|
|
143
|
+
* '@nativescript/core/application' → 'application'
|
|
144
|
+
* '/node_modules/@nativescript/core/ui/core/view.js' → 'ui/core/view'
|
|
145
|
+
* '/foo/bar/baz' → null
|
|
146
|
+
*/
|
|
147
|
+
export function specToCoreSub(spec) {
|
|
148
|
+
if (!spec)
|
|
149
|
+
return null;
|
|
150
|
+
const cleaned = spec.split('?')[0].split('#')[0];
|
|
151
|
+
if (cleaned === CORE_SCOPE_PREFIX)
|
|
152
|
+
return '';
|
|
153
|
+
if (cleaned.startsWith(CORE_SCOPE_PREFIX + '/')) {
|
|
154
|
+
return normalizeCoreSub(cleaned.slice(CORE_SCOPE_PREFIX.length + 1));
|
|
155
|
+
}
|
|
156
|
+
const abs = cleaned.replace(/\\/g, '/').match(/\/node_modules\/@nativescript\/core\/(.+?)$/);
|
|
157
|
+
if (abs)
|
|
158
|
+
return normalizeCoreSub(abs[1]);
|
|
159
|
+
// Case: the path ENDS at the core root (no subpath).
|
|
160
|
+
if (/\/node_modules\/@nativescript\/core\/?$/.test(cleaned.replace(/\\/g, '/'))) {
|
|
161
|
+
return '';
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Produce the set of "runtime module id" strings we expose in
|
|
167
|
+
* `globalThis.__NS_CORE_MODULES__` for a given sub. Callers of the vendor
|
|
168
|
+
* CJS shim may request any of these forms for the same module; we register
|
|
169
|
+
* all of them to the one namespace so lookups are never ambiguous.
|
|
170
|
+
*/
|
|
171
|
+
export function moduleRegistrationKeys(sub) {
|
|
172
|
+
const s = normalizeCoreSub(sub);
|
|
173
|
+
const keys = new Set();
|
|
174
|
+
if (!s) {
|
|
175
|
+
keys.add(CORE_SCOPE_PREFIX);
|
|
176
|
+
keys.add('');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
keys.add(`${CORE_SCOPE_PREFIX}/${s}`);
|
|
180
|
+
keys.add(s);
|
|
181
|
+
// Tolerate `.js` tail on the key (some consumers spell it out).
|
|
182
|
+
keys.add(`${CORE_SCOPE_PREFIX}/${s}.js`);
|
|
183
|
+
keys.add(`${s}.js`);
|
|
184
|
+
// Tolerate `/index` / `/index.js` suffix.
|
|
185
|
+
keys.add(`${CORE_SCOPE_PREFIX}/${s}/index`);
|
|
186
|
+
keys.add(`${CORE_SCOPE_PREFIX}/${s}/index.js`);
|
|
187
|
+
}
|
|
188
|
+
return Array.from(keys);
|
|
189
|
+
}
|
|
190
|
+
export const CORE_SCOPE = CORE_SCOPE_PREFIX;
|
|
191
|
+
//# sourceMappingURL=ns-core-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ns-core-url.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/ns-core-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAmB;IACnD,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACvC,uEAAuE;IACvE,oEAAoE;IACpE,8DAA8D;IAC9D,EAAE;IACF,4CAA4C;IAC5C,uEAAuE;IACvE,sEAAsE;IACtE,mEAAmE;IACnE,gEAAgE;IAChE,uDAAuD;IACvD,iEAAiE;IACjE,iEAAiE;IACjE,4DAA4D;IAC5D,uDAAuD;IACvD,qEAAqE;IACrE,4DAA4D;IAC5D,EAAE;IACF,qEAAqE;IACrE,gEAAgE;IAChE,iDAAiD;IACjD,+DAA+D;IAC/D,+CAA+C;IAC/C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IACjD,wEAAwE;IACxE,6EAA6E;IAC7E,yDAAyD;IACzD,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,CAAC,GAAG,CAAC,CAAC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,GAAG,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,CAAC,CAAC,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;SAAM,CAAC;QACP,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACZ,gEAAgE;QAChE,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpB,0CAA0C;QAC1C,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { findPackageInNodeModules } from './module-resolution.js';
|
|
4
4
|
import { getProjectRootPath } from './project.js';
|
|
5
|
+
import { normalizeModuleId } from './normalize-id.js';
|
|
5
6
|
const projectRoot = getProjectRootPath();
|
|
6
7
|
export function packagePlatformResolverPlugin(opts) {
|
|
7
8
|
// packages used via core transient dependencies and other vite support
|
|
@@ -41,7 +42,7 @@ export function packagePlatformResolverPlugin(opts) {
|
|
|
41
42
|
if (opts.verbose) {
|
|
42
43
|
console.log(`✅ Alias resolver: ${packageName} -> ${mainField}.${opts.platform}.js (extensionless)`);
|
|
43
44
|
}
|
|
44
|
-
return platformFile;
|
|
45
|
+
return normalizeModuleId(platformFile);
|
|
45
46
|
}
|
|
46
47
|
// Fallback to .js
|
|
47
48
|
const jsFile = path.join(packagePath, `${mainField}.js`);
|
|
@@ -49,7 +50,7 @@ export function packagePlatformResolverPlugin(opts) {
|
|
|
49
50
|
if (opts.verbose) {
|
|
50
51
|
console.log(`✅ Alias resolver: ${packageName} -> ${mainField}.js (extensionless)`);
|
|
51
52
|
}
|
|
52
|
-
return jsFile;
|
|
53
|
+
return normalizeModuleId(jsFile);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
// Case 2: Main field has extension but file doesn't exist - look for platform variants
|
|
@@ -63,7 +64,7 @@ export function packagePlatformResolverPlugin(opts) {
|
|
|
63
64
|
if (opts.verbose) {
|
|
64
65
|
console.log(`✅ Alias resolver: ${packageName} -> ${baseName}.${opts.platform}${ext} (missing main)`);
|
|
65
66
|
}
|
|
66
|
-
return platformFile;
|
|
67
|
+
return normalizeModuleId(platformFile);
|
|
67
68
|
}
|
|
68
69
|
// If main file exists, let normal resolution handle it
|
|
69
70
|
// If it doesn't exist and no platform variant found, let it fail naturally
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-platform-aliases.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/package-platform-aliases.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"package-platform-aliases.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/package-platform-aliases.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CA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G,CAAC,MAAM,CAAC,CAAC;gCAEjD,mCAAmC;gCACnC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAC;gCAClF,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;oCACjC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;wCAClB,OAAO,CAAC,GAAG,CAAC,qBAAqB,WAAW,OAAO,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,iBAAiB,CAAC,CAAC;oCACtG,CAAC;oCACD,OAAO,iBAAiB,CAAC,YAAY,CAAC,CAAC;gCACxC,CAAC;gCAED,uDAAuD;gCACvD,2EAA2E;4BAC5E,CAAC;wBACF,CAAC;oBACF,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACZ,uCAAuC;oBACxC,CAAC;gBACF,CAAC;YACF,CAAC;YAED,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-types.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/platform-types.ts"],"names":[],"mappings":""}
|
package/helpers/project.d.ts
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
export declare function getProjectRootPath(): string;
|
|
2
|
+
/**
|
|
3
|
+
* Walk up from `start` looking for the nearest monorepo workspace root.
|
|
4
|
+
*
|
|
5
|
+
* Returns the absolute path of the workspace root, or `null` if none of
|
|
6
|
+
* the supported markers are found before reaching the filesystem root. The
|
|
7
|
+
* search returns the FIRST matching ancestor — so a deeply nested app dir
|
|
8
|
+
* inside an Nx monorepo that happens to also live inside a parent pnpm
|
|
9
|
+
* workspace returns the Nx root (closer to the app) rather than the outer
|
|
10
|
+
* pnpm one. This matches Vite's own `searchForWorkspaceRoot` behaviour.
|
|
11
|
+
*
|
|
12
|
+
* Recognized markers (see {@link MONOREPO_WORKSPACE_MARKERS}):
|
|
13
|
+
* - `pnpm-workspace.yaml` / `pnpm-workspace.yml`
|
|
14
|
+
* - `lerna.json`
|
|
15
|
+
* - `nx.json` (Nx)
|
|
16
|
+
* - `rush.json` (Rush)
|
|
17
|
+
* - `turbo.json` (Turborepo)
|
|
18
|
+
* - `deno.json` / `deno.jsonc` containing a `workspace` field
|
|
19
|
+
* - `package.json` containing a `workspaces` field (npm/yarn workspaces)
|
|
20
|
+
*/
|
|
21
|
+
export declare function findMonorepoWorkspaceRoot(start?: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Memoized variant of {@link findMonorepoWorkspaceRoot}.
|
|
24
|
+
*
|
|
25
|
+
* The dev server resolves hoisted `node_modules/<pkg>/...` candidates on
|
|
26
|
+
* every `/ns/m/` request, and each lookup walks the directory tree once
|
|
27
|
+
* doing `existsSync` calls. Since the workspace layout doesn't change at
|
|
28
|
+
* runtime, the result is safe to cache per `start` directory for the
|
|
29
|
+
* lifetime of the dev server process.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getMonorepoWorkspaceRoot(start?: string): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Clear the {@link getMonorepoWorkspaceRoot} memoization cache. Intended
|
|
34
|
+
* for tests that mutate the filesystem inside a temp dir between calls.
|
|
35
|
+
*/
|
|
36
|
+
export declare function clearMonorepoWorkspaceRootCache(): void;
|
|
2
37
|
export declare const __dirname: string;
|
|
3
38
|
interface IPackageJson {
|
|
4
39
|
name?: string;
|
package/helpers/project.js
CHANGED
|
@@ -1,10 +1,128 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
|
-
import { resolve } from 'path';
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
5
|
export function getProjectRootPath() {
|
|
6
6
|
return process.cwd();
|
|
7
7
|
}
|
|
8
|
+
// Markers that indicate the directory is a monorepo workspace root. Vite's
|
|
9
|
+
// own `searchForWorkspaceRoot` only knows about pnpm/lerna/yarn|npm
|
|
10
|
+
// `workspaces` and Deno; this list extends it to cover popular JS/TS
|
|
11
|
+
// monorepo tools (Nx, Rush, Turborepo) and any future tool by simply adding
|
|
12
|
+
// a marker file name. The order doesn't matter — we return the first
|
|
13
|
+
// ancestor that has any one of them.
|
|
14
|
+
//
|
|
15
|
+
// Why this matters: when an app lives at `apps/<name>/` inside a monorepo,
|
|
16
|
+
// `process.cwd()` (and therefore Vite's `config.root`) is the app dir. The
|
|
17
|
+
// hoisted `node_modules/` is at the workspace root. If Vite's default
|
|
18
|
+
// `fs.allow` doesn't reach that high, every transform-time fs read of a
|
|
19
|
+
// hoisted package fails with `Failed to load url … Does the file exist?`
|
|
20
|
+
// even though the file is right there on disk. The fix is to widen
|
|
21
|
+
// `server.fs.allow` to the detected workspace root.
|
|
22
|
+
const MONOREPO_WORKSPACE_MARKERS = [
|
|
23
|
+
// Standard JS package-manager workspace files (pnpm/yarn-classic/lerna).
|
|
24
|
+
'pnpm-workspace.yaml',
|
|
25
|
+
'pnpm-workspace.yml',
|
|
26
|
+
'lerna.json',
|
|
27
|
+
// Build orchestrators that are monorepo-by-design.
|
|
28
|
+
'nx.json',
|
|
29
|
+
'rush.json',
|
|
30
|
+
'turbo.json',
|
|
31
|
+
// Deno workspaces.
|
|
32
|
+
'deno.json',
|
|
33
|
+
'deno.jsonc',
|
|
34
|
+
];
|
|
35
|
+
function packageJsonHasWorkspaces(dir) {
|
|
36
|
+
const pkgPath = join(dir, 'package.json');
|
|
37
|
+
if (!existsSync(pkgPath))
|
|
38
|
+
return false;
|
|
39
|
+
try {
|
|
40
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
41
|
+
return !!(pkg && pkg.workspaces);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function denoConfigHasWorkspace(dir) {
|
|
48
|
+
for (const name of ['deno.json', 'deno.jsonc']) {
|
|
49
|
+
const p = join(dir, name);
|
|
50
|
+
if (!existsSync(p))
|
|
51
|
+
continue;
|
|
52
|
+
try {
|
|
53
|
+
const cfg = JSON.parse(readFileSync(p, 'utf-8'));
|
|
54
|
+
if (cfg && cfg.workspace)
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
catch { }
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Walk up from `start` looking for the nearest monorepo workspace root.
|
|
63
|
+
*
|
|
64
|
+
* Returns the absolute path of the workspace root, or `null` if none of
|
|
65
|
+
* the supported markers are found before reaching the filesystem root. The
|
|
66
|
+
* search returns the FIRST matching ancestor — so a deeply nested app dir
|
|
67
|
+
* inside an Nx monorepo that happens to also live inside a parent pnpm
|
|
68
|
+
* workspace returns the Nx root (closer to the app) rather than the outer
|
|
69
|
+
* pnpm one. This matches Vite's own `searchForWorkspaceRoot` behaviour.
|
|
70
|
+
*
|
|
71
|
+
* Recognized markers (see {@link MONOREPO_WORKSPACE_MARKERS}):
|
|
72
|
+
* - `pnpm-workspace.yaml` / `pnpm-workspace.yml`
|
|
73
|
+
* - `lerna.json`
|
|
74
|
+
* - `nx.json` (Nx)
|
|
75
|
+
* - `rush.json` (Rush)
|
|
76
|
+
* - `turbo.json` (Turborepo)
|
|
77
|
+
* - `deno.json` / `deno.jsonc` containing a `workspace` field
|
|
78
|
+
* - `package.json` containing a `workspaces` field (npm/yarn workspaces)
|
|
79
|
+
*/
|
|
80
|
+
export function findMonorepoWorkspaceRoot(start = getProjectRootPath()) {
|
|
81
|
+
let current = resolve(start);
|
|
82
|
+
while (true) {
|
|
83
|
+
for (const marker of MONOREPO_WORKSPACE_MARKERS) {
|
|
84
|
+
if (marker.startsWith('deno.')) {
|
|
85
|
+
if (denoConfigHasWorkspace(current))
|
|
86
|
+
return current;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (existsSync(join(current, marker)))
|
|
90
|
+
return current;
|
|
91
|
+
}
|
|
92
|
+
if (packageJsonHasWorkspaces(current))
|
|
93
|
+
return current;
|
|
94
|
+
const parent = dirname(current);
|
|
95
|
+
if (!parent || parent === current)
|
|
96
|
+
return null;
|
|
97
|
+
current = parent;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const monorepoWorkspaceRootCache = new Map();
|
|
101
|
+
/**
|
|
102
|
+
* Memoized variant of {@link findMonorepoWorkspaceRoot}.
|
|
103
|
+
*
|
|
104
|
+
* The dev server resolves hoisted `node_modules/<pkg>/...` candidates on
|
|
105
|
+
* every `/ns/m/` request, and each lookup walks the directory tree once
|
|
106
|
+
* doing `existsSync` calls. Since the workspace layout doesn't change at
|
|
107
|
+
* runtime, the result is safe to cache per `start` directory for the
|
|
108
|
+
* lifetime of the dev server process.
|
|
109
|
+
*/
|
|
110
|
+
export function getMonorepoWorkspaceRoot(start = getProjectRootPath()) {
|
|
111
|
+
const key = resolve(start);
|
|
112
|
+
if (monorepoWorkspaceRootCache.has(key)) {
|
|
113
|
+
return monorepoWorkspaceRootCache.get(key) ?? null;
|
|
114
|
+
}
|
|
115
|
+
const result = findMonorepoWorkspaceRoot(key);
|
|
116
|
+
monorepoWorkspaceRootCache.set(key, result);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Clear the {@link getMonorepoWorkspaceRoot} memoization cache. Intended
|
|
121
|
+
* for tests that mutate the filesystem inside a temp dir between calls.
|
|
122
|
+
*/
|
|
123
|
+
export function clearMonorepoWorkspaceRootCache() {
|
|
124
|
+
monorepoWorkspaceRootCache.clear();
|
|
125
|
+
}
|
|
8
126
|
// Get current directory for ES modules (equivalent to __dirname)
|
|
9
127
|
export const __dirname = import.meta.dirname;
|
|
10
128
|
/**
|
package/helpers/project.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,UAAU,kBAAkB;IACjC,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,2EAA2E;AAC3E,oEAAoE;AACpE,qEAAqE;AACrE,4EAA4E;AAC5E,qEAAqE;AACrE,qCAAqC;AACrC,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AACtE,wEAAwE;AACxE,yEAAyE;AACzE,mEAAmE;AACnE,oDAAoD;AACpD,MAAM,0BAA0B,GAAG;IAClC,yEAAyE;IACzE,qBAAqB;IACrB,oBAAoB;IACpB,YAAY;IACZ,mDAAmD;IACnD,SAAS;IACT,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,YAAY;CACZ,CAAC;AAEF,SAAS,wBAAwB,CAAC,GAAW;IAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAC1C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACvD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helpers/resolver.js
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { resolveNativeScriptPlatformFile } from './utils.js';
|
|
3
|
+
import { normalizeModuleId } from './normalize-id.js';
|
|
4
|
+
const normalizeImporterId = (importer) => {
|
|
5
|
+
const cleanImporter = importer.split('?', 1)[0];
|
|
6
|
+
if (!cleanImporter.startsWith('/@fs/')) {
|
|
7
|
+
return cleanImporter;
|
|
8
|
+
}
|
|
9
|
+
return /^\/\@fs\/[A-Za-z]:/.test(cleanImporter) ? cleanImporter.slice('/@fs/'.length) : cleanImporter.slice('/@fs'.length);
|
|
10
|
+
};
|
|
3
11
|
export default function NativeScriptPlugin(options) {
|
|
4
12
|
return {
|
|
5
13
|
name: 'vite:nativescript',
|
|
14
|
+
enforce: 'pre',
|
|
6
15
|
resolveId(source, importer) {
|
|
7
16
|
const platform = options.platform;
|
|
8
17
|
if (!platform || !importer || source.startsWith('.') === false) {
|
|
9
18
|
return null;
|
|
10
19
|
}
|
|
11
|
-
const resolved = path.resolve(path.dirname(importer), source);
|
|
20
|
+
const resolved = path.resolve(path.dirname(normalizeImporterId(importer)), source);
|
|
12
21
|
const extVariants = ['.ts', '.js'];
|
|
13
22
|
for (const ext of extVariants) {
|
|
14
23
|
const file = resolveNativeScriptPlatformFile(resolved + ext, platform);
|
|
15
24
|
if (file) {
|
|
16
|
-
|
|
25
|
+
// Canonicalize before handing the id to Rolldown. `path.resolve`
|
|
26
|
+
// emits backslashes on Windows; the @nativescript/core alias and
|
|
27
|
+
// Vite's own resolver emit forward slashes. Returning the raw
|
|
28
|
+
// backslash form here makes Rolldown treat the same core file as a
|
|
29
|
+
// second module, double-evaluating widthProperty.register. No-op on
|
|
30
|
+
// POSIX. See normalize-id.ts for the full rationale.
|
|
31
|
+
return normalizeModuleId(file);
|
|
17
32
|
}
|
|
18
33
|
}
|
|
19
34
|
return null;
|
package/helpers/resolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/resolver.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/resolver.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,mBAAmB,GAAG,CAAC,QAAgB,EAAU,EAAE;IACxD,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhD,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED,OAAO,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5H,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,OAAqD;IAC/F,OAAO;QACN,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,KAAK;QAEd,SAAS,CAAC,MAAM,EAAE,QAAQ;YACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YAClC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;gBAChE,OAAO,IAAI,CAAC;YACb,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YACnF,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEnC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;gBAC/B,MAAM,IAAI,GAAG,+BAA+B,CAAC,QAAQ,GAAG,GAAG,EAAE,QAAQ,CAAC,CAAC;gBACvE,IAAI,IAAI,EAAE,CAAC;oBACV,iEAAiE;oBACjE,iEAAiE;oBACjE,8DAA8D;oBAC9D,mEAAmE;oBACnE,oEAAoE;oBACpE,qDAAqD;oBACrD,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAChC,CAAC;YACF,CAAC;YAED,OAAO,IAAI,CAAC;QACb,CAAC;QAED,SAAS,CAAC,IAAI,EAAE,EAAE;YACjB,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,+EAA+E;gBAC/E,OAAO;oBACN,IAAI;oBACJ,GAAG,EAAE,IAAI;iBACT,CAAC;YACH,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Absolute directory roots that the project's tsconfig `paths` aliases point at.
|
|
4
|
+
*
|
|
5
|
+
* Used to scope HMR to configured shared libraries in a monorepo: a file only
|
|
6
|
+
* triggers an update if it lives under the app source dir or one of these
|
|
7
|
+
* alias roots. When an alias targets a file (e.g. `@org/lib -> libs/lib/src/index.ts`)
|
|
8
|
+
* the file's directory is returned so sibling source files in that library are
|
|
9
|
+
* also in scope. Wildcard aliases (`@org/* -> libs/*`) contribute their resolved
|
|
10
|
+
* base directory (`libs`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTsConfigAliasRoots(opts: {
|
|
13
|
+
paths?: Record<string, string[]>;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
}): string[];
|
|
2
16
|
export declare function createTsConfigPathsResolver(opts: {
|
|
3
17
|
paths: Record<string, string[]>;
|
|
4
18
|
baseUrl: string;
|