@farmfe/plugin-vue 2.0.0-beta.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 farm-fe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/func.js ADDED
@@ -0,0 +1,3 @@
1
+ import binPath from "./index.js";
2
+
3
+ export default (options)=>[binPath,options];
package/index.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ export interface VueFeaturesOptions {
2
+ /**
3
+ * Drives the `__VUE_OPTIONS_API__` runtime define. Defaults to `true`,
4
+ * matching `@vitejs/plugin-vue` and `unplugin-vue`.
5
+ */
6
+ optionsAPI?: boolean;
7
+ /**
8
+ * Drives `__VUE_PROD_DEVTOOLS__`. Defaults to `false`.
9
+ */
10
+ prodDevtools?: boolean;
11
+ /**
12
+ * Drives `__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`. Defaults to `false`.
13
+ */
14
+ prodHydrationMismatchDetails?: boolean;
15
+ /**
16
+ * Enable reactive destructure for `defineProps`. Forwarded to fervid.
17
+ */
18
+ propsDestructure?: boolean;
19
+ /**
20
+ * Files matching this pattern are compiled as custom elements.
21
+ *
22
+ * @default /\.ce\.vue$/
23
+ */
24
+ customElement?: boolean | string | RegExp | (string | RegExp)[];
25
+ }
26
+
27
+ export interface VuePluginOptions {
28
+ /**
29
+ * Files matched by this filter are treated as Vue SFCs.
30
+ *
31
+ * @default /\.vue$/
32
+ */
33
+ include?: string | RegExp | (string | RegExp)[];
34
+ /**
35
+ * Files excluded from the Vue SFC pipeline.
36
+ */
37
+ exclude?: string | RegExp | (string | RegExp)[];
38
+
39
+ /**
40
+ * Force production mode regardless of Farm's compilation mode.
41
+ */
42
+ isProduction?: boolean;
43
+
44
+ /**
45
+ * Enable SSR codegen path. Experimental — fervid SSR support is partial.
46
+ */
47
+ ssr?: boolean;
48
+
49
+ /**
50
+ * Emit source maps for the compiled Vue output. Defaults to `true`.
51
+ */
52
+ sourceMap?: boolean;
53
+
54
+ /**
55
+ * @deprecated prefer `features.customElement`.
56
+ */
57
+ customElement?: boolean | string | RegExp | (string | RegExp)[];
58
+
59
+ features?: VueFeaturesOptions;
60
+ }
61
+
62
+ /**
63
+ * Farm Rust plugin to compile Vue 3 Single-File Components.
64
+ *
65
+ * Phase A — coarse HMR (full module reload on change). Granular HMR,
66
+ * preprocessor re-scoping, custom blocks and type-dep tracking are tracked
67
+ * as follow-up work; see the plugin docs for the full feature matrix.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import vue from "@farmfe/plugin-vue";
72
+ *
73
+ * export default {
74
+ * plugins: [vue()],
75
+ * };
76
+ * ```
77
+ */
78
+ declare const vue: (options?: VuePluginOptions) => [string, string];
79
+ export default vue;
package/index.js ADDED
@@ -0,0 +1,122 @@
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import { createRequire } from 'module';
3
+ import { dirname, join } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ const { platform, arch } = process;
7
+ const currentDir = dirname(fileURLToPath(import.meta.url));
8
+
9
+ let binPath = null;
10
+
11
+ const require = createRequire(import.meta.url);
12
+
13
+ function isMusl() {
14
+ // For Node 10
15
+ if (!process.report || typeof process.report.getReport !== 'function') {
16
+ try {
17
+ return readFileSync('/usr/bin/ldd', 'utf8').includes('musl');
18
+ } catch (e) {
19
+ return true;
20
+ }
21
+ } else {
22
+ const { glibcVersionRuntime } = process.report.getReport().header;
23
+ return !glibcVersionRuntime;
24
+ }
25
+ }
26
+
27
+ switch (platform) {
28
+ case 'win32':
29
+ switch (arch) {
30
+ case 'x64':
31
+ if (existsSync(join(currentDir, './npm/win32-x64-msvc/index.farm'))) {
32
+ binPath = join(currentDir, './npm/win32-x64-msvc/index.farm');
33
+ } else {
34
+ binPath = require.resolve('@farmfe/plugin-vue-win32-x64-msvc');
35
+ }
36
+
37
+ break;
38
+ case 'ia32':
39
+ if (existsSync(join(currentDir, './npm/win32-ia32-msvc/index.farm'))) {
40
+ binPath = join(currentDir, './npm/win32-ia32-msvc/index.farm');
41
+ } else {
42
+ binPath = require.resolve('@farmfe/plugin-vue-win32-ia32-msvc');
43
+ }
44
+
45
+ break;
46
+ case 'arm64':
47
+ if (existsSync(join(currentDir, './npm/win32-arm64-msvc/index.farm'))) {
48
+ binPath = join(currentDir, './npm/win32-arm64-msvc/index.farm');
49
+ } else {
50
+ binPath = require.resolve('@farmfe/plugin-vue-win32-arm64-msvc');
51
+ }
52
+
53
+ break;
54
+ default:
55
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
56
+ }
57
+ break;
58
+ case 'darwin':
59
+ switch (arch) {
60
+ case 'x64':
61
+ if (existsSync(join(currentDir, './npm/darwin-x64/index.farm'))) {
62
+ binPath = join(currentDir, './npm/darwin-x64/index.farm');
63
+ } else {
64
+ binPath = require.resolve('@farmfe/plugin-vue-darwin-x64');
65
+ }
66
+ break;
67
+ case 'arm64':
68
+ if (existsSync(join(currentDir, './npm/darwin-arm64/index.farm'))) {
69
+ binPath = join(currentDir, './npm/darwin-arm64/index.farm');
70
+ } else {
71
+ binPath = require.resolve('@farmfe/plugin-vue-darwin-arm64');
72
+ }
73
+ break;
74
+ default:
75
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
76
+ }
77
+ break;
78
+ case 'linux':
79
+ switch (arch) {
80
+ case 'x64':
81
+ if (isMusl()) {
82
+ if (existsSync(join(currentDir, './npm/linux-x64-musl/index.farm'))) {
83
+ binPath = join(currentDir, './npm/linux-x64-musl/index.farm');
84
+ } else {
85
+ binPath = require.resolve('@farmfe/plugin-vue-linux-x64-musl');
86
+ }
87
+ } else {
88
+ if (existsSync(join(currentDir, './npm/linux-x64-gnu/index.farm'))) {
89
+ binPath = join(currentDir, './npm/linux-x64-gnu/index.farm');
90
+ } else {
91
+ binPath = require.resolve('@farmfe/plugin-vue-linux-x64-gnu');
92
+ }
93
+ }
94
+ break;
95
+ case 'arm64':
96
+ if (isMusl()) {
97
+ if (
98
+ existsSync(join(currentDir, './npm/linux-arm64-musl/index.farm'))
99
+ ) {
100
+ binPath = join(currentDir, './npm/linux-arm64-musl/index.farm');
101
+ } else {
102
+ binPath = require.resolve('@farmfe/plugin-vue-linux-arm64-musl');
103
+ }
104
+ } else {
105
+ if (
106
+ existsSync(join(currentDir, './npm/linux-arm64-gnu/index.farm'))
107
+ ) {
108
+ binPath = join(currentDir, './npm/linux-arm64-gnu/index.farm');
109
+ } else {
110
+ binPath = require.resolve('@farmfe/plugin-vue-linux-arm64-gnu');
111
+ }
112
+ }
113
+ break;
114
+ default:
115
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
116
+ }
117
+ break;
118
+ default:
119
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
120
+ }
121
+
122
+ export default binPath;
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@farmfe/plugin-vue",
3
+ "version": "2.0.0-beta.1",
4
+ "description": "Farm Rust plugin to compile Vue 3 SFCs, powered by fervid.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "module",
8
+ "license": "MIT",
9
+ "devDependencies": {
10
+ "@farmfe/plugin-tools": "2.0.0-beta.3"
11
+ },
12
+ "napi": {
13
+ "binaryName": "farm-plugin-vue",
14
+ "targets": [
15
+ "x86_64-unknown-linux-gnu",
16
+ "x86_64-pc-windows-msvc",
17
+ "x86_64-apple-darwin",
18
+ "aarch64-apple-darwin",
19
+ "aarch64-unknown-linux-gnu",
20
+ "aarch64-unknown-linux-musl",
21
+ "x86_64-unknown-linux-musl",
22
+ "i686-pc-windows-msvc",
23
+ "aarch64-pc-windows-msvc"
24
+ ]
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "import": "./func.js",
29
+ "types": "./index.d.ts",
30
+ "default": "./index.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "files": [
35
+ "index.js",
36
+ "index.d.ts",
37
+ "func.js"
38
+ ],
39
+ "optionalDependencies": {
40
+ "@farmfe/plugin-vue-darwin-arm64": "2.0.0-beta.1",
41
+ "@farmfe/plugin-vue-darwin-x64": "2.0.0-beta.1",
42
+ "@farmfe/plugin-vue-linux-arm64-gnu": "2.0.0-beta.1",
43
+ "@farmfe/plugin-vue-linux-arm64-musl": "2.0.0-beta.1",
44
+ "@farmfe/plugin-vue-linux-x64-gnu": "2.0.0-beta.1",
45
+ "@farmfe/plugin-vue-linux-x64-musl": "2.0.0-beta.1",
46
+ "@farmfe/plugin-vue-win32-arm64-msvc": "2.0.0-beta.1",
47
+ "@farmfe/plugin-vue-win32-ia32-msvc": "2.0.0-beta.1",
48
+ "@farmfe/plugin-vue-win32-x64-msvc": "2.0.0-beta.1"
49
+ },
50
+ "scripts": {
51
+ "build": "farm-plugin-tools build --platform -p farmfe_plugin_vue --release",
52
+ "build:publish": "cross-env CARGO_PROFILE_RELEASE_LTO=fat CARGO_PROFILE_RELEASE_STRIP=symbols CARGO_PROFILE_RELEASE_PANIC=abort CARGO_PROFILE_RELEASE_OPT_LEVEL=z farm-plugin-tools build --platform --cargo-name farmfe_plugin_vue -p farmfe_plugin_vue --release"
53
+ }
54
+ }