@thelacanians/vue-native-vite-plugin 0.1.0

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/dist/index.cjs ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => vueNativePlugin
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ function vueNativePlugin(options = {}) {
27
+ const { platform = "ios", globalName = "VueNativeApp" } = options;
28
+ return {
29
+ name: "vue-native",
30
+ /**
31
+ * Modify Vite's resolved config to set up aliases, defines, and build
32
+ * settings appropriate for a native iOS or Android target.
33
+ */
34
+ config(config, env) {
35
+ const isDev = env.mode !== "production";
36
+ return {
37
+ resolve: {
38
+ alias: {
39
+ // Redirect all 'vue' imports to the native runtime.
40
+ // This means when @vitejs/plugin-vue compiles SFCs and they
41
+ // import from 'vue', they actually get '@thelacanians/vue-native-runtime'
42
+ // which uses the native renderer instead of the DOM renderer.
43
+ vue: "@thelacanians/vue-native-runtime"
44
+ }
45
+ },
46
+ define: {
47
+ // Compile-time flag for development-only code paths
48
+ __DEV__: JSON.stringify(isDev),
49
+ // Platform identifier available at compile time
50
+ __PLATFORM__: JSON.stringify(platform),
51
+ // Replace process.env.NODE_ENV references from @vue/shared and
52
+ // @vue/runtime-core. JavaScriptCore has no `process` global, so
53
+ // leaving these unresolved would crash the bundle on load.
54
+ "process.env.NODE_ENV": JSON.stringify(isDev ? "development" : "production")
55
+ },
56
+ build: {
57
+ // Target ES2020 for modern JavaScript engine compatibility
58
+ // (JavaScriptCore on iOS and V8/J2V8 on Android both support ES2020+)
59
+ target: "es2020",
60
+ // IIFE output for embedding in native app
61
+ lib: {
62
+ entry: config.build?.lib?.entry || "app/main.ts",
63
+ formats: ["iife"],
64
+ name: globalName,
65
+ fileName: () => "vue-native-bundle.js"
66
+ },
67
+ rollupOptions: {
68
+ output: {
69
+ // Ensure everything is inlined into a single file
70
+ inlineDynamicImports: true,
71
+ // Disable code splitting — we need a single bundle file
72
+ manualChunks: void 0
73
+ }
74
+ },
75
+ // Don't clear the output directory (native project may have other files)
76
+ emptyOutDir: false,
77
+ // Generate source maps for debugging in native dev tools
78
+ sourcemap: isDev,
79
+ // Minify in production
80
+ minify: isDev ? false : "esbuild"
81
+ }
82
+ };
83
+ }
84
+ };
85
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @thelacanians/vue-native-vite-plugin — Vite plugin for building Vue Native applications.
3
+ *
4
+ * This plugin is used ALONGSIDE @vitejs/plugin-vue (not as a replacement).
5
+ * It configures Vite to:
6
+ * - Alias 'vue' imports to '@thelacanians/vue-native-runtime' so that Vue SFCs use the
7
+ * native renderer instead of the DOM renderer
8
+ * - Define __DEV__ and __PLATFORM__ compile-time constants
9
+ * - Configure the build for IIFE output suitable for embedding in a native
10
+ * app's JavaScript runtime (JavaScriptCore on iOS, V8/J2V8 on Android)
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // vite.config.ts
15
+ * import vue from '@vitejs/plugin-vue'
16
+ * import vueNative from '@thelacanians/vue-native-vite-plugin'
17
+ *
18
+ * export default defineConfig({
19
+ * plugins: [vue(), vueNative()],
20
+ * })
21
+ * ```
22
+ */
23
+ interface VueNativePluginOptions {
24
+ /**
25
+ * Target platform.
26
+ * - `'ios'` — JavaScriptCore (built into iOS)
27
+ * - `'android'` — V8 via J2V8
28
+ * @default 'ios'
29
+ */
30
+ platform?: 'ios' | 'android';
31
+ /**
32
+ * The global variable name for the IIFE bundle.
33
+ * @default 'VueNativeApp'
34
+ */
35
+ globalName?: string;
36
+ /**
37
+ * Enable hot reload WebSocket server integration.
38
+ * When true, configures the build for watch mode output.
39
+ * @default true
40
+ */
41
+ hotReload?: boolean;
42
+ /**
43
+ * Port for the hot reload WebSocket server (started by `vue-native dev`).
44
+ * @default 8174
45
+ */
46
+ hotReloadPort?: number;
47
+ }
48
+ declare function vueNativePlugin(options?: VueNativePluginOptions): {
49
+ name: string;
50
+ /**
51
+ * Modify Vite's resolved config to set up aliases, defines, and build
52
+ * settings appropriate for a native iOS or Android target.
53
+ */
54
+ config(config: any, env: {
55
+ mode: string;
56
+ }): {
57
+ resolve: {
58
+ alias: {
59
+ vue: string;
60
+ };
61
+ };
62
+ define: {
63
+ __DEV__: string;
64
+ __PLATFORM__: string;
65
+ 'process.env.NODE_ENV': string;
66
+ };
67
+ build: {
68
+ target: string;
69
+ lib: {
70
+ entry: any;
71
+ formats: any;
72
+ name: string;
73
+ fileName: () => string;
74
+ };
75
+ rollupOptions: {
76
+ output: {
77
+ inlineDynamicImports: boolean;
78
+ manualChunks: undefined;
79
+ };
80
+ };
81
+ emptyOutDir: boolean;
82
+ sourcemap: boolean;
83
+ minify: string | boolean;
84
+ };
85
+ };
86
+ };
87
+
88
+ export { type VueNativePluginOptions, vueNativePlugin as default };
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @thelacanians/vue-native-vite-plugin — Vite plugin for building Vue Native applications.
3
+ *
4
+ * This plugin is used ALONGSIDE @vitejs/plugin-vue (not as a replacement).
5
+ * It configures Vite to:
6
+ * - Alias 'vue' imports to '@thelacanians/vue-native-runtime' so that Vue SFCs use the
7
+ * native renderer instead of the DOM renderer
8
+ * - Define __DEV__ and __PLATFORM__ compile-time constants
9
+ * - Configure the build for IIFE output suitable for embedding in a native
10
+ * app's JavaScript runtime (JavaScriptCore on iOS, V8/J2V8 on Android)
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // vite.config.ts
15
+ * import vue from '@vitejs/plugin-vue'
16
+ * import vueNative from '@thelacanians/vue-native-vite-plugin'
17
+ *
18
+ * export default defineConfig({
19
+ * plugins: [vue(), vueNative()],
20
+ * })
21
+ * ```
22
+ */
23
+ interface VueNativePluginOptions {
24
+ /**
25
+ * Target platform.
26
+ * - `'ios'` — JavaScriptCore (built into iOS)
27
+ * - `'android'` — V8 via J2V8
28
+ * @default 'ios'
29
+ */
30
+ platform?: 'ios' | 'android';
31
+ /**
32
+ * The global variable name for the IIFE bundle.
33
+ * @default 'VueNativeApp'
34
+ */
35
+ globalName?: string;
36
+ /**
37
+ * Enable hot reload WebSocket server integration.
38
+ * When true, configures the build for watch mode output.
39
+ * @default true
40
+ */
41
+ hotReload?: boolean;
42
+ /**
43
+ * Port for the hot reload WebSocket server (started by `vue-native dev`).
44
+ * @default 8174
45
+ */
46
+ hotReloadPort?: number;
47
+ }
48
+ declare function vueNativePlugin(options?: VueNativePluginOptions): {
49
+ name: string;
50
+ /**
51
+ * Modify Vite's resolved config to set up aliases, defines, and build
52
+ * settings appropriate for a native iOS or Android target.
53
+ */
54
+ config(config: any, env: {
55
+ mode: string;
56
+ }): {
57
+ resolve: {
58
+ alias: {
59
+ vue: string;
60
+ };
61
+ };
62
+ define: {
63
+ __DEV__: string;
64
+ __PLATFORM__: string;
65
+ 'process.env.NODE_ENV': string;
66
+ };
67
+ build: {
68
+ target: string;
69
+ lib: {
70
+ entry: any;
71
+ formats: any;
72
+ name: string;
73
+ fileName: () => string;
74
+ };
75
+ rollupOptions: {
76
+ output: {
77
+ inlineDynamicImports: boolean;
78
+ manualChunks: undefined;
79
+ };
80
+ };
81
+ emptyOutDir: boolean;
82
+ sourcemap: boolean;
83
+ minify: string | boolean;
84
+ };
85
+ };
86
+ };
87
+
88
+ export { type VueNativePluginOptions, vueNativePlugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,64 @@
1
+ // src/index.ts
2
+ function vueNativePlugin(options = {}) {
3
+ const { platform = "ios", globalName = "VueNativeApp" } = options;
4
+ return {
5
+ name: "vue-native",
6
+ /**
7
+ * Modify Vite's resolved config to set up aliases, defines, and build
8
+ * settings appropriate for a native iOS or Android target.
9
+ */
10
+ config(config, env) {
11
+ const isDev = env.mode !== "production";
12
+ return {
13
+ resolve: {
14
+ alias: {
15
+ // Redirect all 'vue' imports to the native runtime.
16
+ // This means when @vitejs/plugin-vue compiles SFCs and they
17
+ // import from 'vue', they actually get '@thelacanians/vue-native-runtime'
18
+ // which uses the native renderer instead of the DOM renderer.
19
+ vue: "@thelacanians/vue-native-runtime"
20
+ }
21
+ },
22
+ define: {
23
+ // Compile-time flag for development-only code paths
24
+ __DEV__: JSON.stringify(isDev),
25
+ // Platform identifier available at compile time
26
+ __PLATFORM__: JSON.stringify(platform),
27
+ // Replace process.env.NODE_ENV references from @vue/shared and
28
+ // @vue/runtime-core. JavaScriptCore has no `process` global, so
29
+ // leaving these unresolved would crash the bundle on load.
30
+ "process.env.NODE_ENV": JSON.stringify(isDev ? "development" : "production")
31
+ },
32
+ build: {
33
+ // Target ES2020 for modern JavaScript engine compatibility
34
+ // (JavaScriptCore on iOS and V8/J2V8 on Android both support ES2020+)
35
+ target: "es2020",
36
+ // IIFE output for embedding in native app
37
+ lib: {
38
+ entry: config.build?.lib?.entry || "app/main.ts",
39
+ formats: ["iife"],
40
+ name: globalName,
41
+ fileName: () => "vue-native-bundle.js"
42
+ },
43
+ rollupOptions: {
44
+ output: {
45
+ // Ensure everything is inlined into a single file
46
+ inlineDynamicImports: true,
47
+ // Disable code splitting — we need a single bundle file
48
+ manualChunks: void 0
49
+ }
50
+ },
51
+ // Don't clear the output directory (native project may have other files)
52
+ emptyOutDir: false,
53
+ // Generate source maps for debugging in native dev tools
54
+ sourcemap: isDev,
55
+ // Minify in production
56
+ minify: isDev ? false : "esbuild"
57
+ }
58
+ };
59
+ }
60
+ };
61
+ }
62
+ export {
63
+ vueNativePlugin as default
64
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@thelacanians/vue-native-vite-plugin",
3
+ "version": "0.1.0",
4
+ "description": "Vite plugin for Vue Native — builds IIFE bundles for native runtimes",
5
+ "license": "MIT",
6
+ "author": "Vue Native Contributors",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/abdul-hamid-achik/vue-native",
10
+ "directory": "packages/vite-plugin"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "type": "module",
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "files": ["dist"],
27
+ "scripts": {
28
+ "build": "tsup src/index.ts --format esm,cjs --dts",
29
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
30
+ "clean": "rm -rf dist"
31
+ },
32
+ "peerDependencies": {
33
+ "vite": "^6.0.0",
34
+ "@vitejs/plugin-vue": "^5.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "tsup": "^8.4.0",
38
+ "typescript": "^5.7.0",
39
+ "vite": "^6.1.0"
40
+ }
41
+ }