@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.30
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 +369 -159
- 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/angular/angular-linker.d.ts +5 -6
- package/helpers/angular/angular-linker.js +36 -121
- package/helpers/angular/angular-linker.js.map +1 -1
- package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
- package/helpers/angular/inject-component-hmr-registration.js +291 -0
- package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
- package/helpers/angular/inject-hmr-vite-ignore.d.ts +75 -0
- package/helpers/angular/inject-hmr-vite-ignore.js +221 -0
- package/helpers/angular/inject-hmr-vite-ignore.js.map +1 -0
- package/helpers/angular/inline-decorator-component-templates.js +1 -170
- package/helpers/angular/inline-decorator-component-templates.js.map +1 -1
- package/helpers/angular/js-lexer.d.ts +4 -0
- package/helpers/angular/js-lexer.js +182 -0
- package/helpers/angular/js-lexer.js.map +1 -0
- package/helpers/angular/shared-linker.d.ts +31 -3
- package/helpers/angular/shared-linker.js +67 -14
- package/helpers/angular/shared-linker.js.map +1 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js +2 -170
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -1
- package/helpers/angular/synthesize-injectable-factories.js +1 -174
- package/helpers/angular/synthesize-injectable-factories.js.map +1 -1
- package/helpers/angular/util.d.ts +1 -0
- package/helpers/angular/util.js +88 -0
- package/helpers/angular/util.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/prelink-angular.js +12 -33
- package/helpers/prelink-angular.js.map +1 -1
- package/helpers/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/solid-jsx-deps.d.ts +15 -0
- package/helpers/solid-jsx-deps.js +178 -0
- package/helpers/solid-jsx-deps.js.map +1 -0
- 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/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 +419 -15
- 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/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/client/vue-sfc-update-overlay.js.map +1 -0
- 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/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/server/linker.js +1 -4
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +13 -15
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/solid/server/strategy.js +3 -18
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +2 -15
- 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/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/angular-root-component.d.ts +79 -0
- package/hmr/server/angular-root-component.js +149 -0
- package/hmr/server/angular-root-component.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/framework-strategy.d.ts +9 -19
- 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.js +60 -8
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +1 -0
- 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/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/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/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-angular-entry.js +1 -1
- package/hmr/server/websocket-angular-entry.js.map +1 -1
- package/hmr/server/websocket-angular-hot-update.d.ts +17 -0
- package/hmr/server/websocket-angular-hot-update.js +176 -2
- package/hmr/server/websocket-angular-hot-update.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 +21 -0
- package/hmr/server/websocket-device-transform.js +1570 -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 +43 -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 +51 -0
- package/hmr/server/websocket-hot-update.js +1160 -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 +44 -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 +305 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +22 -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 +34 -0
- package/hmr/server/websocket-ns-m.js +853 -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-sfc.d.ts +24 -0
- package/hmr/server/websocket-sfc.js +1223 -0
- package/hmr/server/websocket-sfc.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 +10 -0
- package/hmr/server/websocket-vendor-unifier.js +45 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket.d.ts +0 -30
- package/hmr/server/websocket.js +599 -6038
- package/hmr/server/websocket.js.map +1 -1
- 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 +32 -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 -5
- package/hmr/shared/vendor/manifest.js +102 -739
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgC,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgC,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAwB,qBAAqB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE/J;;;;;GAKG;AACH,SAAS,0BAA0B;IAClC,MAAM,UAAU,GAAG,4BAA4B,CAAC;IA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,kDAAkD,CAAC;gBAClE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC3B,OAAO;wBACN,IAAI,EAAE,IAAI,CAAC,OAAO,CACjB,MAAM,EACN,GAAG,MAAM,8qEAA8qE,CACvrE;wBACD,GAAG,EAAE,IAAI;qBACT,CAAC;gBACH,CAAC;YACF,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,EAAc,EAAE;IACxD,OAAO,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;QACxC,OAAO,EAAE,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,CAAC;KAClF,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/configuration/solid.js
CHANGED
|
@@ -3,10 +3,11 @@ import path from 'path';
|
|
|
3
3
|
import alias from '@rollup/plugin-alias';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { dirname, resolve } from 'node:path';
|
|
6
|
-
import { getProjectRootPath } from '../helpers/project.js';
|
|
6
|
+
import { findMonorepoWorkspaceRoot, getProjectRootPath } from '../helpers/project.js';
|
|
7
7
|
import { mergeConfig } from 'vite';
|
|
8
8
|
import { baseConfig } from './base.js';
|
|
9
9
|
import { getTypeCheckPlugins } from '../helpers/typescript-check.js';
|
|
10
|
+
import { findSolidPackagesShippingJsx } from '../helpers/solid-jsx-deps.js';
|
|
10
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
12
|
const __dirname = dirname(__filename);
|
|
12
13
|
const projectRoot = getProjectRootPath();
|
|
@@ -50,8 +51,33 @@ const plugins = [
|
|
|
50
51
|
}),
|
|
51
52
|
];
|
|
52
53
|
export const solidConfig = ({ mode }, options = {}) => {
|
|
54
|
+
const projectRoot = getProjectRootPath();
|
|
55
|
+
const monorepoRoot = findMonorepoWorkspaceRoot(projectRoot);
|
|
56
|
+
// Any Solid library that ships `.jsx`/`.tsx` files in its published
|
|
57
|
+
// output (e.g. `solid-navigation`'s `dist/src/*.jsx`) MUST bypass
|
|
58
|
+
// Vite's depscanner. The depscanner concatenates the package into
|
|
59
|
+
// `node_modules/.vite/deps/<pkg>.js` with the JSX preserved, then
|
|
60
|
+
// `vite:import-analysis` hits the first JSX expression and aborts the
|
|
61
|
+
// dev server with `Failed to parse source for import analysis…`. The
|
|
62
|
+
// `vite-plugin-solid` `transform` hook only runs on ids ending in
|
|
63
|
+
// `.jsx`/`.tsx`, so it never sees the pre-bundled `.js` to fix it.
|
|
64
|
+
// Excluding these packages routes them through the normal serve
|
|
65
|
+
// pipeline, where the original `.jsx` ids match the Solid plugin's
|
|
66
|
+
// filter. See `helpers/solid-jsx-deps.ts` for the detection rules.
|
|
67
|
+
const solidJsxPackages = findSolidPackagesShippingJsx(projectRoot, monorepoRoot);
|
|
53
68
|
return mergeConfig(baseConfig({ mode, flavor: 'solid' }), {
|
|
54
69
|
plugins: [...getTypeCheckPlugins('solid', options.typeCheck), ...plugins],
|
|
70
|
+
optimizeDeps: {
|
|
71
|
+
// Defense-in-depth: keep `module` / `node:module` out of the
|
|
72
|
+
// depscanner's pre-bundle set even if a downstream config swaps
|
|
73
|
+
// out the base `optimizeDeps.exclude`. The root rationale (and the
|
|
74
|
+
// canonical exclude list) lives in `configuration/base.ts`; see
|
|
75
|
+
// the comment above `optimizeDepsExclude` there for the full
|
|
76
|
+
// css-tree → createRequire → HMR rewrite chain that necessitates
|
|
77
|
+
// this. Vite's `mergeConfig` concatenates `exclude` arrays, so
|
|
78
|
+
// duplicating these here is harmless.
|
|
79
|
+
exclude: ['module', 'node:module', ...solidJsxPackages],
|
|
80
|
+
},
|
|
55
81
|
});
|
|
56
82
|
};
|
|
57
83
|
//# sourceMappingURL=solid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/solid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"solid.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/solid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAmB,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAgC,MAAM,gCAAgC,CAAC;AACnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;AACzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;AAErE,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AA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WAAW,GAAG,kBAAkB,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;IAC5D,oEAAoE;IACpE,kEAAkE;IAClE,kEAAkE;IAClE,kEAAkE;IAClE,sEAAsE;IACtE,qEAAqE;IACrE,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,mEAAmE;IACnE,mEAAmE;IACnE,MAAM,gBAAgB,GAAG,4BAA4B,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACjF,OAAO,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE;QACzD,OAAO,EAAE,CAAC,GAAG,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC;QACzE,YAAY,EAAE;YACb,6DAA6D;YAC7D,gEAAgE;YAChE,mEAAmE;YACnE,gEAAgE;YAChE,6DAA6D;YAC7D,iEAAiE;YACjE,+DAA+D;YAC/D,sCAAsC;YACtC,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAAC;SACvD;KACD,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mergeConfig } from 'vite';
|
|
2
|
-
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import { baseConfig } from './base.js';
|
|
5
4
|
import { getCliFlags } from '../helpers/cli-flags.js';
|
|
6
5
|
import { getPackageJson, getProjectFilePath, getProjectRootPath } from '../helpers/project.js';
|
|
7
6
|
import { getProjectAppPath } from '../helpers/utils.js';
|
|
8
7
|
import { getTypeCheckPlugins } from '../helpers/typescript-check.js';
|
|
8
|
+
import { createXmlLoaderPlugin, shouldExcludePlatformFile, toContextImportSpecifier, walkAppFiles } from '../helpers/bundler-context.js';
|
|
9
9
|
/**
|
|
10
10
|
* TypeScript + XML NativeScript Vite configuration.
|
|
11
11
|
* Adds a virtual require.context style registry (xml, js, ts, css, scss) similar to webpack5.
|
|
@@ -41,56 +41,7 @@ function createBundlerContextPlugin() {
|
|
|
41
41
|
return null;
|
|
42
42
|
// Build platform-filtered static module registry similar to webpack's require.context.
|
|
43
43
|
// Generic: only XML, styles and their paired code-behind files. Test/app specific additions belong in app vite.config.ts.
|
|
44
|
-
const
|
|
45
|
-
function walk(dir, out) {
|
|
46
|
-
let entries = [];
|
|
47
|
-
try {
|
|
48
|
-
entries = readdirSync(dir);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return out;
|
|
52
|
-
}
|
|
53
|
-
for (const entry of entries) {
|
|
54
|
-
const full = path.posix.join(dir, entry);
|
|
55
|
-
let st;
|
|
56
|
-
try {
|
|
57
|
-
st = statSync(full);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (st.isDirectory())
|
|
63
|
-
walk(full, out);
|
|
64
|
-
else
|
|
65
|
-
out.push(full);
|
|
66
|
-
}
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
|
-
function listAll() {
|
|
70
|
-
const files = [];
|
|
71
|
-
for (const r of roots)
|
|
72
|
-
walk(r, files);
|
|
73
|
-
return files;
|
|
74
|
-
}
|
|
75
|
-
function shouldExcludeAbsolute(p) {
|
|
76
|
-
const file = p.split('/').pop() || '';
|
|
77
|
-
if (file.startsWith('_'))
|
|
78
|
-
return true;
|
|
79
|
-
if (/\.d\.ts$/.test(p))
|
|
80
|
-
return true;
|
|
81
|
-
if (/([.-]worker)\.(ts|js)$/.test(file))
|
|
82
|
-
return true;
|
|
83
|
-
const isAndroidTagged = /\.android\./.test(p);
|
|
84
|
-
const isIosTagged = /\.ios\./.test(p) || /\.visionos\./.test(p);
|
|
85
|
-
if (platform === 'android' && isIosTagged)
|
|
86
|
-
return true;
|
|
87
|
-
if (['ios', 'visionos'].includes(platform) && isAndroidTagged)
|
|
88
|
-
return true;
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
function toImportSpecifier(abs) {
|
|
92
|
-
return '/' + abs.replace(/^\/+/, '');
|
|
93
|
-
}
|
|
44
|
+
const toImportSpecifier = toContextImportSpecifier;
|
|
94
45
|
function toCtxKey(abs) {
|
|
95
46
|
let rel = abs;
|
|
96
47
|
if (rel.startsWith(appRootPrefix))
|
|
@@ -99,7 +50,7 @@ function createBundlerContextPlugin() {
|
|
|
99
50
|
rel = rel.slice('packages/core/src/'.length);
|
|
100
51
|
return './' + rel;
|
|
101
52
|
}
|
|
102
|
-
const allFiles =
|
|
53
|
+
const allFiles = walkAppFiles(appRoot).filter((f) => !shouldExcludePlatformFile(f, platform));
|
|
103
54
|
const xmlFiles = allFiles.filter((f) => f.endsWith('.xml'));
|
|
104
55
|
const styleFiles = allFiles.filter((f) => /\.(css|scss|less|sass)$/.test(f));
|
|
105
56
|
// Import only code-behind files paired with XML (mirrors webpack's contextual resolution)
|
|
@@ -131,7 +82,7 @@ function createBundlerContextPlugin() {
|
|
|
131
82
|
// Sort code files as well for determinism (some tests rely on early registration of core pages/components)
|
|
132
83
|
codeFiles.sort((a, b) => a.localeCompare(b)).forEach((f) => pushImport(f, false));
|
|
133
84
|
// We no longer manually register nickname modules here; core's registerBundlerModules already adds nicknames.
|
|
134
|
-
const code = `// Generated virtual bundler context (platform=${platform || 'unknown'})\n${importLines.join('\n')}\n(function(){\n const registry = new Map();\n const all = {};\n ${moduleMapLines.join('\n ')}\n ${registryEntries.join('\n ')}\n function context(key){\n const real = registry.get(key);\n if(!real) throw new Error('[ns-vite] Module not found in context: '+key);\n return all[real];\n }\n context.keys = function(){ return Array.from(registry.keys()); };\n // Register modules now with extension map so .ts/.scss nicknames resolve like webpack\n try { if (global.registerBundlerModules) { global.registerBundlerModules(context, { '.ts': '.js', '.scss': '.css', '.sass': '.css', '.less': '.css' }); } } catch(e) {
|
|
85
|
+
const code = `// Generated virtual bundler context (platform=${platform || 'unknown'})\n${importLines.join('\n')}\n(function(){\n const registry = new Map();\n const all = {};\n ${moduleMapLines.join('\n ')}\n ${registryEntries.join('\n ')}\n function context(key){\n const real = registry.get(key);\n if(!real) throw new Error('[ns-vite] Module not found in context: '+key);\n return all[real];\n }\n context.keys = function(){ return Array.from(registry.keys()); };\n // Register modules now with extension map so .ts/.scss nicknames resolve like webpack\n try { if (global.registerBundlerModules) { global.registerBundlerModules(context, { '.ts': '.js', '.scss': '.css', '.sass': '.css', '.less': '.css' }); } } catch(e) { console.warn('[ns-vite] registerBundlerModules error', e); }\n // Safety: ensure main-page nickname exists if XML present\n try {\n const hasMainPageXml = context.keys().some(k => /(^\\.\\/?main-page\\.xml$|\\/main-page\\.xml$)/.test(k));\n if (hasMainPageXml && global.moduleExists && !global.moduleExists('main-page') && global.registerBundlerModules) {\n global.registerBundlerModules(context, { '.ts': '.js', '.scss': '.css', '.sass': '.css', '.less': '.css' });\n }\n } catch(_) {}\n})();`;
|
|
135
86
|
return { code, map: null };
|
|
136
87
|
},
|
|
137
88
|
transform(code, id) {
|
|
@@ -148,30 +99,9 @@ function createBundlerContextPlugin() {
|
|
|
148
99
|
},
|
|
149
100
|
};
|
|
150
101
|
}
|
|
151
|
-
function createXmlLoaderPlugin() {
|
|
152
|
-
return {
|
|
153
|
-
name: 'ns-xml-loader-ts',
|
|
154
|
-
enforce: 'pre',
|
|
155
|
-
load(id) {
|
|
156
|
-
if (!id.endsWith('.xml'))
|
|
157
|
-
return null;
|
|
158
|
-
try {
|
|
159
|
-
const src = readFileSync(id, 'utf-8');
|
|
160
|
-
const xml = JSON.stringify(src)
|
|
161
|
-
.replace(/\u2028/g, '\\u2028')
|
|
162
|
-
.replace(/\u2029/g, '\\u2029');
|
|
163
|
-
const code = `const ___XML___ = ${xml};\nexport default ___XML___;`;
|
|
164
|
-
return { code, map: null };
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
102
|
export const typescriptConfig = ({ mode }, options = {}) => {
|
|
173
103
|
return mergeConfig(baseConfig({ mode, flavor: 'typescript' }), {
|
|
174
|
-
plugins: [...getTypeCheckPlugins('typescript', options.typeCheck), createXmlLoaderPlugin(), createBundlerContextPlugin()],
|
|
104
|
+
plugins: [...getTypeCheckPlugins('typescript', options.typeCheck), createXmlLoaderPlugin('ns-xml-loader-ts'), createBundlerContextPlugin()],
|
|
175
105
|
});
|
|
176
106
|
};
|
|
177
107
|
//# sourceMappingURL=typescript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgC,MAAM,MAAM,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgC,MAAM,MAAM,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,gCAAgC,CAAC;AACnG,OAAO,EAAwB,qBAAqB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE/J;;;;GAIG;AACH,SAAS,0BAA0B;IAClC,MAAM,UAAU,GAAG,4BAA4B,CAAC;IAChD,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,CAAC;IACtC,MAAM,KAAK,G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CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE;QAC9D,OAAO,EAAE,CAAC,GAAG,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,EAAE,0BAA0B,EAAE,CAAC;KAC3I,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
/**
|
|
3
|
-
* Vite plugin to run Angular linker (Babel) over partial-compiled Angular
|
|
4
|
-
* inside node_modules (e.g
|
|
5
|
-
*
|
|
6
|
-
* This converts ɵɵngDeclare* calls to ɵɵdefine* so runtime doesn't require the JIT compiler.
|
|
3
|
+
* Vite plugin to run the Angular linker (Babel) over partial-compiled Angular
|
|
4
|
+
* libraries inside node_modules (e.g. @angular/*, @nativescript/angular),
|
|
5
|
+
* converting ɵɵngDeclare* calls to ɵɵdefine* so the runtime doesn't need JIT.
|
|
7
6
|
*/
|
|
8
7
|
export declare function angularLinkerVitePlugin(projectRoot?: string): Plugin;
|
|
9
8
|
/**
|
|
10
|
-
* Post-phase linker: catches any ɵɵngDeclare* introduced by downstream
|
|
11
|
-
* including
|
|
9
|
+
* Post-phase linker: catches any ɵɵngDeclare* introduced by downstream
|
|
10
|
+
* transforms (e.g. optimizer) including project source, after other plugins run.
|
|
12
11
|
*/
|
|
13
12
|
export declare function angularLinkerVitePluginPost(projectRoot?: string): Plugin;
|
|
@@ -1,67 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ensureSharedAngularLinker, resolveAngularFileSystem } from './shared-linker.js';
|
|
1
|
+
import { runAngularLinker } from './shared-linker.js';
|
|
3
2
|
import { containsRealNgDeclare } from './util.js';
|
|
3
|
+
function normalizeAngularLinkerId(id) {
|
|
4
|
+
return id.split('?', 1)[0].replace(/\\/g, '/');
|
|
5
|
+
}
|
|
6
|
+
function isDebug() {
|
|
7
|
+
return process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
|
-
* Vite plugin to run Angular linker (Babel) over partial-compiled Angular
|
|
6
|
-
* inside node_modules (e.g
|
|
7
|
-
*
|
|
8
|
-
* This converts ɵɵngDeclare* calls to ɵɵdefine* so runtime doesn't require the JIT compiler.
|
|
10
|
+
* Vite plugin to run the Angular linker (Babel) over partial-compiled Angular
|
|
11
|
+
* libraries inside node_modules (e.g. @angular/*, @nativescript/angular),
|
|
12
|
+
* converting ɵɵngDeclare* calls to ɵɵdefine* so the runtime doesn't need JIT.
|
|
9
13
|
*/
|
|
10
14
|
export function angularLinkerVitePlugin(projectRoot) {
|
|
11
|
-
const req = createRequire(projectRoot ? projectRoot + '/package.json' : import.meta.url);
|
|
12
|
-
let babel = null;
|
|
13
|
-
let createLinker = null;
|
|
14
|
-
let angularFileSystem = null;
|
|
15
|
-
async function ensureDeps() {
|
|
16
|
-
if (babel && createLinker)
|
|
17
|
-
return;
|
|
18
|
-
try {
|
|
19
|
-
const babelPath = req.resolve('@babel/core');
|
|
20
|
-
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
21
|
-
babel = (await import(babelPath));
|
|
22
|
-
const linkerMod = await import(linkerPath);
|
|
23
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
// Fall back to hoisted resolution if necessary
|
|
27
|
-
try {
|
|
28
|
-
babel = (await import('@babel/core'));
|
|
29
|
-
}
|
|
30
|
-
catch { }
|
|
31
|
-
try {
|
|
32
|
-
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
33
|
-
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
34
|
-
}
|
|
35
|
-
catch { }
|
|
36
|
-
}
|
|
37
|
-
if (!angularFileSystem) {
|
|
38
|
-
angularFileSystem = await resolveAngularFileSystem(projectRoot);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
15
|
// Base filter: Angular framework libraries + NativeScript Angular + its polyfills bundle.
|
|
42
16
|
const FILTER = /node_modules\/(?:@angular|@nativescript\/angular)\/.*\.[mc]?js$|nativescript-angular-polyfills\.mjs$/;
|
|
43
|
-
// Extended filter: ANY node_modules .js/.mjs file
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
// may not re-run for cached chunks, so we must link at the transform level.
|
|
17
|
+
// Extended filter: ANY node_modules .js/.mjs file — catches Angular ecosystem
|
|
18
|
+
// packages (ngrx, etc.) carrying ɵɵngDeclare* partials. Vite 8 watch rebuilds
|
|
19
|
+
// may skip chunk-level linker fallbacks for cached chunks, so link at transform.
|
|
47
20
|
const NODE_MODULES_FILTER = /node_modules\/.*\.[mc]?js$/;
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
// This is primarily for NativeScript strict / HMR flows so that no partial
|
|
51
|
-
// declarations survive into the device bundle and trigger the JIT runtime.
|
|
21
|
+
// NS_STRICT_NG_LINK_ALL=1 aggressively links any JS/ESM file with a real
|
|
22
|
+
// ɵɵngDeclare* call site so no partials survive into the device bundle.
|
|
52
23
|
const strictAll = process.env.NS_STRICT_NG_LINK_ALL === '1' || process.env.NS_STRICT_NG_LINK_ALL === 'true';
|
|
53
24
|
return {
|
|
54
25
|
name: 'ns-angular-linker-vite',
|
|
55
26
|
enforce: 'pre',
|
|
56
27
|
async load(id) {
|
|
57
|
-
const
|
|
58
|
-
const cleanId = id.split('?', 1)[0];
|
|
59
|
-
// Always process Angular framework libraries. For other node_modules,
|
|
60
|
-
// check if they contain ɵɵngDeclare* (catches @ngrx, etc.).
|
|
28
|
+
const cleanId = normalizeAngularLinkerId(id);
|
|
61
29
|
if (!strictAll && !FILTER.test(cleanId)) {
|
|
62
30
|
if (!NODE_MODULES_FILTER.test(cleanId))
|
|
63
31
|
return null;
|
|
64
|
-
// For non-framework node_modules, peek at the file to see if it has partials
|
|
65
32
|
try {
|
|
66
33
|
const fs = await import('node:fs/promises');
|
|
67
34
|
const peek = await fs.readFile(cleanId, 'utf8');
|
|
@@ -77,40 +44,20 @@ export function angularLinkerVitePlugin(projectRoot) {
|
|
|
77
44
|
const code = await fs.readFile(cleanId, 'utf8');
|
|
78
45
|
if (!code)
|
|
79
46
|
return null;
|
|
80
|
-
// Under NS_STRICT_NG_LINK_ALL we will attempt to link **any** file
|
|
81
|
-
// that actually contains a ɵɵngDeclare* call site.
|
|
82
47
|
if (strictAll && !FILTER.test(cleanId) && !containsRealNgDeclare(code))
|
|
83
48
|
return null;
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
console.log('[ns-angular-linker][vite-load] linking', cleanId);
|
|
90
|
-
}
|
|
91
|
-
catch { }
|
|
92
|
-
}
|
|
93
|
-
const result = await babel.transformAsync(code, {
|
|
94
|
-
filename: cleanId,
|
|
95
|
-
configFile: false,
|
|
96
|
-
babelrc: false,
|
|
97
|
-
sourceMaps: false,
|
|
98
|
-
compact: false,
|
|
99
|
-
plugins: [linkerPlugin],
|
|
100
|
-
});
|
|
101
|
-
if (result?.code && result.code !== code) {
|
|
102
|
-
return { code: result.code, map: null };
|
|
49
|
+
const linked = await runAngularLinker(code, { filename: cleanId, projectRoot });
|
|
50
|
+
if (linked) {
|
|
51
|
+
if (isDebug())
|
|
52
|
+
console.log('[ns-angular-linker][vite-load] linked', cleanId);
|
|
53
|
+
return { code: linked, map: null };
|
|
103
54
|
}
|
|
104
55
|
}
|
|
105
56
|
catch { }
|
|
106
57
|
return null;
|
|
107
58
|
},
|
|
108
59
|
async transform(code, id) {
|
|
109
|
-
const
|
|
110
|
-
// Strip Vite/Rollup query strings before testing
|
|
111
|
-
const cleanId = id.split('?', 1)[0];
|
|
112
|
-
// Always process Angular framework libraries. For other node_modules,
|
|
113
|
-
// only link if they contain ɵɵngDeclare* (catches @ngrx, etc.).
|
|
60
|
+
const cleanId = normalizeAngularLinkerId(id);
|
|
114
61
|
if (!strictAll && !FILTER.test(cleanId)) {
|
|
115
62
|
if (!NODE_MODULES_FILTER.test(cleanId) || !code || !containsRealNgDeclare(code))
|
|
116
63
|
return null;
|
|
@@ -119,71 +66,39 @@ export function angularLinkerVitePlugin(projectRoot) {
|
|
|
119
66
|
return null;
|
|
120
67
|
if (strictAll && !FILTER.test(cleanId) && !containsRealNgDeclare(code))
|
|
121
68
|
return null;
|
|
122
|
-
await ensureDeps();
|
|
123
|
-
if (!babel || !createLinker)
|
|
124
|
-
return null;
|
|
125
69
|
try {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
console.log('[ns-angular-linker][vite]
|
|
130
|
-
}
|
|
131
|
-
catch { }
|
|
132
|
-
}
|
|
133
|
-
const result = await babel.transformAsync(code, {
|
|
134
|
-
filename: cleanId,
|
|
135
|
-
configFile: false,
|
|
136
|
-
babelrc: false,
|
|
137
|
-
sourceMaps: false,
|
|
138
|
-
compact: false,
|
|
139
|
-
plugins: [plugin],
|
|
140
|
-
});
|
|
141
|
-
if (result?.code && result.code !== code) {
|
|
142
|
-
return { code: result.code, map: null };
|
|
70
|
+
const linked = await runAngularLinker(code, { filename: cleanId, projectRoot, freshPlugin: true });
|
|
71
|
+
if (linked) {
|
|
72
|
+
if (isDebug())
|
|
73
|
+
console.log('[ns-angular-linker][vite] linked', cleanId);
|
|
74
|
+
return { code: linked, map: null };
|
|
143
75
|
}
|
|
144
76
|
}
|
|
145
|
-
catch {
|
|
146
|
-
// Soft-fail; return original code
|
|
147
|
-
}
|
|
77
|
+
catch { }
|
|
148
78
|
return null;
|
|
149
79
|
},
|
|
150
80
|
};
|
|
151
81
|
}
|
|
152
82
|
/**
|
|
153
|
-
* Post-phase linker: catches any ɵɵngDeclare* introduced by downstream
|
|
154
|
-
* including
|
|
83
|
+
* Post-phase linker: catches any ɵɵngDeclare* introduced by downstream
|
|
84
|
+
* transforms (e.g. optimizer) including project source, after other plugins run.
|
|
155
85
|
*/
|
|
156
86
|
export function angularLinkerVitePluginPost(projectRoot) {
|
|
157
87
|
return {
|
|
158
88
|
name: 'ns-angular-linker-vite-post',
|
|
159
89
|
enforce: 'post',
|
|
160
90
|
async transform(code, id) {
|
|
161
|
-
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
162
|
-
// Only JS/ESM files
|
|
163
91
|
if (!/\.(m?js)(\?|$)/.test(id))
|
|
164
92
|
return null;
|
|
165
93
|
if (!code || !containsRealNgDeclare(code))
|
|
166
94
|
return null;
|
|
167
|
-
const { babel, linkerPlugin } = await ensureSharedAngularLinker(projectRoot);
|
|
168
|
-
if (!babel || !linkerPlugin)
|
|
169
|
-
return null;
|
|
170
95
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const result = await babel.transformAsync(code, {
|
|
178
|
-
filename: id.split('?', 1)[0],
|
|
179
|
-
configFile: false,
|
|
180
|
-
babelrc: false,
|
|
181
|
-
sourceMaps: false,
|
|
182
|
-
compact: false,
|
|
183
|
-
plugins: [linkerPlugin],
|
|
184
|
-
});
|
|
185
|
-
if (result?.code && result.code !== code) {
|
|
186
|
-
return { code: result.code, map: null };
|
|
96
|
+
const filename = id.split('?', 1)[0];
|
|
97
|
+
const linked = await runAngularLinker(code, { filename, projectRoot });
|
|
98
|
+
if (linked) {
|
|
99
|
+
if (isDebug())
|
|
100
|
+
console.log('[ns-angular-linker][vite-post] linked', filename);
|
|
101
|
+
return { code: linked, map: null };
|
|
187
102
|
}
|
|
188
103
|
}
|
|
189
104
|
catch { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-linker.js","sourceRoot":"","sources":["../../../../../packages/vite/helpers/angular/angular-linker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"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AM,gBAAgB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;gBACvE,IAAI,MAAM,EAAE,CAAC;oBACZ,IAAI,OAAO,EAAE;wBAAE,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,QAAQ,CAAC,CAAC;oBAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;gBACpC,CAAC;YACF,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite-side helper that injects HMR self-registration calls into the
|
|
3
|
+
* compiled output of user `.ts` files that declare `@Component`-
|
|
4
|
+
* decorated classes.
|
|
5
|
+
*
|
|
6
|
+
* After an HMR reboot, the global `__NS_HMR_REGISTER_COMPONENT__` hook
|
|
7
|
+
* (installed by `@nativescript/angular`) records each fresh class
|
|
8
|
+
* keyed by source name. HMR helpers (modal restore, route replay) read
|
|
9
|
+
* the registry to re-attach to the live class. See
|
|
10
|
+
* `hmr-class-registry.ts` for the runtime side of the contract.
|
|
11
|
+
*
|
|
12
|
+
* The helper exposes two phases used by complementary Vite plugins:
|
|
13
|
+
* 1. `findComponentClassNames(rawTs)` — scans the user's raw TS
|
|
14
|
+
* source for `@Component`-decorated classes. Used by an
|
|
15
|
+
* `enforce: 'pre'` plugin to discover names BEFORE the Analog
|
|
16
|
+
* Angular plugin compiles the file. The discovery has to happen
|
|
17
|
+
* on raw TS because the Angular plugin rewrites the `@Component`
|
|
18
|
+
* decorator into static metadata calls (`ɵsetClassMetadata`,
|
|
19
|
+
* `ɵɵdefineComponent`) and removes the textual `@Component(...)`
|
|
20
|
+
* pattern.
|
|
21
|
+
* 2. `appendComponentHmrRegistration(compiledCode, names)` — appends
|
|
22
|
+
* the registration snippet to the END of compiled JS produced by
|
|
23
|
+
* the Analog Angular plugin. Used by an `enforce: 'post'` plugin.
|
|
24
|
+
* Appending here is the only reliable insertion point because:
|
|
25
|
+
* - Class declarations are evaluated and bound by then.
|
|
26
|
+
* - Angular's static metadata (`ɵcmp`/`ɵfac`) has finished
|
|
27
|
+
* attaching, so the registered class identity already
|
|
28
|
+
* carries the up-to-date component definition.
|
|
29
|
+
* - The Analog Angular plugin's `transform` discards anything
|
|
30
|
+
* appended before its compilation step (it returns code
|
|
31
|
+
* regenerated from its own `outputFiles` cache, not the
|
|
32
|
+
* input passed in). Verified directly in the plugin chain.
|
|
33
|
+
* - Source-map line offsets for the original module body are
|
|
34
|
+
* preserved (we only append).
|
|
35
|
+
*
|
|
36
|
+
* The legacy `injectComponentHmrRegistration(rawTs)` helper is kept
|
|
37
|
+
* for backward compatibility — it appends to raw TS in a single call —
|
|
38
|
+
* but is no longer the path used by the live HMR pipeline (its output
|
|
39
|
+
* is silently dropped by the Angular plugin for `@Component` files).
|
|
40
|
+
*
|
|
41
|
+
* The helpers are dev-only: production builds skip the Vite plugins
|
|
42
|
+
* (`apply: 'serve'`), and the runtime hook short-circuits when
|
|
43
|
+
* `isAngularHmrEnabled()` is false.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Marker comment placed immediately before the appended registration
|
|
47
|
+
* block. Plugins can scan for this string to make their work
|
|
48
|
+
* idempotent across re-transforms (the Vite cache may replay the
|
|
49
|
+
* transform pipeline on cached modules).
|
|
50
|
+
*/
|
|
51
|
+
export declare const INJECTION_MARKER = "/* @nativescript/vite ns-hmr-register */";
|
|
52
|
+
export interface InjectComponentHmrRegistrationOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Optional override of the global hook name. Defaults to
|
|
55
|
+
* `__NS_HMR_REGISTER_COMPONENT__`. Exposed for tests; production
|
|
56
|
+
* callers should keep the default.
|
|
57
|
+
*/
|
|
58
|
+
hookName?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface InjectComponentHmrRegistrationResult {
|
|
61
|
+
/** New code, or `null` if no transformation is needed. */
|
|
62
|
+
code: string | null;
|
|
63
|
+
/** Names of `@Component` classes detected in the file. */
|
|
64
|
+
componentNames: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build the trailing snippet that registers each component class with
|
|
68
|
+
* the global HMR hook. Pure string construction — exposed so the post-
|
|
69
|
+
* Angular plugin can append it to compiled output without re-scanning
|
|
70
|
+
* for class names (the pre plugin already scanned the raw TS source).
|
|
71
|
+
*
|
|
72
|
+
* Returns an empty string when `componentNames` is empty so callers
|
|
73
|
+
* can concatenate unconditionally.
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildComponentHmrRegistrationSuffix(componentNames: string[], options?: InjectComponentHmrRegistrationOptions): string;
|
|
76
|
+
/**
|
|
77
|
+
* Append the registration snippet to a piece of code (typically the
|
|
78
|
+
* compiled output from `@analogjs/vite-plugin-angular`) using a list
|
|
79
|
+
* of component names previously discovered in the raw TS source.
|
|
80
|
+
*
|
|
81
|
+
* Returns `{ code: null, componentNames: [] }` if `componentNames`
|
|
82
|
+
* is empty or if the code already contains the injection marker
|
|
83
|
+
* (idempotent re-transform case).
|
|
84
|
+
*/
|
|
85
|
+
export declare function appendComponentHmrRegistration(code: string, componentNames: string[], options?: InjectComponentHmrRegistrationOptions): InjectComponentHmrRegistrationResult;
|
|
86
|
+
/**
|
|
87
|
+
* Legacy helper: scan raw TypeScript source for `@Component` classes
|
|
88
|
+
* and append registration calls. Retained for tests and for any
|
|
89
|
+
* caller running outside the post-Angular plugin chain.
|
|
90
|
+
*
|
|
91
|
+
* NOTE: For files compiled by `@analogjs/vite-plugin-angular`, this
|
|
92
|
+
* helper's output is discarded — the Angular plugin replaces the
|
|
93
|
+
* input code with the regenerated compiled output from its internal
|
|
94
|
+
* `outputFiles` cache. Use `findComponentClassNames(rawTs)` +
|
|
95
|
+
* `appendComponentHmrRegistration(compiledCode, names)` from a
|
|
96
|
+
* `enforce: 'post'` plugin to survive that compilation step.
|
|
97
|
+
*/
|
|
98
|
+
export declare function injectComponentHmrRegistration(code: string, options?: InjectComponentHmrRegistrationOptions): InjectComponentHmrRegistrationResult;
|
|
99
|
+
/**
|
|
100
|
+
* Walk a TS source string and collect class names declared after a
|
|
101
|
+
* `@Component(...)` decorator. Supports:
|
|
102
|
+
* - `export class Foo` and bare `class Foo`
|
|
103
|
+
* - `abstract class Foo` (rare for @Component but allowed)
|
|
104
|
+
* - Any number of additional decorators stacked between `@Component`
|
|
105
|
+
* and the class keyword (e.g. `@Component({}) @SomethingElse() ...`)
|
|
106
|
+
*
|
|
107
|
+
* Skips matches that fall inside string literals or comments. Uses a
|
|
108
|
+
* paren-matching scanner instead of regex `[\s\S]*?` so multi-line
|
|
109
|
+
* decorator arguments (templates, styles arrays) don't trip up the
|
|
110
|
+
* scanner.
|
|
111
|
+
*/
|
|
112
|
+
export declare function findComponentClassNames(code: string): string[];
|