@nativescript/vite 0.0.1-alpha.7 → 0.0.2
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/LICENSE +19 -0
- package/README.md +44 -0
- package/{dist/configuration → configuration}/angular.d.ts +1 -1
- package/configuration/angular.js +480 -0
- package/configuration/angular.js.map +1 -0
- package/configuration/base.d.ts +5 -0
- package/configuration/base.js +494 -0
- package/configuration/base.js.map +1 -0
- package/configuration/javascript.d.ts +4 -0
- package/configuration/javascript.js +151 -0
- package/configuration/javascript.js.map +1 -0
- package/{dist/configuration → configuration}/react.d.ts +1 -1
- package/{dist/configuration → configuration}/react.js +18 -17
- package/configuration/react.js.map +1 -0
- package/{dist/configuration → configuration}/solid.d.ts +1 -1
- package/{dist/configuration → configuration}/solid.js +17 -16
- package/configuration/solid.js.map +1 -0
- package/configuration/typescript.d.ts +4 -0
- package/configuration/typescript.js +175 -0
- package/configuration/typescript.js.map +1 -0
- package/{dist/configuration → configuration}/vue.d.ts +1 -1
- package/configuration/vue.js +163 -0
- package/configuration/vue.js.map +1 -0
- package/helpers/angular-linker.d.ts +13 -0
- package/helpers/angular-linker.js +181 -0
- package/helpers/angular-linker.js.map +1 -0
- package/helpers/cli-flags.d.ts +1 -0
- package/helpers/cli-flags.js +15 -0
- package/helpers/cli-flags.js.map +1 -0
- package/{dist/helpers → helpers}/commonjs-plugins.js +14 -13
- package/helpers/commonjs-plugins.js.map +1 -0
- package/{dist/helpers → helpers}/config-as-json.d.ts +1 -1
- package/{dist/helpers → helpers}/config-as-json.js +7 -6
- package/helpers/config-as-json.js.map +1 -0
- package/helpers/css-platform-plugin.d.ts +10 -0
- package/helpers/css-platform-plugin.js +76 -0
- package/helpers/css-platform-plugin.js.map +1 -0
- package/helpers/css-tree.js +22 -0
- package/helpers/css-tree.js.map +1 -0
- package/{dist/helpers → helpers}/dynamic-import-plugin.js +8 -7
- package/helpers/dynamic-import-plugin.js.map +1 -0
- package/helpers/esbuild-platform-resolver.d.ts +14 -0
- package/helpers/esbuild-platform-resolver.js +93 -0
- package/helpers/esbuild-platform-resolver.js.map +1 -0
- package/{dist/helpers → helpers}/external-configs.js +2 -1
- package/helpers/external-configs.js.map +1 -0
- package/{dist/helpers → helpers}/flavor.d.ts +1 -0
- package/helpers/flavor.js +51 -0
- package/helpers/flavor.js.map +1 -0
- package/{dist/helpers → helpers}/global-defines.d.ts +11 -3
- package/helpers/global-defines.js +24 -0
- package/helpers/global-defines.js.map +1 -0
- package/helpers/logging.d.ts +13 -0
- package/helpers/logging.js +111 -0
- package/helpers/logging.js.map +1 -0
- package/helpers/main-entry.d.ts +10 -0
- package/helpers/main-entry.js +215 -0
- package/helpers/main-entry.js.map +1 -0
- package/{dist/helpers → helpers}/module-resolution.js +4 -3
- package/helpers/module-resolution.js.map +1 -0
- package/{dist/helpers → helpers}/module-runner-patch.d.ts +1 -1
- package/{dist/helpers → helpers}/module-runner-patch.js +10 -12
- package/helpers/module-runner-patch.js.map +1 -0
- package/helpers/nativeclass-transform.d.ts +7 -0
- package/helpers/nativeclass-transform.js +158 -0
- package/helpers/nativeclass-transform.js.map +1 -0
- package/helpers/nativeclass-transformer-plugin.d.ts +5 -0
- package/helpers/nativeclass-transformer-plugin.js +23 -0
- package/helpers/nativeclass-transformer-plugin.js.map +1 -0
- package/{dist/helpers → helpers}/nativescript-package-resolver.js +18 -17
- package/helpers/nativescript-package-resolver.js.map +1 -0
- package/{dist/helpers → helpers}/ns-cli-plugins.d.ts +6 -1
- package/{dist/helpers → helpers}/ns-cli-plugins.js +31 -51
- package/helpers/ns-cli-plugins.js.map +1 -0
- package/helpers/package-platform-aliases.d.ts +10 -0
- package/{dist/helpers → helpers}/package-platform-aliases.js +18 -22
- package/helpers/package-platform-aliases.js.map +1 -0
- package/helpers/postcss-platform-config.d.ts +13 -0
- package/helpers/postcss-platform-config.js +97 -0
- package/helpers/postcss-platform-config.js.map +1 -0
- package/helpers/prelink-angular.d.ts +2 -0
- package/helpers/prelink-angular.js +117 -0
- package/helpers/prelink-angular.js.map +1 -0
- package/helpers/preserve-imports.js +38 -0
- package/helpers/preserve-imports.js.map +1 -0
- package/{dist/helpers → helpers}/project.js +2 -4
- package/helpers/project.js.map +1 -0
- package/helpers/resolver.d.ts +4 -0
- package/{dist/helpers → helpers}/resolver.js +7 -6
- package/helpers/resolver.js.map +1 -0
- package/helpers/theme-core-plugins.d.ts +14 -0
- package/helpers/theme-core-plugins.js +121 -0
- package/helpers/theme-core-plugins.js.map +1 -0
- package/helpers/ts-config-paths.d.ts +10 -0
- package/{dist/helpers → helpers}/ts-config-paths.js +70 -71
- package/helpers/ts-config-paths.js.map +1 -0
- package/{dist/helpers → helpers}/utils.js +14 -27
- package/helpers/utils.js.map +1 -0
- package/{dist/helpers → helpers}/workers.js +15 -16
- package/helpers/workers.js.map +1 -0
- package/{dist/hmr → hmr/client}/css-handler.js +18 -17
- package/hmr/client/css-handler.js.map +1 -0
- package/hmr/client/index.d.ts +13 -0
- package/hmr/client/index.js +1550 -0
- package/hmr/client/index.js.map +1 -0
- package/hmr/client/utils.d.ts +38 -0
- package/hmr/client/utils.js +426 -0
- package/hmr/client/utils.js.map +1 -0
- package/hmr/entry-runtime.d.ts +8 -0
- package/hmr/entry-runtime.js +135 -0
- package/hmr/entry-runtime.js.map +1 -0
- package/hmr/frameworks/angular/server/strategy.d.ts +2 -0
- package/hmr/frameworks/angular/server/strategy.js +101 -0
- package/hmr/frameworks/angular/server/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +22 -0
- package/hmr/frameworks/vue/client/index.js +1537 -0
- package/hmr/frameworks/vue/client/index.js.map +1 -0
- package/hmr/frameworks/vue/server/compiler.d.ts +11 -0
- package/hmr/frameworks/vue/server/compiler.js +26 -0
- package/hmr/frameworks/vue/server/compiler.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-transforms.d.ts +14 -0
- package/hmr/frameworks/vue/server/sfc-transforms.js +282 -0
- package/hmr/frameworks/vue/server/sfc-transforms.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.d.ts +2 -0
- package/hmr/frameworks/vue/server/strategy.js +273 -0
- package/hmr/frameworks/vue/server/strategy.js.map +1 -0
- package/hmr/helpers/ast-extract.d.ts +6 -0
- package/hmr/helpers/ast-extract.js +72 -0
- package/hmr/helpers/ast-extract.js.map +1 -0
- package/hmr/helpers/ast-normalizer.d.ts +7 -0
- package/hmr/helpers/ast-normalizer.js +772 -0
- package/hmr/helpers/ast-normalizer.js.map +1 -0
- package/hmr/helpers/babel.d.ts +3 -0
- package/hmr/helpers/babel.js +17 -0
- package/hmr/helpers/babel.js.map +1 -0
- package/hmr/helpers/sanitize.d.ts +6 -0
- package/hmr/helpers/sanitize.js +55 -0
- package/hmr/helpers/sanitize.js.map +1 -0
- package/hmr/helpers/vendor-rewrite.d.ts +1 -0
- package/hmr/helpers/vendor-rewrite.js +35 -0
- package/hmr/helpers/vendor-rewrite.js.map +1 -0
- package/hmr/server/compiler.d.ts +2 -0
- package/hmr/server/compiler.js +75 -0
- package/hmr/server/compiler.js.map +1 -0
- package/hmr/server/constants.d.ts +14 -0
- package/hmr/server/constants.js +23 -0
- package/hmr/server/constants.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +32 -0
- package/hmr/server/core-sanitize.js +134 -0
- package/hmr/server/core-sanitize.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +68 -0
- package/hmr/server/framework-strategy.js +2 -0
- package/hmr/server/framework-strategy.js.map +1 -0
- package/hmr/server/index.d.ts +5 -0
- package/hmr/server/index.js +19 -0
- package/hmr/server/index.js.map +1 -0
- package/hmr/server/vite-plugin.d.ts +5 -0
- package/{dist/hmr/plugins/plugin-vue.js → hmr/server/vite-plugin.js} +13 -15
- package/hmr/server/vite-plugin.js.map +1 -0
- package/hmr/server/websocket.d.ts +15 -0
- package/hmr/server/websocket.js +5528 -0
- package/hmr/server/websocket.js.map +1 -0
- package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
- package/hmr/shared/runtime/http-only-boot.js +107 -0
- package/hmr/shared/runtime/http-only-boot.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
- package/hmr/shared/runtime/root-placeholder.js +142 -0
- package/hmr/shared/runtime/root-placeholder.js.map +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.d.ts +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.js +134 -0
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +9 -0
- package/hmr/shared/vendor/manifest-loader.js +38 -0
- package/hmr/shared/vendor/manifest-loader.js.map +1 -0
- package/hmr/shared/vendor/manifest.d.ts +34 -0
- package/hmr/shared/vendor/manifest.js +787 -0
- package/hmr/shared/vendor/manifest.js.map +1 -0
- package/hmr/shared/vendor/registry.d.ts +9 -0
- package/hmr/shared/vendor/registry.js +62 -0
- package/hmr/shared/vendor/registry.js.map +1 -0
- package/hmr/vendor-bootstrap.d.ts +3 -0
- package/hmr/vendor-bootstrap.js +32 -0
- package/hmr/vendor-bootstrap.js.map +1 -0
- package/{dist/index.d.ts → index.d.ts} +2 -0
- package/{dist/index.js → index.js} +3 -0
- package/index.js.map +1 -0
- package/package.json +39 -31
- package/{dist/polyfills → polyfills}/mdn-data-at-rules.js +1 -0
- package/polyfills/mdn-data-at-rules.js.map +1 -0
- package/{dist/polyfills → polyfills}/mdn-data-properties.js +1 -0
- package/polyfills/mdn-data-properties.js.map +1 -0
- package/{dist/polyfills → polyfills}/mdn-data-syntaxes.js +1 -0
- package/polyfills/mdn-data-syntaxes.js.map +1 -0
- package/{dist/polyfills → polyfills}/module.js +1 -0
- package/polyfills/module.js.map +1 -0
- package/runtime/core-aliases-early.d.ts +1 -0
- package/runtime/core-aliases-early.js +334 -0
- package/runtime/core-aliases-early.js.map +1 -0
- package/shims/angular-animations-stub.d.ts +8 -0
- package/shims/angular-animations-stub.js +14 -0
- package/shims/angular-animations-stub.js.map +1 -0
- package/{dist/shims → shims}/node-module.js +3 -2
- package/shims/node-module.js.map +1 -0
- package/{dist/shims → shims}/react-reconciler-constants.js +2 -1
- package/shims/react-reconciler-constants.js.map +1 -0
- package/{dist/shims → shims}/react-reconciler.js +1 -0
- package/shims/react-reconciler.js.map +1 -0
- package/{dist/shims → shims}/set-value.js +5 -1
- package/shims/set-value.js.map +1 -0
- package/transformers/NativeClass/index.d.ts +2 -0
- package/transformers/NativeClass/index.js +222 -0
- package/transformers/NativeClass/index.js.map +1 -0
- package/dist/configuration/angular.js +0 -30
- package/dist/configuration/base.d.ts +0 -4
- package/dist/configuration/base.js +0 -386
- package/dist/configuration/vue.js +0 -45
- package/dist/helpers/css-tree.js +0 -21
- package/dist/helpers/flavor.js +0 -40
- package/dist/helpers/global-defines.js +0 -20
- package/dist/helpers/main-entry-hmr-includes.d.ts +0 -1
- package/dist/helpers/main-entry-hmr-includes.js +0 -18
- package/dist/helpers/main-entry.d.ts +0 -5
- package/dist/helpers/main-entry.js +0 -82
- package/dist/helpers/package-platform-aliases.d.ts +0 -4
- package/dist/helpers/preserve-imports.js +0 -19
- package/dist/helpers/resolver.d.ts +0 -4
- package/dist/helpers/ts-config-paths.d.ts +0 -4
- package/dist/hmr/client-vue.d.ts +0 -6
- package/dist/hmr/client-vue.js +0 -585
- package/dist/hmr/component-tracker.d.ts +0 -23
- package/dist/hmr/component-tracker.js +0 -193
- package/dist/hmr/message-handler.d.ts +0 -1
- package/dist/hmr/message-handler.js +0 -590
- package/dist/hmr/nsv-hooks.d.ts +0 -2
- package/dist/hmr/nsv-hooks.js +0 -481
- package/dist/hmr/plugins/index.d.ts +0 -1
- package/dist/hmr/plugins/index.js +0 -16
- package/dist/hmr/plugins/plugin-vue.d.ts +0 -2
- package/dist/hmr/plugins/websocket-vue.d.ts +0 -2
- package/dist/hmr/plugins/websocket-vue.js +0 -911
- package/dist/hmr/runtime-vue.d.ts +0 -13
- package/dist/hmr/runtime-vue.js +0 -2306
- package/dist/hmr/types.d.ts +0 -24
- package/dist/hmr/types.js +0 -2
- package/dist/transformers/NativeClass/index.d.ts +0 -5
- package/dist/transformers/NativeClass/index.js +0 -46
- /package/{dist/helpers → helpers}/commonjs-plugins.d.ts +0 -0
- /package/{dist/helpers → helpers}/css-tree.d.ts +0 -0
- /package/{dist/helpers → helpers}/dynamic-import-plugin.d.ts +0 -0
- /package/{dist/helpers → helpers}/external-configs.d.ts +0 -0
- /package/{dist/helpers → helpers}/module-resolution.d.ts +0 -0
- /package/{dist/helpers → helpers}/nativescript-package-resolver.d.ts +0 -0
- /package/{dist/helpers → helpers}/preserve-imports.d.ts +0 -0
- /package/{dist/helpers → helpers}/project.d.ts +0 -0
- /package/{dist/helpers → helpers}/utils.d.ts +0 -0
- /package/{dist/helpers → helpers}/workers.d.ts +0 -0
- /package/{dist/hmr → hmr/client}/css-handler.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-at-rules.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-properties.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-syntaxes.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/module.d.ts +0 -0
- /package/{dist/shims → shims}/node-module.d.ts +0 -0
- /package/{dist/shims → shims}/react-reconciler-constants.d.ts +0 -0
- /package/{dist/shims → shims}/react-reconciler.d.ts +0 -0
- /package/{dist/shims → shims}/set-value.d.ts +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import alias from '@rollup/plugin-alias';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { dirname, resolve } from 'node:path';
|
|
7
|
+
import { mergeConfig } from 'vite';
|
|
8
|
+
import { baseConfig } from './base.js';
|
|
9
|
+
import { parse as babelParse } from '@babel/parser';
|
|
10
|
+
import generate from '@babel/generator';
|
|
11
|
+
import traverse from '@babel/traverse';
|
|
12
|
+
import * as t from '@babel/types';
|
|
13
|
+
import { getCliFlags } from '../helpers/cli-flags.js';
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
export const vueConfig = ({ mode }) => {
|
|
17
|
+
const targetMode = mode === 'development' ? 'development' : 'production';
|
|
18
|
+
const cliFlags = getCliFlags();
|
|
19
|
+
const isDevMode = targetMode === 'development';
|
|
20
|
+
const hmrActive = isDevMode && !!cliFlags.hmr;
|
|
21
|
+
return mergeConfig(baseConfig({ mode }), {
|
|
22
|
+
plugins: [
|
|
23
|
+
{
|
|
24
|
+
...alias({
|
|
25
|
+
entries: {
|
|
26
|
+
// Retain 'vue' alias to 'nativescript-vue' so any generic Vue imports resolve
|
|
27
|
+
// to the NativeScript-Vue runtime.
|
|
28
|
+
vue: 'nativescript-vue',
|
|
29
|
+
'set-value': resolve(__dirname, '../shims/set-value.js'),
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
enforce: 'pre',
|
|
33
|
+
},
|
|
34
|
+
// Enable Vue Single File Component support
|
|
35
|
+
vue({
|
|
36
|
+
// NativeScript projects often use <script setup lang="ts">
|
|
37
|
+
script: {
|
|
38
|
+
defineModel: true,
|
|
39
|
+
propsDestructure: true,
|
|
40
|
+
},
|
|
41
|
+
// Keep template compilation basic; transform asset URLs is not needed for NS
|
|
42
|
+
template: {
|
|
43
|
+
transformAssetUrls: false,
|
|
44
|
+
compilerOptions: {
|
|
45
|
+
// Only treat real web custom elements (hyphenated) as custom.
|
|
46
|
+
// DO NOT match PascalCase NativeScript tags.
|
|
47
|
+
isCustomElement: (tag) => tag.includes('-'),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
// Optional: allow JSX/TSX in Vue components if used
|
|
52
|
+
vueJsx(),
|
|
53
|
+
// With HMR, apply post-transform to make any named import from 'nativescript-vue' bulletproof in build mode.
|
|
54
|
+
// It rewrites `import { X as Y } from 'nativescript-vue'` to a namespace import and
|
|
55
|
+
// creates local const bindings that pick from either the module's named export (if present)
|
|
56
|
+
// or the default object's property, auto-binding functions to the default instance.
|
|
57
|
+
hmrActive
|
|
58
|
+
? {
|
|
59
|
+
name: 'ns-vue-named-imports-interop',
|
|
60
|
+
apply: 'build',
|
|
61
|
+
enforce: 'post',
|
|
62
|
+
transform(code, id) {
|
|
63
|
+
// Only operate on JS/TS and extracted Vue script blocks
|
|
64
|
+
if (!/\.(mjs|cjs|js|ts|jsx|tsx)(\?|$)/.test(id) && !/\.vue\?vue&type=script/.test(id)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
let ast;
|
|
68
|
+
try {
|
|
69
|
+
ast = babelParse(code, {
|
|
70
|
+
sourceType: 'module',
|
|
71
|
+
plugins: [
|
|
72
|
+
'typescript',
|
|
73
|
+
'jsx',
|
|
74
|
+
// Allow decorators/experimental features if present; harmless if unused
|
|
75
|
+
['decorators', { decoratorsBeforeExport: true }],
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
let mutated = false;
|
|
83
|
+
let hasNSVNamespace = false;
|
|
84
|
+
let hasNSVDefaultVar = false;
|
|
85
|
+
const nsVarName = '__NSV';
|
|
86
|
+
const defVarName = '__nsv';
|
|
87
|
+
const newNodes = [];
|
|
88
|
+
const nodesToRemove = [];
|
|
89
|
+
traverse.default?.(ast, {
|
|
90
|
+
Program: {
|
|
91
|
+
exit(path) {
|
|
92
|
+
if (!mutated)
|
|
93
|
+
return;
|
|
94
|
+
// Prepend namespace/default helpers if they were requested by transforms
|
|
95
|
+
const body = path.node.body;
|
|
96
|
+
const prepend = [];
|
|
97
|
+
if (!hasNSVNamespace) {
|
|
98
|
+
prepend.push(t.importDeclaration([t.importNamespaceSpecifier(t.identifier(nsVarName))], t.stringLiteral('nativescript-vue')));
|
|
99
|
+
hasNSVNamespace = true;
|
|
100
|
+
}
|
|
101
|
+
if (!hasNSVDefaultVar) {
|
|
102
|
+
prepend.push(t.variableDeclaration('const', [
|
|
103
|
+
t.variableDeclarator(t.identifier(defVarName), t.logicalExpression('||',
|
|
104
|
+
// Prefer explicit default when present; fall back to namespace
|
|
105
|
+
t.memberExpression(t.identifier(nsVarName), t.identifier('default'), false), t.identifier(nsVarName))),
|
|
106
|
+
]));
|
|
107
|
+
hasNSVDefaultVar = true;
|
|
108
|
+
}
|
|
109
|
+
path.node.body = [...prepend, ...body];
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
ImportDeclaration(path) {
|
|
113
|
+
const node = path.node;
|
|
114
|
+
const src = node.source.value;
|
|
115
|
+
if (src !== 'nativescript-vue')
|
|
116
|
+
return;
|
|
117
|
+
const named = node.specifiers?.filter((s) => s.type === 'ImportSpecifier');
|
|
118
|
+
if (!named?.length)
|
|
119
|
+
return;
|
|
120
|
+
mutated = true;
|
|
121
|
+
// Ensure our helpers are available
|
|
122
|
+
hasNSVNamespace = true;
|
|
123
|
+
hasNSVDefaultVar = true;
|
|
124
|
+
// Gather new variable declarations for each named specifier
|
|
125
|
+
const decls = [];
|
|
126
|
+
for (const spec of named) {
|
|
127
|
+
const imported = spec.imported.name;
|
|
128
|
+
const local = spec.local.name;
|
|
129
|
+
const pickExpr = t.logicalExpression('||', t.memberExpression(t.identifier(nsVarName), t.identifier(imported), false), t.memberExpression(t.identifier(defVarName), t.identifier(imported), false));
|
|
130
|
+
const bindHelper = t.callExpression(t.arrowFunctionExpression([t.identifier('v')], t.conditionalExpression(t.binaryExpression('===', t.unaryExpression('typeof', t.identifier('v')), t.stringLiteral('function')), t.callExpression(t.memberExpression(t.identifier('v'), t.identifier('bind')), [t.identifier(defVarName)]), t.identifier('v'))), [pickExpr]);
|
|
131
|
+
decls.push(t.variableDeclarator(t.identifier(local), bindHelper));
|
|
132
|
+
}
|
|
133
|
+
// Build replacement: remove named specifiers from original import
|
|
134
|
+
const remaining = node.specifiers.filter((s) => s.type !== 'ImportSpecifier');
|
|
135
|
+
const newStmts = [];
|
|
136
|
+
if (remaining.length) {
|
|
137
|
+
// Keep any default/namespace import as-is
|
|
138
|
+
newStmts.push(t.importDeclaration(remaining, t.stringLiteral('nativescript-vue')));
|
|
139
|
+
}
|
|
140
|
+
// Always ensure namespace/default helpers are present by prepending in Program.exit
|
|
141
|
+
newStmts.push(t.variableDeclaration('const', decls));
|
|
142
|
+
nodesToRemove.push(node);
|
|
143
|
+
newNodes.push(...newStmts);
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
if (!mutated)
|
|
147
|
+
return null;
|
|
148
|
+
// Apply queued removals/insertions conservatively via simple string regeneration
|
|
149
|
+
// by reconstructing the whole module from AST, since we changed structure.
|
|
150
|
+
// Remove collected nodes by marking them and letting generator drop them.
|
|
151
|
+
// Easiest approach: reconstruct AST.body filtering out removed nodes and appending new ones near the end.
|
|
152
|
+
const program = ast.program;
|
|
153
|
+
program.body = program.body.filter((n) => !nodesToRemove.includes(n));
|
|
154
|
+
program.body.push(...newNodes);
|
|
155
|
+
const out = generate.default ? generate.default(program, {}) : generate(program, {});
|
|
156
|
+
return { code: out.code, map: null };
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
: undefined,
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.js","sourceRoot":"","sources":["../../../../packages/vite/configuration/vue.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,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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0G;wBAC1G,MAAM,OAAO,GAAI,GAAW,CAAC,OAAoB,CAAC;wBAClD,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;wBACtE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;wBAE/B,MAAM,GAAG,GAAI,QAAgB,CAAC,OAAO,CAAC,CAAC,CAAE,QAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAc,EAAE,EAAE,CAAC,CAAC;wBAC9G,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;oBACtC,CAAC;iBACD;gBACF,CAAC,CAAC,SAAS;SACZ;KACD,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin to run Angular linker (Babel) over partial-compiled Angular libraries
|
|
4
|
+
* inside node_modules (e.g., @angular/*, @nativescript/angular).
|
|
5
|
+
*
|
|
6
|
+
* This converts ɵɵngDeclare* calls to ɵɵdefine* so runtime doesn't require the JIT compiler.
|
|
7
|
+
*/
|
|
8
|
+
export declare function angularLinkerVitePlugin(projectRoot?: string): Plugin;
|
|
9
|
+
/**
|
|
10
|
+
* Post-phase linker: catches any ɵɵngDeclare* introduced by downstream transforms (e.g., optimizer)
|
|
11
|
+
* including in project source, after other plugins have run.
|
|
12
|
+
*/
|
|
13
|
+
export declare function angularLinkerVitePluginPost(projectRoot?: string): Plugin;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin to run Angular linker (Babel) over partial-compiled Angular libraries
|
|
4
|
+
* inside node_modules (e.g., @angular/*, @nativescript/angular).
|
|
5
|
+
*
|
|
6
|
+
* This converts ɵɵngDeclare* calls to ɵɵdefine* so runtime doesn't require the JIT compiler.
|
|
7
|
+
*/
|
|
8
|
+
export function angularLinkerVitePlugin(projectRoot) {
|
|
9
|
+
const req = createRequire(projectRoot ? projectRoot + '/package.json' : import.meta.url);
|
|
10
|
+
let babel = null;
|
|
11
|
+
let createLinker = null;
|
|
12
|
+
async function ensureDeps() {
|
|
13
|
+
if (babel && createLinker)
|
|
14
|
+
return;
|
|
15
|
+
try {
|
|
16
|
+
const babelPath = req.resolve('@babel/core');
|
|
17
|
+
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
18
|
+
babel = (await import(babelPath));
|
|
19
|
+
const linkerMod = await import(linkerPath);
|
|
20
|
+
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Fall back to hoisted resolution if necessary
|
|
24
|
+
try {
|
|
25
|
+
babel = (await import('@babel/core'));
|
|
26
|
+
}
|
|
27
|
+
catch { }
|
|
28
|
+
try {
|
|
29
|
+
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
30
|
+
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Restrict to Angular framework packages in pre phase to avoid extra work.
|
|
36
|
+
const FILTER = /node_modules\/(?:@angular|@nativescript\/angular)\/.*\.[mc]?js$/;
|
|
37
|
+
return {
|
|
38
|
+
name: 'ns-angular-linker-vite',
|
|
39
|
+
enforce: 'pre',
|
|
40
|
+
async load(id) {
|
|
41
|
+
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
42
|
+
const cleanId = id.split('?', 1)[0];
|
|
43
|
+
if (!FILTER.test(cleanId))
|
|
44
|
+
return null;
|
|
45
|
+
try {
|
|
46
|
+
const fs = await import('node:fs/promises');
|
|
47
|
+
const code = await fs.readFile(cleanId, 'utf8');
|
|
48
|
+
if (!code)
|
|
49
|
+
return null;
|
|
50
|
+
await ensureDeps();
|
|
51
|
+
if (!babel || !createLinker)
|
|
52
|
+
return null;
|
|
53
|
+
const plugin = createLinker({ sourceMapping: false });
|
|
54
|
+
if (debug) {
|
|
55
|
+
try {
|
|
56
|
+
console.log('[ns-angular-linker][vite-load] linking', cleanId);
|
|
57
|
+
}
|
|
58
|
+
catch { }
|
|
59
|
+
}
|
|
60
|
+
const result = await babel.transformAsync(code, {
|
|
61
|
+
filename: cleanId,
|
|
62
|
+
configFile: false,
|
|
63
|
+
babelrc: false,
|
|
64
|
+
sourceMaps: false,
|
|
65
|
+
compact: false,
|
|
66
|
+
plugins: [plugin],
|
|
67
|
+
});
|
|
68
|
+
if (result?.code && result.code !== code) {
|
|
69
|
+
return { code: result.code, map: null };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch { }
|
|
73
|
+
return null;
|
|
74
|
+
},
|
|
75
|
+
async transform(code, id) {
|
|
76
|
+
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
77
|
+
// Strip Vite/Rollup query strings before testing
|
|
78
|
+
const cleanId = id.split('?', 1)[0];
|
|
79
|
+
if (!FILTER.test(cleanId))
|
|
80
|
+
return null;
|
|
81
|
+
if (!code)
|
|
82
|
+
return null;
|
|
83
|
+
await ensureDeps();
|
|
84
|
+
if (!babel || !createLinker)
|
|
85
|
+
return null;
|
|
86
|
+
try {
|
|
87
|
+
const plugin = createLinker({ sourceMapping: false });
|
|
88
|
+
if (debug) {
|
|
89
|
+
try {
|
|
90
|
+
console.log('[ns-angular-linker][vite] linking', cleanId);
|
|
91
|
+
}
|
|
92
|
+
catch { }
|
|
93
|
+
}
|
|
94
|
+
const result = await babel.transformAsync(code, {
|
|
95
|
+
filename: cleanId,
|
|
96
|
+
configFile: false,
|
|
97
|
+
babelrc: false,
|
|
98
|
+
sourceMaps: false,
|
|
99
|
+
compact: false,
|
|
100
|
+
plugins: [plugin],
|
|
101
|
+
});
|
|
102
|
+
if (result?.code && result.code !== code) {
|
|
103
|
+
return { code: result.code, map: null };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Soft-fail; return original code
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Post-phase linker: catches any ɵɵngDeclare* introduced by downstream transforms (e.g., optimizer)
|
|
115
|
+
* including in project source, after other plugins have run.
|
|
116
|
+
*/
|
|
117
|
+
export function angularLinkerVitePluginPost(projectRoot) {
|
|
118
|
+
const req = createRequire(projectRoot ? projectRoot + '/package.json' : import.meta.url);
|
|
119
|
+
let babel = null;
|
|
120
|
+
let createLinker = null;
|
|
121
|
+
async function ensureDeps() {
|
|
122
|
+
if (babel && createLinker)
|
|
123
|
+
return;
|
|
124
|
+
try {
|
|
125
|
+
const babelPath = req.resolve('@babel/core');
|
|
126
|
+
const linkerPath = req.resolve('@angular/compiler-cli/linker/babel');
|
|
127
|
+
babel = (await import(babelPath));
|
|
128
|
+
const linkerMod = await import(linkerPath);
|
|
129
|
+
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
try {
|
|
133
|
+
babel = (await import('@babel/core'));
|
|
134
|
+
}
|
|
135
|
+
catch { }
|
|
136
|
+
try {
|
|
137
|
+
const linkerMod = await import('@angular/compiler-cli/linker/babel');
|
|
138
|
+
createLinker = linkerMod.createLinkerPlugin || linkerMod.createEs2015LinkerPlugin || null;
|
|
139
|
+
}
|
|
140
|
+
catch { }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
name: 'ns-angular-linker-vite-post',
|
|
145
|
+
enforce: 'post',
|
|
146
|
+
async transform(code, id) {
|
|
147
|
+
const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1';
|
|
148
|
+
// Only JS/ESM files
|
|
149
|
+
if (!/\.(m?js)(\?|$)/.test(id))
|
|
150
|
+
return null;
|
|
151
|
+
if (!code || (code.indexOf('\u0275\u0275ngDeclare') === -1 && code.indexOf('ɵɵngDeclare') === -1 && code.indexOf('ngDeclare') === -1))
|
|
152
|
+
return null;
|
|
153
|
+
await ensureDeps();
|
|
154
|
+
if (!babel || !createLinker)
|
|
155
|
+
return null;
|
|
156
|
+
try {
|
|
157
|
+
const plugin = createLinker({ sourceMapping: false });
|
|
158
|
+
if (debug) {
|
|
159
|
+
try {
|
|
160
|
+
console.log('[ns-angular-linker][vite-post] linking', id.split('?', 1)[0]);
|
|
161
|
+
}
|
|
162
|
+
catch { }
|
|
163
|
+
}
|
|
164
|
+
const result = await babel.transformAsync(code, {
|
|
165
|
+
filename: id.split('?', 1)[0],
|
|
166
|
+
configFile: false,
|
|
167
|
+
babelrc: false,
|
|
168
|
+
sourceMaps: false,
|
|
169
|
+
compact: false,
|
|
170
|
+
plugins: [plugin],
|
|
171
|
+
});
|
|
172
|
+
if (result?.code && result.code !== code) {
|
|
173
|
+
return { code: result.code, map: null };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch { }
|
|
177
|
+
return null;
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=angular-linker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-linker.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/angular-linker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAoB;IA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,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,KAAK;oBACjB,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,CAAC,MAAM,CAAC;iBACjB,CAAC,CAAC;gBACH,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;gBACzC,CAAC;YACF,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCliFlags(): Record<string, string | boolean>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import minimist from 'minimist';
|
|
2
|
+
let cliFlags = null;
|
|
3
|
+
export function getCliFlags() {
|
|
4
|
+
if (!cliFlags) {
|
|
5
|
+
const cliArgs = minimist(process.argv.slice(2), { '--': true });
|
|
6
|
+
cliFlags = (cliArgs['--'] || []).reduce((obj, flag) => {
|
|
7
|
+
// remove env prefix
|
|
8
|
+
const [rawKey, ...rest] = flag.replace(/^--env\./, '').split('=');
|
|
9
|
+
obj[rawKey] = rest.length === 0 ? true : rest.join('=');
|
|
10
|
+
return obj;
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
return cliFlags;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=cli-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-flags.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/cli-flags.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,IAAI,QAAQ,GAA4C,IAAI,CAAC;AAE7D,MAAM,UAAU,WAAW;IAC1B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,QAAQ,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACrD,oBAAoB;YACpB,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACxD,OAAO,GAAG,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;IACR,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
export const commonjsPlugins = [
|
|
3
3
|
// Fix source-map-js subpath imports for css-tree compatibility
|
|
4
4
|
{
|
|
5
|
-
name:
|
|
6
|
-
enforce:
|
|
5
|
+
name: 'source-map-js-subpath-compat',
|
|
6
|
+
enforce: 'pre',
|
|
7
7
|
resolveId(id) {
|
|
8
|
-
if (id ===
|
|
9
|
-
return
|
|
8
|
+
if (id === 'source-map-js/lib/source-map-generator.js') {
|
|
9
|
+
return '\0source-map-generator-virtual';
|
|
10
10
|
}
|
|
11
11
|
return null;
|
|
12
12
|
},
|
|
13
13
|
load(id) {
|
|
14
|
-
if (id ===
|
|
14
|
+
if (id === '\0source-map-generator-virtual') {
|
|
15
15
|
// Import the main source-map-js package and extract SourceMapGenerator
|
|
16
16
|
return `
|
|
17
17
|
import * as sourceMapJs from 'source-map-js';
|
|
@@ -24,16 +24,16 @@ export { SourceMapGenerator };
|
|
|
24
24
|
},
|
|
25
25
|
// Fix html-entities ESM compatibility issue
|
|
26
26
|
{
|
|
27
|
-
name:
|
|
28
|
-
enforce:
|
|
27
|
+
name: 'html-entities-compat',
|
|
28
|
+
enforce: 'pre',
|
|
29
29
|
resolveId(id) {
|
|
30
|
-
if (id ===
|
|
30
|
+
if (id === 'html-entities') {
|
|
31
31
|
return id;
|
|
32
32
|
}
|
|
33
33
|
return null;
|
|
34
34
|
},
|
|
35
35
|
load(id) {
|
|
36
|
-
if (id ===
|
|
36
|
+
if (id === 'html-entities') {
|
|
37
37
|
// html-entities exports: exports.encode = encode; exports.decode = decode; exports.decodeEntity = decodeEntity;
|
|
38
38
|
return `
|
|
39
39
|
import * as htmlEntitiesModule from 'html-entities/lib/index.js';
|
|
@@ -48,16 +48,16 @@ export default htmlEntitiesModule;
|
|
|
48
48
|
},
|
|
49
49
|
// Fix fast-xml-parser ESM compatibility issue
|
|
50
50
|
{
|
|
51
|
-
name:
|
|
52
|
-
enforce:
|
|
51
|
+
name: 'fast-xml-parser-compat',
|
|
52
|
+
enforce: 'pre',
|
|
53
53
|
resolveId(id) {
|
|
54
|
-
if (id ===
|
|
54
|
+
if (id === 'fast-xml-parser') {
|
|
55
55
|
return id;
|
|
56
56
|
}
|
|
57
57
|
return null;
|
|
58
58
|
},
|
|
59
59
|
load(id) {
|
|
60
|
-
if (id ===
|
|
60
|
+
if (id === 'fast-xml-parser') {
|
|
61
61
|
// fast-xml-parser exports: exports.XMLParser = XMLParser; exports.XMLBuilder = XMLBuilder; exports.XMLValidator = XMLValidator; etc.
|
|
62
62
|
return `
|
|
63
63
|
import * as fastXmlParser from 'fast-xml-parser/src/fxp.js';
|
|
@@ -73,3 +73,4 @@ export default fastXmlParser;
|
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
75
|
];
|
|
76
|
+
//# sourceMappingURL=commonjs-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonjs-plugins.js","sourceRoot":"","sources":["../../../../packages/v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,2 @@
|
|
|
1
|
-
import type { Plugin } from
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
2
|
export default function nsConfigAsJsonPlugin(): Plugin;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { nsConfigToJson } from
|
|
2
|
-
const nsConfigVirtualId =
|
|
1
|
+
import { nsConfigToJson } from './utils.js';
|
|
2
|
+
const nsConfigVirtualId = '\0nsvite:nsconfig-json';
|
|
3
3
|
export default function nsConfigAsJsonPlugin() {
|
|
4
4
|
// will hold your parsed config object
|
|
5
5
|
let configObject;
|
|
6
6
|
return {
|
|
7
|
-
name:
|
|
7
|
+
name: 'nsvite-nsconfig-as-json',
|
|
8
8
|
// 1. Intercept imports of "~/package.json"
|
|
9
9
|
resolveId(source) {
|
|
10
|
-
if (source ===
|
|
10
|
+
if (source === '~/package.json') {
|
|
11
11
|
return nsConfigVirtualId;
|
|
12
12
|
}
|
|
13
13
|
return null;
|
|
@@ -26,10 +26,11 @@ export default function nsConfigAsJsonPlugin() {
|
|
|
26
26
|
generateBundle(_options, _bundle) {
|
|
27
27
|
const json = JSON.stringify(configObject, null, 2);
|
|
28
28
|
this.emitFile({
|
|
29
|
-
type:
|
|
30
|
-
fileName:
|
|
29
|
+
type: 'asset',
|
|
30
|
+
fileName: 'package.json',
|
|
31
31
|
source: json,
|
|
32
32
|
});
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
//# sourceMappingURL=config-as-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-as-json.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/config-as-json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC3C,sCAAsC;IACtC,IAAI,YAAiC,CAAC;IAEtC,OAAO;QACN,IAAI,EAAE,yBAAyB;QAE/B,2CAA2C;QAC3C,SAAS,CAAC,MAAM;YACf,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;gBACjC,OAAO,iBAAiB,CAAC;YAC1B,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,kDAAkD;QAClD,IAAI,CAAC,EAAE;YACN,IAAI,EAAE,KAAK,iBAAiB,EAAE,CAAC;gBAC9B,YAAY,GAAG,cAAc,EAAE,CAAC;gBAEhC,+DAA+D;gBAC/D,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC;YAC1D,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,sEAAsE;QACtE,kDAAkD;QAClD,cAAc,CAAC,QAAQ,EAAE,OAAO;YAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,CAAC;gBACb,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,cAAc;gBACxB,MAAM,EAAE,IAAI;aACZ,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin: ns-css-platform
|
|
4
|
+
*
|
|
5
|
+
* Provides platform specific CSS resolution. When a generic import fails (foo.css)
|
|
6
|
+
* it will attempt to load foo.android.css or foo.ios.css depending on platform.
|
|
7
|
+
* Also rewrites relative @import specifiers inside CSS files to platform variants
|
|
8
|
+
* when the generic file does not exist but a platform suffixed version does.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createPlatformCssPlugin(platform: string): Plugin;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { existsSync, readFileSync } from 'fs';
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin: ns-css-platform
|
|
5
|
+
*
|
|
6
|
+
* Provides platform specific CSS resolution. When a generic import fails (foo.css)
|
|
7
|
+
* it will attempt to load foo.android.css or foo.ios.css depending on platform.
|
|
8
|
+
* Also rewrites relative @import specifiers inside CSS files to platform variants
|
|
9
|
+
* when the generic file does not exist but a platform suffixed version does.
|
|
10
|
+
*/
|
|
11
|
+
export function createPlatformCssPlugin(platform) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'ns-css-platform',
|
|
14
|
+
enforce: 'pre',
|
|
15
|
+
transform(code, id) {
|
|
16
|
+
const baseId = id.split('?')[0];
|
|
17
|
+
if (!baseId.endsWith('.css') || !code.includes('@import'))
|
|
18
|
+
return null;
|
|
19
|
+
const dir = path.dirname(baseId);
|
|
20
|
+
const platformExt = platform === 'android' ? '.android.css' : '.ios.css';
|
|
21
|
+
let changed = false;
|
|
22
|
+
// Support @import "foo.css"; @import 'foo.css'; @import url("foo.css"); preserving rest
|
|
23
|
+
const importRegex = /@import\s+(?:url\()?['"]([^'"()]+\.css)['"]\)?/g;
|
|
24
|
+
const newCode = code.replace(importRegex, (full, spec) => {
|
|
25
|
+
if (/^(https?:|data:)/.test(spec) || spec.includes('nativescript-theme-core') || spec.endsWith(platformExt))
|
|
26
|
+
return full;
|
|
27
|
+
if (!(spec.startsWith('.') || spec.startsWith('/')))
|
|
28
|
+
return full;
|
|
29
|
+
const abs = path.isAbsolute(spec) ? spec : path.resolve(dir, spec);
|
|
30
|
+
if (existsSync(abs))
|
|
31
|
+
return full;
|
|
32
|
+
const alt = abs.replace(/\.css$/, platformExt);
|
|
33
|
+
if (existsSync(alt)) {
|
|
34
|
+
let rel = path.relative(dir, alt).replace(/\\/g, '/');
|
|
35
|
+
if (!rel.startsWith('.'))
|
|
36
|
+
rel = './' + rel;
|
|
37
|
+
changed = true;
|
|
38
|
+
return full.replace(spec, rel);
|
|
39
|
+
}
|
|
40
|
+
return full;
|
|
41
|
+
});
|
|
42
|
+
return changed ? { code: newCode, map: null } : null;
|
|
43
|
+
},
|
|
44
|
+
resolveId(id, importer) {
|
|
45
|
+
if (!id || !importer)
|
|
46
|
+
return null;
|
|
47
|
+
if (!(id.startsWith('.') || id.startsWith('/')))
|
|
48
|
+
return null;
|
|
49
|
+
if (!/\.css$/.test(id))
|
|
50
|
+
return null;
|
|
51
|
+
const importerPath = importer.split('?')[0];
|
|
52
|
+
const baseDir = path.dirname(importerPath);
|
|
53
|
+
const abs = path.isAbsolute(id) ? id : path.resolve(baseDir, id);
|
|
54
|
+
if (existsSync(abs))
|
|
55
|
+
return null;
|
|
56
|
+
const platformExt = platform === 'android' ? '.android.css' : '.ios.css';
|
|
57
|
+
const alt = abs.replace(/\.css$/, platformExt);
|
|
58
|
+
if (existsSync(alt)) {
|
|
59
|
+
return '\0ns-css-platform:' + alt;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
},
|
|
63
|
+
load(id) {
|
|
64
|
+
if (!id.startsWith('\0ns-css-platform:'))
|
|
65
|
+
return null;
|
|
66
|
+
const real = id.substring('\0ns-css-platform:'.length);
|
|
67
|
+
try {
|
|
68
|
+
return readFileSync(real, 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=css-platform-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-platform-plugin.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/css-platform-plugin.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACvD,OAAO;QACN,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,KAAK;QACd,SAAS,CAAC,IAAY,EAAE,EAAU;YACjC,MAAM,MAAM,GA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,CAAC,CAAC,CAAC,UAAU,CAAC;YACzE,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC/C,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,OAAO,oBAAoB,GAAG,GAAG,CAAC;YACnC,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,EAAU;YACd,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;gBAAE,OAAO,IAAI,CAAC;YACtD,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,CAAC;gBACJ,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACR,OAAO,EAAE,CAAC;YACX,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { __dirname } from './project.js';
|
|
3
|
+
export const aliasCssTree = [
|
|
4
|
+
// Node.js built-ins and mdn-data polyfills for css-tree
|
|
5
|
+
{
|
|
6
|
+
find: 'module',
|
|
7
|
+
replacement: path.resolve(__dirname, '../polyfills/module.js'),
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
find: 'mdn-data/css/properties.json',
|
|
11
|
+
replacement: path.resolve(__dirname, '../polyfills/mdn-data-properties.js'),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
find: 'mdn-data/css/syntaxes.json',
|
|
15
|
+
replacement: path.resolve(__dirname, '../polyfills/mdn-data-syntaxes.js'),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
find: 'mdn-data/css/at-rules.json',
|
|
19
|
+
replacement: path.resolve(__dirname, '../polyfills/mdn-data-at-rules.js'),
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
//# sourceMappingURL=css-tree.js.map
|