@nativescript/vite 0.0.1 → 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/helpers/external-configs.d.ts +6 -0
- package/helpers/external-configs.js +34 -0
- 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 -2
- 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/helpers/module-runner-patch.d.ts +3 -0
- package/helpers/module-runner-patch.js +63 -0
- 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/helpers/ns-cli-plugins.d.ts +14 -0
- package/helpers/ns-cli-plugins.js +165 -0
- 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 +19 -23
- 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.d.ts +2 -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 +73 -72
- package/helpers/ts-config-paths.js.map +1 -0
- package/{dist/helpers → helpers}/utils.d.ts +6 -0
- package/{dist/helpers → helpers}/utils.js +28 -34
- package/helpers/utils.js.map +1 -0
- package/{dist/helpers → helpers}/workers.js +15 -16
- package/helpers/workers.js.map +1 -0
- package/hmr/client/css-handler.d.ts +4 -0
- package/hmr/client/css-handler.js +78 -0
- 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/hmr/server/vite-plugin.js +44 -0
- 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 -30
- 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/shims/node-module.d.ts +5 -0
- package/shims/node-module.js +13 -0
- 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 -13
- package/dist/configuration/base.js +0 -228
- package/dist/configuration/old-without-merge-base.d.ts +0 -13
- package/dist/configuration/old-without-merge-base.js +0 -249
- 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 -18
- package/dist/helpers/main-entry.d.ts +0 -5
- package/dist/helpers/main-entry.js +0 -75
- package/dist/helpers/ns-cli-plugins.d.ts +0 -17
- package/dist/helpers/ns-cli-plugins.js +0 -128
- package/dist/helpers/package-platform-aliases.d.ts +0 -4
- package/dist/helpers/resolver.d.ts +0 -4
- package/dist/helpers/ts-config-paths.d.ts +0 -4
- package/dist/hmr/hmr-angular.d.ts +0 -1
- package/dist/hmr/hmr-angular.js +0 -34
- package/dist/hmr/hmr-bridge.d.ts +0 -18
- package/dist/hmr/hmr-bridge.js +0 -154
- package/dist/hmr/hmr-client.d.ts +0 -5
- package/dist/hmr/hmr-client.js +0 -93
- package/dist/hmr/hmr-server.d.ts +0 -20
- package/dist/hmr/hmr-server.js +0 -179
- 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}/module-resolution.d.ts +0 -0
- /package/{dist/helpers → helpers}/nativescript-package-resolver.d.ts +0 -0
- /package/{dist/helpers → helpers}/project.d.ts +0 -0
- /package/{dist/helpers → helpers}/workers.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}/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
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { getPackageJson, getProjectFilePath, getProjectRootPath, } from "./project.js";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
const projectRoot = getProjectRootPath();
|
|
5
|
-
// main entry
|
|
6
|
-
const packageJson = getPackageJson();
|
|
7
|
-
const mainEntry = getProjectFilePath(packageJson.main);
|
|
8
|
-
// console.log("mainEntry:", mainEntry);
|
|
9
|
-
// hmr client
|
|
10
|
-
const hmrClientPath = getProjectFilePath("./node_modules/@nativescript/vite/dist/hmr/hmr-client.js");
|
|
11
|
-
const hmrClientExists = fs.existsSync(hmrClientPath);
|
|
12
|
-
// console.log("hmrClientPath:", hmrClientPath);
|
|
13
|
-
// console.log("hmrClientExists:", hmrClientExists);
|
|
14
|
-
// Check if polyfills file exists
|
|
15
|
-
const polyfillsPath = getProjectFilePath("src/polyfills.ts");
|
|
16
|
-
const polyfillsExists = fs.existsSync(polyfillsPath);
|
|
17
|
-
// console.log("polyfillsPath:", polyfillsPath);
|
|
18
|
-
// console.log("polyfillsExists:", polyfillsExists);
|
|
19
|
-
const VIRTUAL_ID = 'virtual:entry-with-polyfills';
|
|
20
|
-
const RESOLVED = '\0' + VIRTUAL_ID;
|
|
21
|
-
export function mainEntryPlugin(cliFlags, debug) {
|
|
22
|
-
return {
|
|
23
|
-
name: "main-entry",
|
|
24
|
-
resolveId(id) {
|
|
25
|
-
if (id === VIRTUAL_ID) {
|
|
26
|
-
return RESOLVED;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
},
|
|
30
|
-
load(id) {
|
|
31
|
-
if (id === RESOLVED) {
|
|
32
|
-
let imports = "";
|
|
33
|
-
if (polyfillsExists) {
|
|
34
|
-
imports += `import '${polyfillsPath}';\n`;
|
|
35
|
-
}
|
|
36
|
-
// Import WebSocket support for HMR in development
|
|
37
|
-
if (debug && cliFlags.hmr) {
|
|
38
|
-
imports += `import '${hmrClientPath}';\n`;
|
|
39
|
-
}
|
|
40
|
-
// Import inspector modules for debugging in development
|
|
41
|
-
if (debug) {
|
|
42
|
-
imports += `import '@nativescript/core/inspector_modules';\n`;
|
|
43
|
-
}
|
|
44
|
-
// Import CSS and apply via Application.addCss before main entry
|
|
45
|
-
const appCssPath = path.resolve(projectRoot, "src/app.css");
|
|
46
|
-
if (fs.existsSync(appCssPath)) {
|
|
47
|
-
imports += `
|
|
48
|
-
// Import and apply global CSS
|
|
49
|
-
import appCssContent from './src/app.css?inline';
|
|
50
|
-
import { Application } from '@nativescript/core';
|
|
51
|
-
|
|
52
|
-
if (typeof global !== 'undefined' && appCssContent) {
|
|
53
|
-
try {
|
|
54
|
-
// Just testing logs if needed
|
|
55
|
-
// console.log('🎨 CSS content length:', appCssContent.length);
|
|
56
|
-
// console.log('🎨 CSS content preview:', appCssContent.substring(0, 200) + '...');
|
|
57
|
-
|
|
58
|
-
Application.addCss(appCssContent);
|
|
59
|
-
// console.log('🎨 Global CSS applied');
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.error('Error applying CSS:', error);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
}
|
|
66
|
-
imports += `import '${mainEntry}';`;
|
|
67
|
-
if (debug) {
|
|
68
|
-
console.log("🔄 Virtual entry imports:", imports);
|
|
69
|
-
}
|
|
70
|
-
return imports;
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare function hmrPlugin(targetMode: string): {
|
|
2
|
-
name: string;
|
|
3
|
-
buildStart(): void;
|
|
4
|
-
watchChange(id: any, { event }: {
|
|
5
|
-
event: any;
|
|
6
|
-
}): void;
|
|
7
|
-
handleHotUpdate({ file, server, timestamp }: {
|
|
8
|
-
file: any;
|
|
9
|
-
server: any;
|
|
10
|
-
timestamp: any;
|
|
11
|
-
}): any[];
|
|
12
|
-
};
|
|
13
|
-
export declare function cliPlugin(targetMode: string, cliFlags: any): {
|
|
14
|
-
name: string;
|
|
15
|
-
buildStart(): void;
|
|
16
|
-
writeBundle(options: any, bundle: any): void;
|
|
17
|
-
};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
// NativeScript HMR integration - track changes for incremental builds
|
|
3
|
-
// Track changed files globally for HMR
|
|
4
|
-
let changedFilesTracker = new Set();
|
|
5
|
-
let isInitialBuild = true;
|
|
6
|
-
export function hmrPlugin(targetMode) {
|
|
7
|
-
return {
|
|
8
|
-
name: "nativescript-hmr",
|
|
9
|
-
buildStart() {
|
|
10
|
-
if (targetMode === "development") {
|
|
11
|
-
console.log("🔥 Vite: Build started");
|
|
12
|
-
// Don't clear changedFilesTracker here - we need it for writeBundle
|
|
13
|
-
// We'll clear it in writeBundle after using it
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
// Use watchChange hook to track file changes in build mode
|
|
17
|
-
watchChange(id, { event }) {
|
|
18
|
-
if (targetMode === "development") {
|
|
19
|
-
const relativePath = path.relative(process.cwd(), id);
|
|
20
|
-
// Only track changes in src directory and config files
|
|
21
|
-
const shouldTrack = relativePath.startsWith("src/");
|
|
22
|
-
if (!shouldTrack) {
|
|
23
|
-
return; // Ignore changes to build outputs, platforms, node_modules, etc.
|
|
24
|
-
}
|
|
25
|
-
console.log(`🔥 File ${event}:`, relativePath);
|
|
26
|
-
// Track the changed file
|
|
27
|
-
changedFilesTracker.add(relativePath);
|
|
28
|
-
// Log the type of change for debugging
|
|
29
|
-
if (id.endsWith(".css") || id.endsWith(".scss")) {
|
|
30
|
-
console.log("🔥 CSS file change detected");
|
|
31
|
-
}
|
|
32
|
-
else if (id.endsWith(".html")) {
|
|
33
|
-
console.log("🔥 HTML template change detected");
|
|
34
|
-
}
|
|
35
|
-
else if (id.endsWith(".ts") && !id.endsWith(".d.ts")) {
|
|
36
|
-
console.log("🔥 TypeScript file change detected");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
// Keep handleHotUpdate for completeness, but it won't fire in build mode
|
|
41
|
-
handleHotUpdate({ file, server, timestamp }) {
|
|
42
|
-
if (targetMode === "development") {
|
|
43
|
-
const relativePath = path.relative(process.cwd(), file);
|
|
44
|
-
// Only handle HMR for src directory and config files
|
|
45
|
-
const shouldHandle = relativePath.startsWith("src/");
|
|
46
|
-
if (!shouldHandle) {
|
|
47
|
-
return []; // Ignore HMR for build outputs, platforms, node_modules, etc.
|
|
48
|
-
}
|
|
49
|
-
console.log("🔥 HMR update detected for:", relativePath);
|
|
50
|
-
console.log("🔥 Note: This only fires in dev server mode, not build mode");
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
// NativeScript CLI integration - including IPC communication for HMR
|
|
57
|
-
export function cliPlugin(targetMode, cliFlags) {
|
|
58
|
-
return {
|
|
59
|
-
name: "nativescript-cli-integration",
|
|
60
|
-
buildStart() {
|
|
61
|
-
if (targetMode === "development") {
|
|
62
|
-
console.log("🔥 Vite: Build started");
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
writeBundle(options, bundle) {
|
|
66
|
-
if (targetMode === "development") {
|
|
67
|
-
const buildType = isInitialBuild ? "initial" : "incremental";
|
|
68
|
-
console.log(`🔥 NativeScript: ${buildType} build completed`);
|
|
69
|
-
// Get all emitted files from the bundle
|
|
70
|
-
const emittedFiles = Object.keys(bundle);
|
|
71
|
-
// Determine what changed
|
|
72
|
-
const changedFilesList = Array.from(changedFilesTracker);
|
|
73
|
-
// Determine if this should be an HMR update:
|
|
74
|
-
// - Not the initial build
|
|
75
|
-
// - Has specific changed files
|
|
76
|
-
// - Changes are HMR-compatible (HTML templates, CSS, some TS changes)
|
|
77
|
-
const hasHTMLChanges = changedFilesList.some((f) => f.endsWith(".html"));
|
|
78
|
-
const hasCSSChanges = changedFilesList.some((f) => f.endsWith(".css") || f.endsWith(".scss"));
|
|
79
|
-
const hasComponentChanges = changedFilesList.some((f) => f.includes(".component."));
|
|
80
|
-
const canUseHMR = !isInitialBuild &&
|
|
81
|
-
changedFilesList.length > 0 &&
|
|
82
|
-
(hasHTMLChanges || hasCSSChanges || hasComponentChanges);
|
|
83
|
-
const isHMR = canUseHMR && cliFlags.hmr;
|
|
84
|
-
if (changedFilesList.length > 0) {
|
|
85
|
-
console.log("🔥 Changed files triggered rebuild:", changedFilesList);
|
|
86
|
-
console.log("🔥 Can use HMR:", canUseHMR);
|
|
87
|
-
}
|
|
88
|
-
// For TypeScript changes, this will be a full rebuild (expected)
|
|
89
|
-
// For CSS changes, this could potentially be optimized (future enhancement)
|
|
90
|
-
const hasTypeScriptChanges = changedFilesList.some((f) => f.endsWith(".ts"));
|
|
91
|
-
if (hasTypeScriptChanges) {
|
|
92
|
-
console.log("🔥 TypeScript changes detected - full rebuild required");
|
|
93
|
-
}
|
|
94
|
-
if (hasCSSChanges) {
|
|
95
|
-
console.log("🔥 CSS changes detected - could be optimized for HMR in future");
|
|
96
|
-
}
|
|
97
|
-
if (hasHTMLChanges) {
|
|
98
|
-
console.log("🔥 HTML template changes detected - using HMR");
|
|
99
|
-
}
|
|
100
|
-
console.log(`🔥 Emitted ${emittedFiles.length} files in ${buildType} build`);
|
|
101
|
-
// Send IPC message to CLI
|
|
102
|
-
if (process.send) {
|
|
103
|
-
const message = {
|
|
104
|
-
emittedFiles: emittedFiles,
|
|
105
|
-
chunkFiles: emittedFiles.filter((f) => f.includes("chunk") || f.includes("vendor")),
|
|
106
|
-
hash: Date.now().toString(),
|
|
107
|
-
isHMR: isHMR && !isInitialBuild, // Mark as HMR for incremental builds
|
|
108
|
-
changedFiles: changedFilesList,
|
|
109
|
-
buildType: buildType,
|
|
110
|
-
timestamp: Date.now(),
|
|
111
|
-
};
|
|
112
|
-
console.log(`🔥 Sending ${buildType} build notification to CLI (isHMR: ${message.isHMR})`);
|
|
113
|
-
if (changedFilesList.length > 0) {
|
|
114
|
-
console.log("🔥 IPC includes changed files:", changedFilesList);
|
|
115
|
-
}
|
|
116
|
-
process.send(message);
|
|
117
|
-
}
|
|
118
|
-
// Reset trackers AFTER we've used them
|
|
119
|
-
if (isInitialBuild) {
|
|
120
|
-
isInitialBuild = false;
|
|
121
|
-
console.log("🔥 Initial build complete - subsequent changes will trigger fast rebuilds");
|
|
122
|
-
}
|
|
123
|
-
// Clear the tracker for the next build cycle
|
|
124
|
-
changedFilesTracker.clear();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function handleAngularHmrUpdate(): void;
|
package/dist/hmr/hmr-angular.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { isDevMode, ɵresetCompiledComponents,
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
} from "@angular/core";
|
|
4
|
-
export function handleAngularHmrUpdate() {
|
|
5
|
-
// Reset JIT compiled components cache
|
|
6
|
-
ɵresetCompiledComponents();
|
|
7
|
-
try {
|
|
8
|
-
console.log(`typeof global["__cleanup_ng_hot__"]`, typeof global["__cleanup_ng_hot__"]);
|
|
9
|
-
if (global["__cleanup_ng_hot__"])
|
|
10
|
-
global["__cleanup_ng_hot__"]();
|
|
11
|
-
global["__reboot_ng_modules__"]();
|
|
12
|
-
console.log('angular called __reboot_ng_modules__!');
|
|
13
|
-
// need to call some kind of apply here?
|
|
14
|
-
// Webpack would call in this order with angular-hot-loader/hmr-accept:
|
|
15
|
-
/**
|
|
16
|
-
* angular hot dispose called!
|
|
17
|
-
hot dispose called here?!
|
|
18
|
-
__cleanup_ng_hot__ called!
|
|
19
|
-
angular hot accept about to be called!
|
|
20
|
-
Angular is running in development mode.
|
|
21
|
-
[HMR][bd598ae5b97083449f33] success | Successfully applied update.
|
|
22
|
-
calling global.__onLiveSync!
|
|
23
|
-
*/
|
|
24
|
-
global.__onLiveSync();
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
console.error("[NG HMR] Error disposing previous module");
|
|
28
|
-
console.error(e, e?.stack);
|
|
29
|
-
// HMR breaks when rejecting the main module dispose, so we manually trigger an HMR restart
|
|
30
|
-
// const hash = __webpack_require__.h();
|
|
31
|
-
// console.log(`[HMR][${hash}] failure | Error disposing previous module`);
|
|
32
|
-
// throw e;
|
|
33
|
-
}
|
|
34
|
-
}
|
package/dist/hmr/hmr-bridge.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple HMR Notification Bridge
|
|
3
|
-
*
|
|
4
|
-
* This creates a lightweight WebSocket server that the NativeScript CLI
|
|
5
|
-
* can notify when builds complete, and forwards those to the app.
|
|
6
|
-
*/
|
|
7
|
-
declare class SimpleHMRBridge {
|
|
8
|
-
private wsServer;
|
|
9
|
-
private connectedClients;
|
|
10
|
-
private buildProcess;
|
|
11
|
-
start(): Promise<void>;
|
|
12
|
-
private startWebSocketServer;
|
|
13
|
-
private startNativeScriptBuild;
|
|
14
|
-
private parseBuildOutput;
|
|
15
|
-
private notifyClients;
|
|
16
|
-
stop(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export { SimpleHMRBridge };
|
package/dist/hmr/hmr-bridge.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple HMR Notification Bridge
|
|
3
|
-
*
|
|
4
|
-
* This creates a lightweight WebSocket server that the NativeScript CLI
|
|
5
|
-
* can notify when builds complete, and forwards those to the app.
|
|
6
|
-
*/
|
|
7
|
-
import { WebSocketServer } from 'ws';
|
|
8
|
-
import WebSocketType from 'ws';
|
|
9
|
-
import { spawn } from 'child_process';
|
|
10
|
-
import { pathToFileURL } from 'node:url';
|
|
11
|
-
import { resolve } from 'node:path';
|
|
12
|
-
const isMain = () => typeof process !== 'undefined' &&
|
|
13
|
-
!!process.argv?.[1] &&
|
|
14
|
-
import.meta.url === pathToFileURL(resolve(process.argv[1])).href;
|
|
15
|
-
class SimpleHMRBridge {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.connectedClients = new Set();
|
|
18
|
-
}
|
|
19
|
-
async start() {
|
|
20
|
-
console.log('🔥 Starting Simple HMR Bridge...');
|
|
21
|
-
// Start WebSocket server for NativeScript app
|
|
22
|
-
this.startWebSocketServer();
|
|
23
|
-
// Start NativeScript build process
|
|
24
|
-
this.startNativeScriptBuild();
|
|
25
|
-
console.log('🔥 HMR Bridge ready!');
|
|
26
|
-
}
|
|
27
|
-
startWebSocketServer() {
|
|
28
|
-
const HMR_WS_PORT = 24678;
|
|
29
|
-
this.wsServer = new WebSocketServer({ port: HMR_WS_PORT });
|
|
30
|
-
this.wsServer.on('connection', (ws) => {
|
|
31
|
-
console.log('🔥 NativeScript client connected to HMR bridge');
|
|
32
|
-
this.connectedClients.add(ws);
|
|
33
|
-
// Send connection confirmation
|
|
34
|
-
ws.send(JSON.stringify({
|
|
35
|
-
type: 'connected',
|
|
36
|
-
timestamp: Date.now()
|
|
37
|
-
}));
|
|
38
|
-
ws.on('close', () => {
|
|
39
|
-
console.log('🔥 NativeScript client disconnected');
|
|
40
|
-
this.connectedClients.delete(ws);
|
|
41
|
-
});
|
|
42
|
-
ws.on('message', (message) => {
|
|
43
|
-
try {
|
|
44
|
-
const data = JSON.parse(message.toString());
|
|
45
|
-
console.log('🔥 Received from NativeScript:', data);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
console.error('🔥 Invalid message from NativeScript:', e);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
console.log(`🔥 HMR bridge listening on ws://localhost:${HMR_WS_PORT}`);
|
|
53
|
-
}
|
|
54
|
-
startNativeScriptBuild() {
|
|
55
|
-
console.log('🔥 Starting NativeScript build with HMR notifications...');
|
|
56
|
-
// Get platform from command line arguments (default to 'ios' if not provided)
|
|
57
|
-
const platform = process.argv[2] || 'ios';
|
|
58
|
-
console.log(`🔥 Building for platform: ${platform}`);
|
|
59
|
-
// Start ns run with specified platform
|
|
60
|
-
const args = ['debug', platform];
|
|
61
|
-
this.buildProcess = spawn('ns', args, {
|
|
62
|
-
cwd: process.cwd(),
|
|
63
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
64
|
-
env: {
|
|
65
|
-
...process.env,
|
|
66
|
-
NS_HMR_BRIDGE: 'true' // Signal to our Vite config that HMR bridge is active
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
this.buildProcess.stdout.on('data', (data) => {
|
|
70
|
-
const output = data.toString();
|
|
71
|
-
process.stdout.write(output);
|
|
72
|
-
// Listen for build completion messages
|
|
73
|
-
this.parseBuildOutput(output);
|
|
74
|
-
});
|
|
75
|
-
this.buildProcess.stderr.on('data', (data) => {
|
|
76
|
-
process.stderr.write(data);
|
|
77
|
-
});
|
|
78
|
-
this.buildProcess.on('close', (code) => {
|
|
79
|
-
console.log(`🔥 NativeScript build process exited with code ${code}`);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
parseBuildOutput(output) {
|
|
83
|
-
// Look for our HMR indicators in the build output
|
|
84
|
-
const lines = output.split('\n');
|
|
85
|
-
for (const line of lines) {
|
|
86
|
-
// Look for our HMR build completion messages
|
|
87
|
-
if (line.includes('🔥 HMR update - copying only changed files')) {
|
|
88
|
-
// Extract changed files from the next lines
|
|
89
|
-
const changedFilesMatch = line.match(/🔥 HMR update - copying only changed files for: (.+)/);
|
|
90
|
-
if (changedFilesMatch) {
|
|
91
|
-
try {
|
|
92
|
-
const changedFiles = JSON.parse(changedFilesMatch[1].replace(/'/g, '"'));
|
|
93
|
-
this.notifyClients({
|
|
94
|
-
type: 'build-complete',
|
|
95
|
-
timestamp: Date.now(),
|
|
96
|
-
changedFiles,
|
|
97
|
-
buildType: 'incremental',
|
|
98
|
-
isHMR: true
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
catch (e) {
|
|
102
|
-
console.log('🔥 Could not parse changed files from:', changedFilesMatch[1]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else if (line.includes('🔥 Full build - copying all files')) {
|
|
107
|
-
this.notifyClients({
|
|
108
|
-
type: 'build-complete',
|
|
109
|
-
timestamp: Date.now(),
|
|
110
|
-
buildType: 'full',
|
|
111
|
-
isHMR: false
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else if (line.includes('Vite build completed!')) {
|
|
115
|
-
// Build is done, notify clients
|
|
116
|
-
console.log('🔥 Build completed, notifying clients...');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
notifyClients(update) {
|
|
121
|
-
const message = JSON.stringify(update);
|
|
122
|
-
let sentCount = 0;
|
|
123
|
-
this.connectedClients.forEach((client) => {
|
|
124
|
-
if (client.readyState === WebSocketType.OPEN) {
|
|
125
|
-
client.send(message);
|
|
126
|
-
sentCount++;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
if (sentCount > 0) {
|
|
130
|
-
console.log(`🔥 Notified ${sentCount} clients of update:`, update.type);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async stop() {
|
|
134
|
-
console.log('🔥 Stopping HMR bridge...');
|
|
135
|
-
if (this.buildProcess) {
|
|
136
|
-
this.buildProcess.kill('SIGTERM');
|
|
137
|
-
}
|
|
138
|
-
if (this.wsServer) {
|
|
139
|
-
this.wsServer.close();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// Export for use in startup script
|
|
144
|
-
export { SimpleHMRBridge };
|
|
145
|
-
// Auto-start if run directly
|
|
146
|
-
if (isMain()) {
|
|
147
|
-
const bridge = new SimpleHMRBridge();
|
|
148
|
-
bridge.start().catch(console.error);
|
|
149
|
-
// Handle graceful shutdown
|
|
150
|
-
process.on('SIGINT', () => {
|
|
151
|
-
console.log('\n🔥 Shutting down HMR bridge...');
|
|
152
|
-
bridge.stop().then(() => process.exit(0));
|
|
153
|
-
});
|
|
154
|
-
}
|
package/dist/hmr/hmr-client.d.ts
DELETED
package/dist/hmr/hmr-client.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple NativeScript HMR Client for Vite
|
|
3
|
-
* Based on @nativescript/webpack loaders but simplified for Vite
|
|
4
|
-
*/
|
|
5
|
-
// Import WebSocket polyfill directly
|
|
6
|
-
import { WebSocket as NativeScriptWebSocket } from '@valor/nativescript-websockets/websocket';
|
|
7
|
-
// Ensure WebSocket is available globally for other code
|
|
8
|
-
if (typeof global !== 'undefined') {
|
|
9
|
-
global.WebSocket = NativeScriptWebSocket;
|
|
10
|
-
}
|
|
11
|
-
// Make WebSocket available in current scope
|
|
12
|
-
const WebSocket = NativeScriptWebSocket;
|
|
13
|
-
// import { Application } from "@nativescript/core";
|
|
14
|
-
let hmrBootEmittedSymbol = Symbol.for("HMRBootEmitted");
|
|
15
|
-
let originalLiveSyncSymbol = Symbol.for("OriginalLiveSync");
|
|
16
|
-
let hmrRuntimeLastLiveSyncSymbol = Symbol.for("HMRRuntimeLastLiveSync");
|
|
17
|
-
if (global.__onLiveSync !== global[hmrRuntimeLastLiveSyncSymbol]) {
|
|
18
|
-
// we store the original liveSync here in case this code runs again
|
|
19
|
-
// which happens when you module.hot.accept() the main file
|
|
20
|
-
global[originalLiveSyncSymbol] = global.__onLiveSync;
|
|
21
|
-
}
|
|
22
|
-
global[hmrRuntimeLastLiveSyncSymbol] = async function () {
|
|
23
|
-
console.log(`calling global[hmrRuntimeLastLiveSyncSymbol]`);
|
|
24
|
-
await global[originalLiveSyncSymbol]();
|
|
25
|
-
};
|
|
26
|
-
global.__onLiveSync = global[hmrRuntimeLastLiveSyncSymbol];
|
|
27
|
-
if (!global[hmrBootEmittedSymbol]) {
|
|
28
|
-
global[hmrBootEmittedSymbol] = true;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Note: allow vite to inject each flavor client handling
|
|
32
|
-
* Start Manual Flavor Testing
|
|
33
|
-
*/
|
|
34
|
-
const flavor = "angular";
|
|
35
|
-
import { handleAngularHmrUpdate } from "./hmr-angular.js";
|
|
36
|
-
/**
|
|
37
|
-
* End Manual Flavor Testing
|
|
38
|
-
*/
|
|
39
|
-
class SimpleNativeScriptHMRClient {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.ws = null;
|
|
42
|
-
console.log("🔥 Simple HMR Client starting...");
|
|
43
|
-
console.log("🔥 WebSocket available:", typeof WebSocket !== 'undefined');
|
|
44
|
-
console.log("🔥 global.WebSocket available:", typeof global !== 'undefined' && typeof global.WebSocket !== 'undefined');
|
|
45
|
-
this.connect();
|
|
46
|
-
}
|
|
47
|
-
connect() {
|
|
48
|
-
try {
|
|
49
|
-
// Check if WebSocket is available
|
|
50
|
-
if (typeof WebSocket === 'undefined') {
|
|
51
|
-
console.error("🔥 WebSocket is not available - HMR disabled");
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.ws = new WebSocket("ws://localhost:24678");
|
|
55
|
-
this.ws.onopen = () => {
|
|
56
|
-
console.log("🔥 HMR connected");
|
|
57
|
-
};
|
|
58
|
-
this.ws.onmessage = (event) => {
|
|
59
|
-
try {
|
|
60
|
-
const update = JSON.parse(event.data);
|
|
61
|
-
this.handleUpdate(update);
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
console.error("🔥 HMR message error:", error);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
console.error("🔥 HMR connection failed:", error);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
handleUpdate(update) {
|
|
73
|
-
console.log("🔥 HMR update received:", update.type);
|
|
74
|
-
if (update.type === "build-complete" && update.isHMR) {
|
|
75
|
-
// skip very first one since it's initial build
|
|
76
|
-
console.log("🔥 Applying HMR update for:", update.changedFiles);
|
|
77
|
-
switch (flavor) {
|
|
78
|
-
case "angular":
|
|
79
|
-
// Handle Angular specific HMR updates
|
|
80
|
-
handleAngularHmrUpdate();
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Initialize on app launch
|
|
87
|
-
let hmrClient;
|
|
88
|
-
if (!hmrClient) {
|
|
89
|
-
console.log("🔥 Initializing Simple NativeScript HMR Client");
|
|
90
|
-
// Application.on(Application.launchEvent, () => {
|
|
91
|
-
hmrClient = new SimpleNativeScriptHMRClient();
|
|
92
|
-
// });
|
|
93
|
-
}
|
package/dist/hmr/hmr-server.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NativeScript True HMR Implementation
|
|
3
|
-
*
|
|
4
|
-
* This creates a bridge between Vite's dev server HMR and NativeScript runtime
|
|
5
|
-
* to enable true hot module replacement without losing application state.
|
|
6
|
-
*/
|
|
7
|
-
declare class NativeScriptHMRServer {
|
|
8
|
-
private viteServer;
|
|
9
|
-
private wsServer;
|
|
10
|
-
private buildProcess;
|
|
11
|
-
private connectedClients;
|
|
12
|
-
start(): Promise<void>;
|
|
13
|
-
private startViteDevServer;
|
|
14
|
-
private startHMRBridge;
|
|
15
|
-
private handleViteHMRMessage;
|
|
16
|
-
private broadcastToClients;
|
|
17
|
-
private startBuildProcess;
|
|
18
|
-
stop(): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export { NativeScriptHMRServer };
|