@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,336 @@
|
|
|
1
|
+
import { getProjectAppVirtualPath } from '../../../../helpers/utils.js';
|
|
2
|
+
import { isRuntimeGraphExcludedPath } from '../../../server/runtime-graph-filter.js';
|
|
3
|
+
import { canonicalizeTransformRequestCacheKey } from '../../../server/transform-cache-invalidation.js';
|
|
4
|
+
const APP_VIRTUAL_WITH_SLASH = `${getProjectAppVirtualPath()}/`;
|
|
5
|
+
export function collectGraphUpdateModulesForHotUpdate(options) {
|
|
6
|
+
const targets = new Map();
|
|
7
|
+
const addTarget = (mod) => {
|
|
8
|
+
const id = mod?.id?.replace(/\?.*$/, '');
|
|
9
|
+
if (!id)
|
|
10
|
+
return;
|
|
11
|
+
if (isRuntimeGraphExcludedPath(id))
|
|
12
|
+
return;
|
|
13
|
+
if (!targets.has(id)) {
|
|
14
|
+
targets.set(id, mod);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
if (options.flavor === 'angular' && /\.(html|htm)$/i.test(options.file)) {
|
|
18
|
+
const importerIdsSeen = [];
|
|
19
|
+
const importerIdsAccepted = [];
|
|
20
|
+
for (const mod of options.modules || []) {
|
|
21
|
+
for (const importer of mod?.importers || []) {
|
|
22
|
+
const importerId = importer?.id || '';
|
|
23
|
+
importerIdsSeen.push(importerId);
|
|
24
|
+
if (/\.[cm]?[jt]sx?(?:$|\?)/i.test(importerId)) {
|
|
25
|
+
addTarget(importer);
|
|
26
|
+
importerIdsAccepted.push(importerId);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const fellBackToFile = !targets.size;
|
|
31
|
+
if (fellBackToFile) {
|
|
32
|
+
addTarget(options.getModuleById(options.file.replace(/\.(html|htm)$/i, '.ts')));
|
|
33
|
+
addTarget(options.getModuleById(options.file.replace(/\.(html|htm)$/i, '.js')));
|
|
34
|
+
}
|
|
35
|
+
if (options.verbose) {
|
|
36
|
+
console.info(`[ns-hmr][server] collectGraphUpdateModulesForHotUpdate(html) file=${options.file} importersSeen=${importerIdsSeen.length} importersAccepted=${importerIdsAccepted.length} fellBackToFile=${fellBackToFile} targets=${targets.size}`);
|
|
37
|
+
if (importerIdsSeen.length) {
|
|
38
|
+
console.info(`[ns-hmr][server] importersSeen sample=`, importerIdsSeen.slice(0, 8));
|
|
39
|
+
}
|
|
40
|
+
if (importerIdsAccepted.length) {
|
|
41
|
+
console.info(`[ns-hmr][server] importersAccepted sample=`, importerIdsAccepted.slice(0, 8));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return Array.from(targets.values());
|
|
45
|
+
}
|
|
46
|
+
if (!options.file.endsWith('.vue')) {
|
|
47
|
+
addTarget(options.getModuleById(options.file) || options.getModuleById(options.file + '?vue'));
|
|
48
|
+
}
|
|
49
|
+
return Array.from(targets.values());
|
|
50
|
+
}
|
|
51
|
+
export function collectAngularHotUpdateRoots(options) {
|
|
52
|
+
const roots = [];
|
|
53
|
+
const seenIds = new Set();
|
|
54
|
+
const seenObjects = new Set();
|
|
55
|
+
const addRoot = (mod) => {
|
|
56
|
+
if (!mod) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (mod.id) {
|
|
60
|
+
if (isRuntimeGraphExcludedPath(mod.id)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (seenIds.has(mod.id)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
seenIds.add(mod.id);
|
|
67
|
+
roots.push(mod);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (seenObjects.has(mod)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
seenObjects.add(mod);
|
|
74
|
+
roots.push(mod);
|
|
75
|
+
};
|
|
76
|
+
if (/\.(html|htm)$/i.test(options.file)) {
|
|
77
|
+
for (const mod of collectGraphUpdateModulesForHotUpdate({
|
|
78
|
+
file: options.file,
|
|
79
|
+
flavor: 'angular',
|
|
80
|
+
modules: options.modules,
|
|
81
|
+
getModuleById: options.getModuleById,
|
|
82
|
+
})) {
|
|
83
|
+
addRoot(mod);
|
|
84
|
+
}
|
|
85
|
+
return roots;
|
|
86
|
+
}
|
|
87
|
+
if (!/\.(m|c)?ts$/i.test(options.file)) {
|
|
88
|
+
return roots;
|
|
89
|
+
}
|
|
90
|
+
for (const mod of options.modules || []) {
|
|
91
|
+
addRoot(mod);
|
|
92
|
+
}
|
|
93
|
+
for (const mod of options.getModulesByFile?.(options.file) || []) {
|
|
94
|
+
addRoot(mod);
|
|
95
|
+
}
|
|
96
|
+
if (!roots.length) {
|
|
97
|
+
addRoot(options.getModuleById(options.file));
|
|
98
|
+
}
|
|
99
|
+
return roots;
|
|
100
|
+
}
|
|
101
|
+
// Angular narrowing: a TS/JS file needs to invalidate its transitive
|
|
102
|
+
// importers only when it carries Angular semantics (a top-level @Component,
|
|
103
|
+
// @Directive, @Pipe, @Injectable, or @NgModule decorator). Files that only
|
|
104
|
+
// export constants, types, enums, plain functions, or plain classes are
|
|
105
|
+
// "leaf" modules — ES modules' live bindings deliver the new exports to
|
|
106
|
+
// importers automatically once V8 re-evaluates the changed module. Forcing
|
|
107
|
+
// every importer to re-transform on a constants edit is what produces the
|
|
108
|
+
// large invalidation waves that dominate the `refresh` phase on
|
|
109
|
+
// constants-style edits in big apps.
|
|
110
|
+
//
|
|
111
|
+
// Regex anchors at line start with only whitespace before `@Decorator(` so
|
|
112
|
+
// we don't false-match on string literals, JSDoc references, or commented-
|
|
113
|
+
// out blocks. Tests pin the matching/non-matching shapes that have come up
|
|
114
|
+
// in real Angular sources.
|
|
115
|
+
const ANGULAR_SEMANTIC_DECORATOR_REGEX = /^[ \t]*@(?:Component|Directive|Pipe|Injectable|NgModule)\b\s*\(/m;
|
|
116
|
+
export function angularSourceHasSemanticDecorator(source) {
|
|
117
|
+
if (!source || source.length === 0)
|
|
118
|
+
return false;
|
|
119
|
+
return ANGULAR_SEMANTIC_DECORATOR_REGEX.test(source);
|
|
120
|
+
}
|
|
121
|
+
export function shouldInvalidateAngularTransitiveImporters(options) {
|
|
122
|
+
if (options.flavor !== 'angular') {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
// Template-only (.html/.htm) edits change the component's view but never
|
|
126
|
+
// its exported symbol shape, so importers of the component do not need to
|
|
127
|
+
// re-transform. Skipping the transitive walk here is the single biggest
|
|
128
|
+
// latency win for template HMR.
|
|
129
|
+
if (!/\.(?:(m|c)?[jt]sx?)$/i.test(options.file)) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
// When source is available, narrow to "files whose changes can affect
|
|
133
|
+
// the Angular semantics of their importers". Files without a top-level
|
|
134
|
+
// @Component/@Directive/@Pipe/@Injectable/@NgModule decorator are leaf
|
|
135
|
+
// modules — invalidating the file itself is sufficient. When source is
|
|
136
|
+
// undefined/null (e.g. ctx.read() failed or the caller didn't plumb it
|
|
137
|
+
// through), fall back to the conservative behavior: invalidate
|
|
138
|
+
// transitively.
|
|
139
|
+
if (typeof options.source === 'string') {
|
|
140
|
+
return angularSourceHasSemanticDecorator(options.source);
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
function isExtensionlessAngularAppTransformCandidate(id) {
|
|
145
|
+
return id.startsWith(APP_VIRTUAL_WITH_SLASH) && /\.(?:[mc]?[jt]sx?)$/i.test(id);
|
|
146
|
+
}
|
|
147
|
+
function addAngularTransformCacheInvalidationUrl(targets, rawId, projectRoot) {
|
|
148
|
+
const id = String(rawId || '');
|
|
149
|
+
if (!id) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const cacheKey = projectRoot ? canonicalizeTransformRequestCacheKey(id, projectRoot) : id;
|
|
153
|
+
targets.add(cacheKey);
|
|
154
|
+
const normalizedId = cacheKey.replace(/\?.*$/, '');
|
|
155
|
+
if (!isExtensionlessAngularAppTransformCandidate(normalizedId)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
targets.add(normalizedId.replace(/\.(?:[mc]?[jt]sx?)$/i, ''));
|
|
159
|
+
}
|
|
160
|
+
export function collectAngularTransformCacheInvalidationUrls(options) {
|
|
161
|
+
const urls = new Set();
|
|
162
|
+
if (options.isTs) {
|
|
163
|
+
addAngularTransformCacheInvalidationUrl(urls, options.file, options.projectRoot);
|
|
164
|
+
}
|
|
165
|
+
for (const mod of options.hotUpdateRoots || []) {
|
|
166
|
+
addAngularTransformCacheInvalidationUrl(urls, mod?.id, options.projectRoot);
|
|
167
|
+
}
|
|
168
|
+
for (const mod of options.transitiveImporters || []) {
|
|
169
|
+
addAngularTransformCacheInvalidationUrl(urls, mod?.id, options.projectRoot);
|
|
170
|
+
}
|
|
171
|
+
return Array.from(urls);
|
|
172
|
+
}
|
|
173
|
+
// Stable URL + Explicit Invalidation.
|
|
174
|
+
//
|
|
175
|
+
// Compute the set of fully-qualified `/ns/m/<rel>` URLs that the runtime
|
|
176
|
+
// should drop from `g_moduleRegistry` before re-importing main.ts. The
|
|
177
|
+
// set must satisfy these invariants:
|
|
178
|
+
//
|
|
179
|
+
// * The changed file itself (so V8 fetches the new source).
|
|
180
|
+
// * Every transitive importer up to the entry (so the new exports are
|
|
181
|
+
// re-bound; ESM live bindings only "see" new exports if the importer
|
|
182
|
+
// re-evaluates).
|
|
183
|
+
// * No `/node_modules/` paths (vendor packages are stable in dev; evicting
|
|
184
|
+
// them would force unnecessary re-fetch + re-transform).
|
|
185
|
+
// * No virtual / runtime-graph-excluded ids (e.g. `\0` rollup virtuals).
|
|
186
|
+
// * No duplicates — the set is deduped on canonical relative path.
|
|
187
|
+
//
|
|
188
|
+
// The output URLs are origin-absolute (e.g.
|
|
189
|
+
// `http://localhost:5173/ns/m/src/main.ts`) so the runtime can feed the
|
|
190
|
+
// list directly into `__nsInvalidateModules` without any further
|
|
191
|
+
// resolution work. The runtime canonicalizer collapses any residual
|
|
192
|
+
// `__ns_hmr__/<tag>/` or `__ns_boot__/b1/` segments, so the effective
|
|
193
|
+
// registry key is `/ns/m/<rel>` regardless of any tag a stale V8 cache
|
|
194
|
+
// entry might still carry.
|
|
195
|
+
//
|
|
196
|
+
// Extensionless canonical key.
|
|
197
|
+
//
|
|
198
|
+
// Vite emits ES module import statements with extensions stripped (this
|
|
199
|
+
// is how `resolve.extensions` works for Angular/TS apps), so V8 in the
|
|
200
|
+
// NativeScript iOS runtime keys `g_moduleRegistry` by the extensionless
|
|
201
|
+
// URL it sees in the import statement. Concretely, an import like
|
|
202
|
+
// import { AppComponent } from './app.component';
|
|
203
|
+
// inside `main.ts` is rewritten by Vite to
|
|
204
|
+
// import { AppComponent } from '/ns/m/src/app/app.component';
|
|
205
|
+
// and V8 stores the resulting module under the key
|
|
206
|
+
// http://localhost:5173/ns/m/src/app/app.component
|
|
207
|
+
// (no `.ts` extension). The `moduleGraph` ids on the server, however,
|
|
208
|
+
// are absolute file paths that DO carry the extension, so a naive
|
|
209
|
+
// eviction set built from `mod.id` keys against `.../app.component.ts`
|
|
210
|
+
// — which never matches the registry entry. The runtime reports
|
|
211
|
+
// `[resolver][remove:miss]`, the cached module survives, ESM live
|
|
212
|
+
// bindings continue to point at the OLD constants module, and the user
|
|
213
|
+
// sees no visual update despite a clean HMR cycle.
|
|
214
|
+
//
|
|
215
|
+
// Workaround: for any path ending in `.ts/.tsx/.js/.jsx/.mjs/.mts/
|
|
216
|
+
// .cjs/.cts`, emit BOTH the extensioned URL AND the extension-stripped
|
|
217
|
+
// canonical URL. The runtime evicts whichever shape V8 actually has;
|
|
218
|
+
// the other is a harmless `remove:miss`. Cost: at most 2x URLs in
|
|
219
|
+
// `evictPaths` (still tiny relative to the JSON payload).
|
|
220
|
+
//
|
|
221
|
+
// Returning a `Set` of URLs (rather than an array) lets the caller
|
|
222
|
+
// collapse multiple sources (changed file + roots + transitive
|
|
223
|
+
// importers) without paying for an extra dedup pass.
|
|
224
|
+
function normalizeAngularEvictRelativeId(rawId, projectRoot) {
|
|
225
|
+
if (!rawId)
|
|
226
|
+
return null;
|
|
227
|
+
let id = String(rawId).split('?')[0].replace(/\\/g, '/');
|
|
228
|
+
if (!id)
|
|
229
|
+
return null;
|
|
230
|
+
if (id.startsWith('file://')) {
|
|
231
|
+
id = id.slice('file://'.length);
|
|
232
|
+
}
|
|
233
|
+
const root = projectRoot ? projectRoot.replace(/\\/g, '/').replace(/\/$/, '') : '';
|
|
234
|
+
if (root && id.startsWith(root)) {
|
|
235
|
+
id = id.slice(root.length);
|
|
236
|
+
}
|
|
237
|
+
if (!id.startsWith('/')) {
|
|
238
|
+
id = '/' + id;
|
|
239
|
+
}
|
|
240
|
+
if (id.includes('/node_modules/')) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
if (isRuntimeGraphExcludedPath(id)) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
// Reject virtual ids — they aren't fetchable over /ns/m/.
|
|
247
|
+
if (id.includes('\0') || id.includes('/@id/') || id.includes('/@fs/')) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
return id;
|
|
251
|
+
}
|
|
252
|
+
export function collectAngularEvictionUrls(options) {
|
|
253
|
+
const urls = new Set();
|
|
254
|
+
const origin = String(options.origin || '').replace(/\/$/, '');
|
|
255
|
+
const root = options.projectRoot;
|
|
256
|
+
const addRel = (rel) => {
|
|
257
|
+
if (!rel)
|
|
258
|
+
return;
|
|
259
|
+
// Final defense: never emit non-/ns/m URLs for eviction; the runtime
|
|
260
|
+
// would map them to a different cache namespace.
|
|
261
|
+
urls.add(`${origin}/ns/m${rel}`);
|
|
262
|
+
// V8 in the iOS runtime keys `g_moduleRegistry` by the URL Vite
|
|
263
|
+
// emitted in the *generated* import statement, which strips JS/TS
|
|
264
|
+
// extensions (see the extensionless-key block above). So the
|
|
265
|
+
// canonical registry key for an app TS/JS module is the
|
|
266
|
+
// extensionless form. Emit it alongside the `.ts` form so the
|
|
267
|
+
// explicit eviction matches whatever shape the runtime actually
|
|
268
|
+
// stored. This cannot false-positive: at most one of the two URLs
|
|
269
|
+
// maps to a real entry, and `__nsInvalidateModules` treats unknown
|
|
270
|
+
// keys as no-ops.
|
|
271
|
+
const extMatch = rel.match(/\.(?:[mc]?[jt]sx?)$/i);
|
|
272
|
+
if (extMatch) {
|
|
273
|
+
urls.add(`${origin}/ns/m${rel.slice(0, -extMatch[0].length)}`);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
addRel(normalizeAngularEvictRelativeId(options.file, root));
|
|
277
|
+
for (const mod of options.hotUpdateRoots || []) {
|
|
278
|
+
addRel(normalizeAngularEvictRelativeId(mod?.id || mod?.file, root));
|
|
279
|
+
}
|
|
280
|
+
for (const mod of options.transitiveImporters || []) {
|
|
281
|
+
addRel(normalizeAngularEvictRelativeId(mod?.id || mod?.file, root));
|
|
282
|
+
}
|
|
283
|
+
// The bootstrap entry must always be evicted: V8's `import(entry)` is a
|
|
284
|
+
// no-op if the cache entry is still live, and the entire HMR cycle
|
|
285
|
+
// hinges on re-evaluating main.ts. The transitive walk usually catches
|
|
286
|
+
// this naturally (every component reaches main via importer chains),
|
|
287
|
+
// but include it explicitly as an invariant — covers edge cases like a
|
|
288
|
+
// hand-rolled `@nativescript/hmr-strategy` overriding the candidates,
|
|
289
|
+
// or a pristine app whose graph hasn't yet linked main into the
|
|
290
|
+
// importer set.
|
|
291
|
+
if (typeof options.bootstrapEntry === 'string' && options.bootstrapEntry) {
|
|
292
|
+
addRel(normalizeAngularEvictRelativeId(options.bootstrapEntry, root));
|
|
293
|
+
}
|
|
294
|
+
return Array.from(urls);
|
|
295
|
+
}
|
|
296
|
+
export function shouldSuppressDefaultViteHotUpdate(options) {
|
|
297
|
+
if (options.flavor !== 'angular') {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
return /\.(html|htm|ts)$/i.test(options.file);
|
|
301
|
+
}
|
|
302
|
+
export function normalizeHotReloadMatchPath(raw, root) {
|
|
303
|
+
let normalized = String(raw || '')
|
|
304
|
+
.split('?')[0]
|
|
305
|
+
.replace(/\\/g, '/')
|
|
306
|
+
.replace(/^file:\/\//, '');
|
|
307
|
+
if (root) {
|
|
308
|
+
const rootNormalized = root.replace(/\\/g, '/');
|
|
309
|
+
if (normalized.startsWith(rootNormalized)) {
|
|
310
|
+
normalized = normalized.slice(rootNormalized.length);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (!normalized.startsWith('/')) {
|
|
314
|
+
normalized = `/${normalized}`;
|
|
315
|
+
}
|
|
316
|
+
return normalized;
|
|
317
|
+
}
|
|
318
|
+
export function shouldSuppressViteFullReloadPayload(options) {
|
|
319
|
+
const { payload, pendingEntries, root } = options;
|
|
320
|
+
const now = options.now ?? Date.now();
|
|
321
|
+
if (!payload || payload.type !== 'full-reload') {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
const payloadPath = typeof payload.path === 'string' && payload.path !== '*' ? normalizeHotReloadMatchPath(payload.path, root) : null;
|
|
325
|
+
const payloadTriggeredBy = typeof payload.triggeredBy === 'string' ? normalizeHotReloadMatchPath(payload.triggeredBy, root) : null;
|
|
326
|
+
for (const entry of pendingEntries) {
|
|
327
|
+
if (!entry || entry.expiresAt <= now) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (payloadTriggeredBy === entry.absPath || payloadTriggeredBy === entry.relPath || payloadPath === entry.relPath || payloadPath === entry.absPath) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=websocket-angular-hot-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-angular-hot-update.js","sourceRoot":"","sources":["../../../../../../../packages/vite/hmr/frameworks/angular/server/websocket-angular-hot-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,oCAAoC,EAAE,MAAM,iDAAiD,CAAC;AAEvG,MAAM,sBAAsB,GAAG,GAAG,wBAAwB,EAAE,GAAG,CAAC;AAQhE,MAAM,UAAU,qCAAqC,CAAC,OAA+K;IACpO,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;IAC5D,MAAM,SAAS,GAAG,CAAC,GAAqC,EAAE,EAAE;QAC3D,MAAM,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,EAAE;YAAE,OAAO;QAChB,IAAI,0BAA0B,CAAC,EAAE,CAAC;YAAE,OAAO;QAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACtB,OAAO,CA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AC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,2BAA2B,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtI,MAAM,kBAAkB,GAAG,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,2BAA2B,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEnI,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC;YACtC,SAAS;QACV,CAAC;QAED,IAAI,kBAAkB,KAAK,KAAK,CAAC,OAAO,IAAI,kBAAkB,KAAK,KAAK,CAAC,OAAO,IAAI,WAAW,KAAK,KAAK,CAAC,OAAO,IAAI,WAAW,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;YACpJ,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find installed packages whose pre-bundle output would smuggle JSX into
|
|
3
|
+
* Vite's import-analysis stage. Returned names are safe to drop into
|
|
4
|
+
* `optimizeDeps.exclude` — the dev server will serve them through the
|
|
5
|
+
* normal module pipeline, where `vite-plugin-solid` can transform their
|
|
6
|
+
* original `.jsx`/`.tsx` files.
|
|
7
|
+
*
|
|
8
|
+
* The function is intentionally synchronous and best-effort: filesystem
|
|
9
|
+
* errors are swallowed, missing directories are skipped, and the scan
|
|
10
|
+
* caps at {@link MAX_SCAN_DEPTH} levels per package. Callers should
|
|
11
|
+
* treat the empty-array result as "no exclusions needed", not "scan
|
|
12
|
+
* failed". A nullable `monorepoRoot` is accepted so workspace hoisting
|
|
13
|
+
* is covered without forcing every caller to compute it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findSolidPackagesShippingJsx(projectRoot: string, monorepoRoot?: string | null): string[];
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Why this helper exists
|
|
5
|
+
* ----------------------
|
|
6
|
+
*
|
|
7
|
+
* Vite's depscanner happily pre-bundles every bare specifier the app
|
|
8
|
+
* imports. For a Solid library that publishes pre-compiled-but-still-JSX
|
|
9
|
+
* files (e.g. `solid-navigation`'s `dist/src/*.jsx`), the pre-bundle output
|
|
10
|
+
* lands at `node_modules/.vite/deps/<pkg>.js` with the JSX intact —
|
|
11
|
+
* rolldown's depscanner doesn't run Solid's JSX transform (that lives in
|
|
12
|
+
* `vite-plugin-solid`'s `transform` hook, which only matches files whose
|
|
13
|
+
* id ends in `.jsx`/`.tsx`).
|
|
14
|
+
*
|
|
15
|
+
* Vite then runs `vite:import-analysis` on the `.js` output, hits the
|
|
16
|
+
* first JSX expression, and aborts the dev server's pre-transform with:
|
|
17
|
+
*
|
|
18
|
+
* Failed to parse source for import analysis because the content
|
|
19
|
+
* contains invalid JS syntax. If you are using JSX, make sure to
|
|
20
|
+
* name the file with the .jsx or .tsx extension.
|
|
21
|
+
* File: /…/.vite/deps/<pkg>.js:51:32
|
|
22
|
+
*
|
|
23
|
+
* The fix: when a project depends on a Solid library that ships `.jsx`
|
|
24
|
+
* (or `.tsx`) source files in its package directory, mark that package
|
|
25
|
+
* as `optimizeDeps.exclude` so Vite serves it through the regular dev
|
|
26
|
+
* pipeline, where `vite-plugin-solid`'s `transform` hook matches the
|
|
27
|
+
* original `.jsx` id and applies the Solid babel preset.
|
|
28
|
+
*
|
|
29
|
+
* Detection rules — biased toward false negatives so we never wrongly
|
|
30
|
+
* exclude a package that Vite must pre-bundle (esp. CJS-only deps that
|
|
31
|
+
* need esm interop). A package is excluded only when ALL of the
|
|
32
|
+
* following hold:
|
|
33
|
+
*
|
|
34
|
+
* 1. It declares `solid-js` or `@nativescript-community/solid-js` in
|
|
35
|
+
* `dependencies` / `peerDependencies` / `devDependencies`. This is
|
|
36
|
+
* a strong signal that the package's published artifacts are
|
|
37
|
+
* meant to be processed by a Solid-aware JSX transformer.
|
|
38
|
+
* 2. Its package directory contains at least one `.jsx` / `.tsx`
|
|
39
|
+
* source file under `dist` / `lib` / `build` / `es` / `esm` /
|
|
40
|
+
* `out` (the common published-output dirs) or directly at the
|
|
41
|
+
* package root. We deliberately skip `node_modules`, `src` (raw
|
|
42
|
+
* sources, not what `main` points to), and test dirs.
|
|
43
|
+
*
|
|
44
|
+
* Both checks are scoped to packages installed in the app's
|
|
45
|
+
* `node_modules` (plus the monorepo's hoisted `node_modules`, if any)
|
|
46
|
+
* — we never recurse into transitive nested copies, since those are
|
|
47
|
+
* also reachable from the same top-level scan once Vite resolves them.
|
|
48
|
+
*/
|
|
49
|
+
const PUBLISHED_OUTPUT_DIRS = new Set(['dist', 'lib', 'build', 'es', 'esm', 'out']);
|
|
50
|
+
// Always-skip subdirs regardless of depth: nested copies, test fixtures,
|
|
51
|
+
// docs, and example apps. Notably `src` is NOT in here because a published
|
|
52
|
+
// bundle may use `dist/src/<file>.jsx` as its layout (e.g. `solid-navigation`).
|
|
53
|
+
// `src/` at the *package root* is rejected separately by the
|
|
54
|
+
// "depth 0 must be a published-output dir" gate below.
|
|
55
|
+
const ALWAYS_SKIP_DIR_NAMES = new Set(['node_modules', 'test', 'tests', '__tests__', 'spec', 'specs', 'docs', 'examples', 'example', '.git', '.cache']);
|
|
56
|
+
const JSX_EXT_RE = /\.(jsx|tsx)$/;
|
|
57
|
+
const MAX_SCAN_DEPTH = 4;
|
|
58
|
+
function isSolidConsumer(pkgJson) {
|
|
59
|
+
const buckets = ['dependencies', 'peerDependencies', 'devDependencies', 'optionalDependencies'];
|
|
60
|
+
for (const key of buckets) {
|
|
61
|
+
const deps = pkgJson[key];
|
|
62
|
+
if (!deps || typeof deps !== 'object')
|
|
63
|
+
continue;
|
|
64
|
+
if (deps['solid-js'])
|
|
65
|
+
return true;
|
|
66
|
+
if (deps['@nativescript-community/solid-js'])
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function hasJsxFile(dir, depth = 0) {
|
|
72
|
+
if (depth > MAX_SCAN_DEPTH)
|
|
73
|
+
return false;
|
|
74
|
+
let entries;
|
|
75
|
+
try {
|
|
76
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
if (entry.isFile() && JSX_EXT_RE.test(entry.name)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
if (entry.name.startsWith('.'))
|
|
87
|
+
continue;
|
|
88
|
+
if (ALWAYS_SKIP_DIR_NAMES.has(entry.name))
|
|
89
|
+
continue;
|
|
90
|
+
// At depth 0 (package root) only descend into known
|
|
91
|
+
// published-output dirs so a sibling `src/` (raw sources)
|
|
92
|
+
// can't flag the package on its own. Deeper levels are
|
|
93
|
+
// inside a publish dir already, so any subdir (incl. `src`)
|
|
94
|
+
// is fair game.
|
|
95
|
+
if (depth === 0 && !PUBLISHED_OUTPUT_DIRS.has(entry.name))
|
|
96
|
+
continue;
|
|
97
|
+
if (hasJsxFile(path.join(dir, entry.name), depth + 1))
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
function scanDirectoryForJsxPackages(nodeModulesDir, result, scope = '') {
|
|
104
|
+
let entries;
|
|
105
|
+
try {
|
|
106
|
+
entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
if (!entry.isDirectory())
|
|
113
|
+
continue;
|
|
114
|
+
if (entry.name.startsWith('.'))
|
|
115
|
+
continue;
|
|
116
|
+
if (entry.name === 'node_modules')
|
|
117
|
+
continue;
|
|
118
|
+
const entryPath = path.join(nodeModulesDir, entry.name);
|
|
119
|
+
if (!scope && entry.name.startsWith('@')) {
|
|
120
|
+
scanDirectoryForJsxPackages(entryPath, result, entry.name);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const pkgName = scope ? `${scope}/${entry.name}` : entry.name;
|
|
124
|
+
if (result.has(pkgName))
|
|
125
|
+
continue;
|
|
126
|
+
const pkgJsonPath = path.join(entryPath, 'package.json');
|
|
127
|
+
if (!fs.existsSync(pkgJsonPath))
|
|
128
|
+
continue;
|
|
129
|
+
let pkgJson;
|
|
130
|
+
try {
|
|
131
|
+
pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (!isSolidConsumer(pkgJson))
|
|
137
|
+
continue;
|
|
138
|
+
if (!hasJsxFile(entryPath))
|
|
139
|
+
continue;
|
|
140
|
+
result.add(pkgName);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Find installed packages whose pre-bundle output would smuggle JSX into
|
|
145
|
+
* Vite's import-analysis stage. Returned names are safe to drop into
|
|
146
|
+
* `optimizeDeps.exclude` — the dev server will serve them through the
|
|
147
|
+
* normal module pipeline, where `vite-plugin-solid` can transform their
|
|
148
|
+
* original `.jsx`/`.tsx` files.
|
|
149
|
+
*
|
|
150
|
+
* The function is intentionally synchronous and best-effort: filesystem
|
|
151
|
+
* errors are swallowed, missing directories are skipped, and the scan
|
|
152
|
+
* caps at {@link MAX_SCAN_DEPTH} levels per package. Callers should
|
|
153
|
+
* treat the empty-array result as "no exclusions needed", not "scan
|
|
154
|
+
* failed". A nullable `monorepoRoot` is accepted so workspace hoisting
|
|
155
|
+
* is covered without forcing every caller to compute it.
|
|
156
|
+
*/
|
|
157
|
+
export function findSolidPackagesShippingJsx(projectRoot, monorepoRoot) {
|
|
158
|
+
const found = new Set();
|
|
159
|
+
const seenDirs = new Set();
|
|
160
|
+
const scanDirs = [];
|
|
161
|
+
const projectNodeModules = path.resolve(projectRoot, 'node_modules');
|
|
162
|
+
scanDirs.push(projectNodeModules);
|
|
163
|
+
if (monorepoRoot && path.resolve(monorepoRoot) !== path.resolve(projectRoot)) {
|
|
164
|
+
const monorepoNodeModules = path.resolve(monorepoRoot, 'node_modules');
|
|
165
|
+
scanDirs.push(monorepoNodeModules);
|
|
166
|
+
}
|
|
167
|
+
for (const dir of scanDirs) {
|
|
168
|
+
const key = path.resolve(dir);
|
|
169
|
+
if (seenDirs.has(key))
|
|
170
|
+
continue;
|
|
171
|
+
seenDirs.add(key);
|
|
172
|
+
if (!fs.existsSync(dir))
|
|
173
|
+
continue;
|
|
174
|
+
scanDirectoryForJsxPackages(dir, found);
|
|
175
|
+
}
|
|
176
|
+
return Array.from(found).sort();
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=solid-jsx-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-jsx-deps.js","sourceRoot":"","sources":["../../../../../../../packages/vite/hmr/frameworks/solid/build/solid-jsx-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACpF,yEAAyE;AACzE,2EAA2E;AAC3E,gFAAgF;AAChF,6DAA6D;AAC7D,uDAAuD;AACvD,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,C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