@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,396 @@
|
|
|
1
|
+
// Static export-surface enumerator for the single-realm HTTP-ESM bridge.
|
|
2
|
+
//
|
|
3
|
+
// The HMR runtime serves canonical bridge specifiers (e.g. `/ns/rt` for
|
|
4
|
+
// `nativescript-vue`) that fan out to the device's vendor registry so that
|
|
5
|
+
// app code, plugins, and the vendor bundle itself share one module record
|
|
6
|
+
// per package. The bridge module must therefore re-export every public
|
|
7
|
+
// symbol the underlying package offers — otherwise consumers fall back to
|
|
8
|
+
// `undefined` for any export the bridge author forgot to enumerate, and the
|
|
9
|
+
// failure only surfaces at the call site (often deep inside a UI event
|
|
10
|
+
// handler) as `TypeError: <name> is not a function`.
|
|
11
|
+
//
|
|
12
|
+
// Hand-curated re-export lists are the source of that bug class. This
|
|
13
|
+
// helper replaces them with a deterministic walk of the package's static
|
|
14
|
+
// ESM export graph:
|
|
15
|
+
//
|
|
16
|
+
// 1. Resolve the package's `main` entry from the project's `node_modules`.
|
|
17
|
+
// 2. Parse with Babel and collect every named export — both inline
|
|
18
|
+
// (`export const x = …`, `export function y() {}`, `export { z }`) and
|
|
19
|
+
// re-exported (`export { a, b as c } from './foo'`).
|
|
20
|
+
// 3. Recurse into `export * from <spec>`, following both relative paths
|
|
21
|
+
// and bare package specifiers (so `export * from '@vue/runtime-core'`
|
|
22
|
+
// contributes the full Vue runtime API too).
|
|
23
|
+
// 4. Cache the result by `${projectRoot}::${packageId}` — the walk
|
|
24
|
+
// touches dozens of files for `nativescript-vue` and we want one walk
|
|
25
|
+
// per dev session, not per request.
|
|
26
|
+
//
|
|
27
|
+
// The walker is intentionally permissive: parse errors and unresolvable
|
|
28
|
+
// specifiers are swallowed (continue with what we have). The caller decides
|
|
29
|
+
// what to do if the surface comes back empty (typically: fall back to a
|
|
30
|
+
// known-good baseline list rather than emit a stub bridge).
|
|
31
|
+
import { parse as babelParse } from '@babel/parser';
|
|
32
|
+
import { readFileSync, existsSync, realpathSync } from 'fs';
|
|
33
|
+
import path from 'path';
|
|
34
|
+
import { createRequire } from 'node:module';
|
|
35
|
+
const cache = new Map();
|
|
36
|
+
/**
|
|
37
|
+
* Clear the cache. Tests use this to assert determinism; production code
|
|
38
|
+
* never needs it (the cache is intentionally process-lifetime).
|
|
39
|
+
*/
|
|
40
|
+
export function __clearPackageExportsCache() {
|
|
41
|
+
cache.clear();
|
|
42
|
+
}
|
|
43
|
+
export function enumeratePackageExports(packageId, projectRoot) {
|
|
44
|
+
const root = path.resolve(projectRoot || process.cwd());
|
|
45
|
+
const cacheKey = `${root}::${packageId}`;
|
|
46
|
+
const cached = cache.get(cacheKey);
|
|
47
|
+
if (cached)
|
|
48
|
+
return cached;
|
|
49
|
+
const result = {
|
|
50
|
+
names: new Set(),
|
|
51
|
+
hasDefault: false,
|
|
52
|
+
entry: '',
|
|
53
|
+
visitedFiles: [],
|
|
54
|
+
};
|
|
55
|
+
const rootRequire = createRequireFromDir(root);
|
|
56
|
+
const entry = resolvePackageEsmEntry(packageId, rootRequire);
|
|
57
|
+
if (!entry) {
|
|
58
|
+
cache.set(cacheKey, result);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
result.entry = entry;
|
|
62
|
+
const visited = new Set();
|
|
63
|
+
const queue = [entry];
|
|
64
|
+
while (queue.length) {
|
|
65
|
+
const file = queue.shift();
|
|
66
|
+
const real = safeRealpath(file);
|
|
67
|
+
if (visited.has(real))
|
|
68
|
+
continue;
|
|
69
|
+
visited.add(real);
|
|
70
|
+
result.visitedFiles.push(real);
|
|
71
|
+
const source = readFileSafe(real);
|
|
72
|
+
if (source === null)
|
|
73
|
+
continue;
|
|
74
|
+
const program = parseModule(source);
|
|
75
|
+
if (!program)
|
|
76
|
+
continue;
|
|
77
|
+
const dir = path.dirname(real);
|
|
78
|
+
const localRequire = createRequireFromFile(real);
|
|
79
|
+
for (const node of program.body) {
|
|
80
|
+
collectExportsFromNode(node, result, (spec) => {
|
|
81
|
+
const next = resolveSpec(spec, dir, localRequire);
|
|
82
|
+
if (next)
|
|
83
|
+
queue.push(next);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
cache.set(cacheKey, result);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
function collectExportsFromNode(node, out, queueReExportSource) {
|
|
91
|
+
if (node.type === 'ExportNamedDeclaration') {
|
|
92
|
+
// `export const x = …`, `export function y() {}`, `export class Z {}`
|
|
93
|
+
const decl = node.declaration;
|
|
94
|
+
if (decl) {
|
|
95
|
+
if (decl.declarations) {
|
|
96
|
+
for (const d of decl.declarations) {
|
|
97
|
+
addId(out.names, d?.id);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (decl.id?.name) {
|
|
101
|
+
out.names.add(decl.id.name);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// `export { a, b as c }` and `export { a } from './foo'`
|
|
105
|
+
for (const spec of (node.specifiers || [])) {
|
|
106
|
+
const exportedName = spec?.exported?.name ?? spec?.exported?.value;
|
|
107
|
+
if (exportedName === 'default') {
|
|
108
|
+
out.hasDefault = true;
|
|
109
|
+
}
|
|
110
|
+
else if (exportedName) {
|
|
111
|
+
out.names.add(String(exportedName));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// `export … from <source>` — we already captured the explicit names above,
|
|
115
|
+
// but we still need to recurse if there's a `*` re-export hiding inside
|
|
116
|
+
// (Babel models that as `ExportAllDeclaration`, handled below). Nothing to do here.
|
|
117
|
+
}
|
|
118
|
+
else if (node.type === 'ExportAllDeclaration') {
|
|
119
|
+
// `export * from <source>` — recurse.
|
|
120
|
+
// `export * as ns from <source>` adds a named binding `ns` instead of fanning out.
|
|
121
|
+
const src = node.source?.value;
|
|
122
|
+
const asName = node.exported?.name;
|
|
123
|
+
if (asName) {
|
|
124
|
+
if (asName !== 'default')
|
|
125
|
+
out.names.add(String(asName));
|
|
126
|
+
}
|
|
127
|
+
else if (src) {
|
|
128
|
+
queueReExportSource(src);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (node.type === 'ExportDefaultDeclaration') {
|
|
132
|
+
out.hasDefault = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function addId(names, idNode) {
|
|
136
|
+
if (!idNode)
|
|
137
|
+
return;
|
|
138
|
+
if (idNode.type === 'Identifier' && idNode.name) {
|
|
139
|
+
names.add(idNode.name);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (idNode.type === 'ObjectPattern') {
|
|
143
|
+
for (const prop of idNode.properties || []) {
|
|
144
|
+
if (prop.type === 'ObjectProperty')
|
|
145
|
+
addId(names, prop.value);
|
|
146
|
+
else if (prop.type === 'RestElement')
|
|
147
|
+
addId(names, prop.argument);
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (idNode.type === 'ArrayPattern') {
|
|
152
|
+
for (const el of idNode.elements || [])
|
|
153
|
+
addId(names, el);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (idNode.type === 'AssignmentPattern') {
|
|
157
|
+
addId(names, idNode.left);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function parseModule(source) {
|
|
161
|
+
try {
|
|
162
|
+
const ast = babelParse(source, {
|
|
163
|
+
sourceType: 'module',
|
|
164
|
+
plugins: ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'decorators-legacy', 'classProperties', 'classPrivateProperties', 'classPrivateMethods'],
|
|
165
|
+
errorRecovery: true,
|
|
166
|
+
allowReturnOutsideFunction: true,
|
|
167
|
+
allowUndeclaredExports: true,
|
|
168
|
+
});
|
|
169
|
+
return ast.program;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function resolveSpec(spec, dir, localRequire) {
|
|
176
|
+
if (!spec)
|
|
177
|
+
return null;
|
|
178
|
+
if (spec.startsWith('.')) {
|
|
179
|
+
return resolveRelative(dir, spec);
|
|
180
|
+
}
|
|
181
|
+
if (spec.startsWith('/')) {
|
|
182
|
+
return existsSync(spec) ? spec : null;
|
|
183
|
+
}
|
|
184
|
+
// Bare specifier (e.g. `@vue/runtime-core` from inside `nativescript-vue`).
|
|
185
|
+
// `createRequire.resolve()` is CJS-first and follows the package's `main`
|
|
186
|
+
// field, which for dual-format packages like `@vue/runtime-core` points at
|
|
187
|
+
// a CommonJS shim (`module.exports = require('./dist/…cjs.js')`) — parsing
|
|
188
|
+
// that as ESM yields zero exports and we silently drop the entire
|
|
189
|
+
// re-export chain. Use the ESM-aware resolver instead so we land on the
|
|
190
|
+
// actual `dist/…esm-bundler.js` advertised by `exports[".module"]` /
|
|
191
|
+
// `module`, where `export { ref, computed, … }` lives.
|
|
192
|
+
if (localRequire) {
|
|
193
|
+
return resolvePackageEsmEntry(spec, localRequire);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Resolve a bare specifier to its ESM entry file by consulting the package's
|
|
199
|
+
* own `package.json` ESM hints — in priority order:
|
|
200
|
+
*
|
|
201
|
+
* 1. `exports[<sub>].module` (Vue, modern dual-format packages)
|
|
202
|
+
* 2. `exports[<sub>].import`
|
|
203
|
+
* 3. `exports[<sub>]` shorthand (string form)
|
|
204
|
+
* 4. top-level `module` field (older dual-format convention)
|
|
205
|
+
* 5. top-level `main` (last resort; may be CJS — we'll parse what we get)
|
|
206
|
+
*
|
|
207
|
+
* `<sub>` is either `"."` (root entry) or `"./relative/subpath"`. Anything not
|
|
208
|
+
* declared in `exports` falls back to plain CJS resolution.
|
|
209
|
+
*
|
|
210
|
+
* Returns the absolute file path, or `null` if the package can't be located.
|
|
211
|
+
*/
|
|
212
|
+
function resolvePackageEsmEntry(spec, localRequire) {
|
|
213
|
+
const { packageName, subpath } = splitBareSpec(spec);
|
|
214
|
+
if (!packageName)
|
|
215
|
+
return null;
|
|
216
|
+
// Locate the package's `package.json` from the calling file's vantage point.
|
|
217
|
+
// Node ≥ 18.6 has `require.resolve('<pkg>/package.json')` working for almost
|
|
218
|
+
// every layout (including pnpm hoisted/nested), provided the package
|
|
219
|
+
// declares `package.json` reachable (it is, by default). If the package
|
|
220
|
+
// opts out of exposing it via `exports`, fall back to walking up from any
|
|
221
|
+
// resolvable entry.
|
|
222
|
+
let pkgJsonPath = safeResolve(localRequire, `${packageName}/package.json`);
|
|
223
|
+
if (!pkgJsonPath) {
|
|
224
|
+
const someEntry = safeResolve(localRequire, spec);
|
|
225
|
+
if (someEntry)
|
|
226
|
+
pkgJsonPath = findPackageJsonUpward(someEntry, packageName);
|
|
227
|
+
}
|
|
228
|
+
if (!pkgJsonPath)
|
|
229
|
+
return null;
|
|
230
|
+
const pkgDir = path.dirname(pkgJsonPath);
|
|
231
|
+
const pkg = readJsonSafe(pkgJsonPath);
|
|
232
|
+
if (!pkg)
|
|
233
|
+
return null;
|
|
234
|
+
const subKey = subpath ? `./${subpath}` : '.';
|
|
235
|
+
const esmRelative = pickEsmEntryFromManifest(pkg, subKey);
|
|
236
|
+
if (esmRelative) {
|
|
237
|
+
const resolved = resolveRelativeInsidePackage(pkgDir, esmRelative);
|
|
238
|
+
if (resolved)
|
|
239
|
+
return resolved;
|
|
240
|
+
}
|
|
241
|
+
// Last-resort fallback: ordinary CJS resolution. Parsing may yield zero
|
|
242
|
+
// exports (the file is genuinely CJS) — that's acceptable; the caller
|
|
243
|
+
// treats an empty contribution as "this package adds nothing" rather than
|
|
244
|
+
// erroring out.
|
|
245
|
+
return safeResolve(localRequire, spec);
|
|
246
|
+
}
|
|
247
|
+
function splitBareSpec(spec) {
|
|
248
|
+
if (spec.startsWith('@')) {
|
|
249
|
+
const parts = spec.split('/');
|
|
250
|
+
if (parts.length < 2)
|
|
251
|
+
return { packageName: '', subpath: '' };
|
|
252
|
+
return { packageName: `${parts[0]}/${parts[1]}`, subpath: parts.slice(2).join('/') };
|
|
253
|
+
}
|
|
254
|
+
const slash = spec.indexOf('/');
|
|
255
|
+
if (slash === -1)
|
|
256
|
+
return { packageName: spec, subpath: '' };
|
|
257
|
+
return { packageName: spec.slice(0, slash), subpath: spec.slice(slash + 1) };
|
|
258
|
+
}
|
|
259
|
+
function readJsonSafe(file) {
|
|
260
|
+
try {
|
|
261
|
+
return JSON.parse(readFileSync(file, 'utf-8'));
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function pickEsmEntryFromManifest(pkg, subKey) {
|
|
268
|
+
const exportsField = pkg?.exports;
|
|
269
|
+
if (exportsField && typeof exportsField === 'object') {
|
|
270
|
+
const entry = exportsField[subKey];
|
|
271
|
+
const fromConditional = pickEsmFromConditionalExports(entry);
|
|
272
|
+
if (fromConditional)
|
|
273
|
+
return fromConditional;
|
|
274
|
+
}
|
|
275
|
+
// `exports` as a bare string only applies to the `.` subpath.
|
|
276
|
+
if (typeof exportsField === 'string' && subKey === '.')
|
|
277
|
+
return exportsField;
|
|
278
|
+
if (subKey === '.') {
|
|
279
|
+
if (typeof pkg?.module === 'string')
|
|
280
|
+
return pkg.module;
|
|
281
|
+
if (typeof pkg?.main === 'string')
|
|
282
|
+
return pkg.main;
|
|
283
|
+
// CommonJS-only packages frequently omit `main`; Node defaults to `index.js`.
|
|
284
|
+
return 'index.js';
|
|
285
|
+
}
|
|
286
|
+
// Subpath without an `exports` mapping: caller falls through to CJS resolution.
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
function pickEsmFromConditionalExports(entry) {
|
|
290
|
+
if (!entry)
|
|
291
|
+
return null;
|
|
292
|
+
if (typeof entry === 'string')
|
|
293
|
+
return entry;
|
|
294
|
+
if (typeof entry !== 'object')
|
|
295
|
+
return null;
|
|
296
|
+
// Prefer `module` (the de-facto "ESM bundler" condition that Vue, lit,
|
|
297
|
+
// preact etc. ship), then `import`, then `default`. Skip `node`/`require`
|
|
298
|
+
// because those usually point at the CJS shim we're explicitly avoiding.
|
|
299
|
+
for (const key of ['module', 'import', 'default']) {
|
|
300
|
+
const value = entry[key];
|
|
301
|
+
if (typeof value === 'string')
|
|
302
|
+
return value;
|
|
303
|
+
if (value && typeof value === 'object') {
|
|
304
|
+
const nested = pickEsmFromConditionalExports(value);
|
|
305
|
+
if (nested)
|
|
306
|
+
return nested;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
function resolveRelativeInsidePackage(pkgDir, rel) {
|
|
312
|
+
const trimmed = rel.replace(/^\.\//, '');
|
|
313
|
+
const candidates = [trimmed, `${trimmed}.js`, `${trimmed}.mjs`, `${trimmed}.cjs`, `${trimmed}/index.js`, `${trimmed}/index.mjs`];
|
|
314
|
+
for (const c of candidates) {
|
|
315
|
+
const p = path.join(pkgDir, c);
|
|
316
|
+
if (existsSync(p))
|
|
317
|
+
return safeRealpath(p);
|
|
318
|
+
}
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
function findPackageJsonUpward(startFile, expectedName) {
|
|
322
|
+
let dir = path.dirname(startFile);
|
|
323
|
+
const root = path.parse(dir).root;
|
|
324
|
+
while (dir && dir !== root) {
|
|
325
|
+
const candidate = path.join(dir, 'package.json');
|
|
326
|
+
if (existsSync(candidate)) {
|
|
327
|
+
const pkg = readJsonSafe(candidate);
|
|
328
|
+
if (pkg?.name === expectedName)
|
|
329
|
+
return candidate;
|
|
330
|
+
}
|
|
331
|
+
const next = path.dirname(dir);
|
|
332
|
+
if (next === dir)
|
|
333
|
+
break;
|
|
334
|
+
dir = next;
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
function resolveRelative(dir, spec) {
|
|
339
|
+
const base = path.resolve(dir, spec);
|
|
340
|
+
const candidates = ['', '.js', '.mjs', '.cjs', '/index.js', '/index.mjs', '/index.cjs'];
|
|
341
|
+
for (const ext of candidates) {
|
|
342
|
+
const p = base + ext;
|
|
343
|
+
try {
|
|
344
|
+
if (existsSync(p)) {
|
|
345
|
+
const real = safeRealpath(p);
|
|
346
|
+
// Skip directories returned by `existsSync` without an index file fallback.
|
|
347
|
+
try {
|
|
348
|
+
const stat = readFileSafe(real);
|
|
349
|
+
if (stat !== null)
|
|
350
|
+
return real;
|
|
351
|
+
}
|
|
352
|
+
catch { }
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch { }
|
|
356
|
+
}
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
function safeResolve(req, spec) {
|
|
360
|
+
try {
|
|
361
|
+
return req.resolve(spec);
|
|
362
|
+
}
|
|
363
|
+
catch {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function createRequireFromDir(dir) {
|
|
368
|
+
// `createRequire` wants a file path; we pass a synthetic file under the
|
|
369
|
+
// dir so resolution starts there.
|
|
370
|
+
return createRequire(path.join(dir, 'package.json'));
|
|
371
|
+
}
|
|
372
|
+
function createRequireFromFile(file) {
|
|
373
|
+
try {
|
|
374
|
+
return createRequire(file);
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function safeRealpath(file) {
|
|
381
|
+
try {
|
|
382
|
+
return realpathSync(file);
|
|
383
|
+
}
|
|
384
|
+
catch {
|
|
385
|
+
return file;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function readFileSafe(file) {
|
|
389
|
+
try {
|
|
390
|
+
return readFileSync(file, 'utf-8');
|
|
391
|
+
}
|
|
392
|
+
catch {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=package-exports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-exports.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/helpers/package-exports.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,wEAAwE;AACxE,2EAA2E;AAC3E,0EAA0E;AAC1E,uEAAuE;AACvE,0EAA0E;AAC1E,4EAA4E;AAC5E,uEAAuE;AACvE,qDAAqD;AACrD,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,oBAAoB;AACpB,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,4EAA4E;AAC5E,0DAA0D;AAC1D,0EAA0E;AAC1E,2EAA2E;AAC3E,kDAAkD;AAClD,qEAAqE;AACrE,2EAA2E;AAC3E,yCAAyC;AACzC,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,wEAAwE;AACxE,4DAA4D;AAE5D,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,UAAU,EA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R,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC"}
|
package/hmr/server/constants.js
CHANGED
|
@@ -5,15 +5,24 @@ export const QUERY_PATTERN = /\?.*$/;
|
|
|
5
5
|
// Detect whether Vite's variable dynamic import helper is already inlined
|
|
6
6
|
export const VARIABLE_DYNAMIC_IMPORT_HELPER_PATTERN = /__variableDynamicImportRuntimeHelper\s*=/;
|
|
7
7
|
// Import/export matchers (static and dynamic)
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
//
|
|
9
|
+
// Each pattern's first capture group includes the optional leading anchor
|
|
10
|
+
// (`^|\n`) so the replacement function preserves the line break that would
|
|
11
|
+
// otherwise be silently consumed by the regex engine. Without this, two
|
|
12
|
+
// concatenated patterns like:
|
|
13
|
+
// `})();\nexport * from "a"\nexport * from "b"`
|
|
14
|
+
// would collapse to:
|
|
15
|
+
// `})();export * from "a"export * from "b"`
|
|
16
|
+
// because each `(?:^|\n)` ate a newline that no replacement string put back.
|
|
17
|
+
export const IMPORT_PATTERN_1 = /((?:^|\n)\s*import\s+[^'";]*?\s+from\s+["'])([^"']+)(["'];?)/g;
|
|
18
|
+
export const IMPORT_PATTERN_2 = /((?:^|\n)\s*export\s+[^'";]*?\s+from\s+["'])([^"']+)(["'];?)/g;
|
|
10
19
|
export const EXPORT_PATTERN = IMPORT_PATTERN_2;
|
|
11
20
|
export const IMPORT_PATTERN_3 = /(import\(\s*["'])([^"']+)(["']\s*\))/g;
|
|
12
21
|
// Side-effect imports: import "spec" / import 'spec' (no `from`, no bindings)
|
|
13
|
-
export const IMPORT_PATTERN_SIDE_EFFECT = /(?:^|\n)
|
|
22
|
+
export const IMPORT_PATTERN_SIDE_EFFECT = /((?:^|\n)\s*import\s+["'])([^"']+)(["'];?)/g;
|
|
14
23
|
// Vue-specific patterns
|
|
15
24
|
export const VUE_FILE_PATTERN = /\.vue(?:\?[^"']*)?$/;
|
|
16
|
-
export const VUE_FILE_IMPORT = /(?:^|\n)
|
|
25
|
+
export const VUE_FILE_IMPORT = /((?:^|\n)\s*import\s+[^'";]*?\s+from\s+["'])([^"']+\.vue(?:\?[^"']*)?)(["'];?)/g;
|
|
17
26
|
// Vite/HMR noise cleanup
|
|
18
27
|
export const VITE_CLIENT_IMPORT = /(?:^|\n)\s*import\s+['"](?:\/@vite\/client|@vite\/client)['"];?/g;
|
|
19
28
|
// Strip Vite's injected `import.meta.hot = __vite__createHotContext(...)` assignment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/constants.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qGAAqG;AAErG,uBAAuB;AACvB,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sCAAsC,GAAG,0CAA0C,CAAC;AAEjG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,+DAA+D,CAAC;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAG,+DAA+D,CAAC;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AACxE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,6CAA6C,CAAC;AAExF,wBAAwB;AACxB,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,iFAAiF,CAAC;AAEjH,yBAAyB;AACzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,kEAAkE,CAAC;AACrG,sFAAsF;AACtF,wFAAwF;AACxF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,sCAAsC,CAAC;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG,+DAA+D,CAAC;AAErG,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,kEAAkE,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G,sEAAsE,CAAC;AAC5G,MAAM,CAAC,MAAM,qBAAqB,GAAG,+CAA+C,CAAC"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* "@nativescript/core/index.js";
|
|
9
9
|
* This trips the sanitizer's local-core-path detector and breaks HTTP ESM loading.
|
|
10
10
|
*
|
|
11
|
-
* This helper safely maps those literals to:
|
|
12
|
-
* import "/ns/core?p=
|
|
11
|
+
* This helper safely maps those literals to the canonical path form:
|
|
12
|
+
* import "/ns/core/<sub>"; // subpath form, no version, no ?p=
|
|
13
13
|
* or, without subpath:
|
|
14
14
|
* import "/ns/core";
|
|
15
15
|
*/
|
|
@@ -19,17 +19,95 @@ export declare function normalizeStrayCoreStringLiterals(code: string): string;
|
|
|
19
19
|
* following side-effect import of the core bridge.
|
|
20
20
|
*
|
|
21
21
|
* Example:
|
|
22
|
-
* import { A, B } from\nimport "/ns/core
|
|
22
|
+
* import { A, B } from\nimport "/ns/core/index";
|
|
23
23
|
* becomes
|
|
24
|
-
* import { A, B } from "/ns/core
|
|
24
|
+
* import { A, B } from "/ns/core/index";
|
|
25
25
|
*/
|
|
26
26
|
export declare function fixDanglingCoreFrom(code: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Run the full "rescue any stray @nativescript/core references" pass over the
|
|
29
|
+
* code in one call. This is the canonical entry point for NS-M served modules
|
|
30
|
+
* (and any other consumer that wants the safety net). The three sub-passes
|
|
31
|
+
* cover progressively rarer pipeline accidents:
|
|
32
|
+
*
|
|
33
|
+
* 1. `normalizeStrayCoreStringLiterals` — turns naked `"@nativescript/core/foo";`
|
|
34
|
+
* string literals (produced by some upstream transforms that bare-stringify
|
|
35
|
+
* side-effect imports) back into proper `import "/ns/core/foo";`.
|
|
36
|
+
* 2. `fixDanglingCoreFrom` — merges multi-line accidents where a `from`
|
|
37
|
+
* clause got separated from its specifier across newlines.
|
|
38
|
+
* 3. `normalizeAnyCoreSpecToBridge` — final regex sweep that catches any
|
|
39
|
+
* remaining `from "...@nativescript/core[/sub]..."` references that escaped
|
|
40
|
+
* both the AST normalizer and the import rewriter.
|
|
41
|
+
*
|
|
42
|
+
* Centralising the passes here ensures every NS-M emitter applies the same
|
|
43
|
+
* safety net in the same order; drift between call sites re-introduces the
|
|
44
|
+
* realm-split bug.
|
|
45
|
+
*
|
|
46
|
+
* Returns the (possibly) rewritten code; never throws.
|
|
47
|
+
*/
|
|
48
|
+
export declare function sanitizeStrayCoreReferences(code: string): string;
|
|
27
49
|
/**
|
|
28
50
|
* Fallback: normalize ANY import spec that references '@nativescript/core' (including
|
|
29
51
|
* absolute/relative or resolved forms like '/node_modules/@nativescript/core/index.js?v=...')
|
|
30
52
|
* into the unified '/ns/core' bridge before fast-fail assertions.
|
|
31
53
|
*/
|
|
32
54
|
export declare function normalizeAnyCoreSpecToBridge(code: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Description of the URL the bridge is currently serving, used to resolve
|
|
57
|
+
* relative import specifiers (`./x`, `../x`) into absolute `/ns/core/<sub>`
|
|
58
|
+
* URLs.
|
|
59
|
+
*
|
|
60
|
+
* Why this exists: Vite's `vite:import-analysis` pass usually rewrites every
|
|
61
|
+
* relative specifier to an absolute (`/@fs/...` or `/node_modules/...`) ID
|
|
62
|
+
* before code reaches us, but for files under `node_modules` some transform
|
|
63
|
+
* paths leave relatives untouched. When the device fetches such a module at
|
|
64
|
+
* `http://host/ns/core/utils/layout-helper` (no trailing slash, no `/index`)
|
|
65
|
+
* V8/iOS apply RFC 3986 URL resolution and treat `layout-helper` as the
|
|
66
|
+
* *file*, so `./layout-helper-common` becomes
|
|
67
|
+
* `http://host/ns/core/utils/layout-helper-common` — a sibling that does not
|
|
68
|
+
* exist (the real file lives at `…/layout-helper/layout-helper-common`).
|
|
69
|
+
*
|
|
70
|
+
* Passing a `RelativeBase` lets `rewriteSpec` resolve these specifiers
|
|
71
|
+
* server-side and emit canonical absolute `/ns/core/<resolved>` URLs, so the
|
|
72
|
+
* device never has to guess. When omitted, `rewriteSpec` falls back to the
|
|
73
|
+
* pre-existing behaviour of leaving relatives alone.
|
|
74
|
+
*/
|
|
75
|
+
export type RelativeBase = {
|
|
76
|
+
/**
|
|
77
|
+
* Sub-path of the served module, without the leading `/ns/core/`. May be
|
|
78
|
+
* the empty string for the package main (`/ns/core` itself).
|
|
79
|
+
*/
|
|
80
|
+
sub: string;
|
|
81
|
+
/**
|
|
82
|
+
* `true` when the served file is a directory-index (e.g.
|
|
83
|
+
* `…/utils/layout-helper/index.android.ts`); in that case `sub` already
|
|
84
|
+
* names the *directory*, and `./x` resolves to `<sub>/x`.
|
|
85
|
+
*
|
|
86
|
+
* `false` for plain file modules (e.g. `…/utils/native-helper.ts`); the
|
|
87
|
+
* resolution base is the parent directory of `sub`, so `./x` resolves to
|
|
88
|
+
* `<sub-parent>/x`.
|
|
89
|
+
*/
|
|
90
|
+
isDirectoryIndex: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Detect whether a resolved module path is a directory-index file. Matches
|
|
94
|
+
* `index.<platform?>.<ext>` shapes used across @nativescript/core (e.g.
|
|
95
|
+
* `index.js`, `index.android.ts`, `index.ios.mjs`).
|
|
96
|
+
*/
|
|
97
|
+
export declare function isDirectoryIndexFilename(modulePath: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a relative specifier (`./x`, `../x`) into a canonical
|
|
100
|
+
* @nativescript/core sub-path, given the base described by `relBase`.
|
|
101
|
+
*
|
|
102
|
+
* `…/index.<platform>.<ext>` files mean `sub` IS the directory (so `./x` →
|
|
103
|
+
* `<sub>/x`); plain files mean the resolution base is `sub`'s parent.
|
|
104
|
+
*
|
|
105
|
+
* Returned sub-path is sanitised by `buildCoreUrlPath`'s convention: trailing
|
|
106
|
+
* `.(m)?(j|t)s` extensions are stripped so callers can directly emit
|
|
107
|
+
* `/ns/core/<resolved>` without producing a non-canonical URL that the
|
|
108
|
+
* bridge would 301-redirect later.
|
|
109
|
+
*/
|
|
110
|
+
export declare function resolveRelativeCoreSub(spec: string, relBase: RelativeBase): string | null;
|
|
33
111
|
/**
|
|
34
112
|
* Minimal specifier rewriter for deep subpath core modules.
|
|
35
113
|
*
|
|
@@ -43,14 +121,19 @@ export declare function normalizeAnyCoreSpecToBridge(code: string): string;
|
|
|
43
121
|
* This replaces the heavy 5-pass pipeline (processCodeForDevice →
|
|
44
122
|
* rewriteImports → deduplicateLinkerImports → CJS wrapping → etc.)
|
|
45
123
|
* for deep subpath core modules where Vite already produces correct ESM.
|
|
124
|
+
*
|
|
125
|
+
* When `relBase` is supplied, relative specifiers (`./x`, `../x`) are
|
|
126
|
+
* resolved server-side into canonical `/ns/core/<resolved>` URLs so the
|
|
127
|
+
* device never has to guess where a directory-index file's siblings live.
|
|
128
|
+
* See `RelativeBase` and `rewriteSpec` for the full rationale.
|
|
46
129
|
*/
|
|
47
|
-
export declare function rewriteSpecifiersForDevice(code: string, origin: string, ver: number): string;
|
|
130
|
+
export declare function rewriteSpecifiersForDevice(code: string, origin: string, ver: number, relBase?: RelativeBase): string;
|
|
48
131
|
/**
|
|
49
132
|
* Determine whether a `/ns/core` bridge URL points to a real subpath module.
|
|
50
133
|
*
|
|
51
|
-
* Any `/ns/core
|
|
134
|
+
* Any `/ns/core/<sub>` module now serves real ESM content with real named
|
|
52
135
|
* exports via Vite's transform pipeline, except for package-main aliases like
|
|
53
|
-
* `/ns/core
|
|
136
|
+
* `/ns/core/index`, which should be treated like the main `/ns/core`
|
|
54
137
|
* bridge and destructured from its default export.
|
|
55
138
|
* The main proxy bridge (`/ns/core`) still only exports a default Proxy and
|
|
56
139
|
* requires named imports to be destructured from it.
|