diff --git a/examples/farm/farm.config.ts b/examples/farm/farm.config.ts
new file mode 100644
index 00000000..1246ecb2
--- /dev/null
+++ b/examples/farm/farm.config.ts
@@ -0,0 +1,32 @@
+// import Vue from "unplugin-vue/vite";
+import fs from 'node:fs'
+import { defineConfig } from '@farmfe/core'
+import Vue from 'unplugin-vue/farm'
+
+export default defineConfig({
+ plugins: [Vue(), base()],
+ // vitePlugins: [Vue()],
+ compilation: {
+ progress: false,
+ persistentCache: false
+ },
+})
+
+function base() {
+ return {
+ name: 'farm-load-vue-module-type',
+ priority: -100,
+ load: {
+ filters: {
+ resolvedPaths: ['.vue'],
+ },
+ executor: (param) => {
+ const content = fs.readFileSync(param.resolvedPath, 'utf-8')
+ return {
+ content,
+ moduleType: 'js',
+ }
+ },
+ },
+ }
+}
diff --git a/examples/farm/index.html b/examples/farm/index.html
new file mode 100644
index 00000000..c984e8b7
--- /dev/null
+++ b/examples/farm/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+ Farm + Vue3 + TS
+
+
+
+
+
+
+
+
diff --git a/examples/farm/package.json b/examples/farm/package.json
new file mode 100644
index 00000000..3b79b40f
--- /dev/null
+++ b/examples/farm/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "farm-vue",
+ "version": "1.0.0",
+ "private": true,
+ "scripts": {
+ "dev": "farm start",
+ "start": "farm start",
+ "build": "farm build",
+ "preview": "farm preview",
+ "clean": "farm clean"
+ },
+ "dependencies": {
+ "vue": "^3.4.0"
+ },
+ "devDependencies": {
+ "@farmfe/cli": "/Users/adny/rust/farm/packages/cli",
+ "@farmfe/core": "/Users/adny/rust/farm/packages/core",
+ "@vitejs/plugin-vue": "^5.0.4",
+ "core-js": "^3.30.1",
+ "unplugin-vue": "workspace:*"
+ }
+}
diff --git a/examples/farm/public/favicon.ico b/examples/farm/public/favicon.ico
new file mode 100644
index 00000000..80465ded
Binary files /dev/null and b/examples/farm/public/favicon.ico differ
diff --git a/examples/farm/src/App.vue b/examples/farm/src/App.vue
new file mode 100644
index 00000000..638b3afe
--- /dev/null
+++ b/examples/farm/src/App.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
Hello world
+ {{ msg }}
+
+
+
diff --git a/examples/farm/src/main.ts b/examples/farm/src/main.ts
new file mode 100644
index 00000000..01433bca
--- /dev/null
+++ b/examples/farm/src/main.ts
@@ -0,0 +1,4 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+
+createApp(App).mount('#app')
diff --git a/examples/farm/tsconfig.json b/examples/farm/tsconfig.json
new file mode 100644
index 00000000..26526bc1
--- /dev/null
+++ b/examples/farm/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "module": "ESNext",
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "preserve",
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
+}
diff --git a/package.json b/package.json
index 66998b98..c53eb005 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,10 @@
"require": "./dist/esbuild.cjs",
"import": "./dist/esbuild.js"
},
+ "./farm": {
+ "require": "./dist/farm.cjs",
+ "import": "./dist/farm.js"
+ },
"./api": {
"require": "./dist/api.cjs",
"import": "./dist/api.js"
@@ -86,9 +90,10 @@
"vue": "^3.2.25"
},
"dependencies": {
+ "@farmfe/core": "/Users/adny/rust/farm/packages/core",
"@vue/reactivity": "^3.5.13",
"debug": "^4.3.7",
- "unplugin": "^1.16.0",
+ "unplugin": "/Users/adny/typescript/unplugin",
"vite": "^6.0.0"
},
"devDependencies": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9f8bb90e..906e16fb 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -8,6 +8,9 @@ importers:
.:
dependencies:
+ '@farmfe/core':
+ specifier: /Users/adny/rust/farm/packages/core
+ version: link:../../rust/farm/packages/core
'@vue/reactivity':
specifier: ^3.5.13
version: 3.5.13
@@ -15,8 +18,8 @@ importers:
specifier: ^4.3.7
version: 4.3.7
unplugin:
- specifier: ^1.16.0
- version: 1.16.0
+ specifier: /Users/adny/typescript/unplugin
+ version: link:../unplugin
vite:
specifier: ^6.0.0
version: 6.0.0(@types/node@22.10.0)(jiti@1.21.6)(sass@1.81.0)(terser@5.32.0)(tsx@4.19.1)(yaml@2.5.1)
@@ -83,7 +86,7 @@ importers:
version: 1.2.1
tsup:
specifier: ^8.3.5
- version: 8.3.5(@swc/core@1.9.3)(jiti@1.21.6)(postcss@8.4.49)(tsx@4.19.1)(typescript@5.7.2)(yaml@2.5.1)
+ version: 8.3.5(@swc/core@1.9.3(@swc/helpers@0.5.15))(jiti@1.21.6)(postcss@8.4.49)(tsx@4.19.1)(typescript@5.7.2)(yaml@2.5.1)
typescript:
specifier: ^5.7.2
version: 5.7.2
@@ -95,7 +98,7 @@ importers:
version: 2.1.6(@types/node@22.10.0)(@vitest/ui@2.1.6)(jiti@1.21.6)(sass@1.81.0)(terser@5.32.0)(tsx@4.19.1)(yaml@2.5.1)
webpack:
specifier: ^5.96.1
- version: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)
+ version: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)
examples/esbuild:
dependencies:
@@ -119,6 +122,28 @@ importers:
specifier: workspace:*
version: link:../..
+ examples/farm:
+ dependencies:
+ vue:
+ specifier: ^3.4.0
+ version: 3.5.13(typescript@5.7.2)
+ devDependencies:
+ '@farmfe/cli':
+ specifier: /Users/adny/rust/farm/packages/cli
+ version: link:../../../../rust/farm/packages/cli
+ '@farmfe/core':
+ specifier: /Users/adny/rust/farm/packages/core
+ version: link:../../../../rust/farm/packages/core
+ '@vitejs/plugin-vue':
+ specifier: ^5.0.4
+ version: 5.2.1(vite@6.0.0(@types/node@22.10.0)(jiti@1.21.6)(sass@1.81.0)(terser@5.32.0)(tsx@4.19.1)(yaml@2.5.1))(vue@3.5.13(typescript@5.7.2))
+ core-js:
+ specifier: ^3.30.1
+ version: 3.39.0
+ unplugin-vue:
+ specifier: workspace:*
+ version: link:../..
+
examples/rolldown:
dependencies:
vue:
@@ -165,22 +190,22 @@ importers:
devDependencies:
'@rspack/cli':
specifier: 1.1.4
- version: 1.1.4(@rspack/core@1.1.4)(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ version: 1.1.4(@rspack/core@1.1.4(@swc/helpers@0.5.15))(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
'@rspack/core':
specifier: 1.1.4
- version: 1.1.4
+ version: 1.1.4(@swc/helpers@0.5.15)
css-loader:
specifier: ^7.1.2
- version: 7.1.2(@rspack/core@1.1.4)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ version: 7.1.2(@rspack/core@1.1.4(@swc/helpers@0.5.15))(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
serve:
specifier: ^14.2.4
version: 14.2.4
style-loader:
specifier: ^4.0.0
- version: 4.0.0(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ version: 4.0.0(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
ts-node:
specifier: ^10.9.2
- version: 10.9.2(@swc/core@1.9.3)(@types/node@22.10.0)(typescript@5.7.2)
+ version: 10.9.2(@swc/core@1.9.3(@swc/helpers@0.5.15))(@types/node@22.10.0)(typescript@5.7.2)
unplugin-vue:
specifier: workspace:*
version: link:../..
@@ -209,16 +234,16 @@ importers:
devDependencies:
'@swc/core':
specifier: ^1.9.3
- version: 1.9.3
+ version: 1.9.3(@swc/helpers@0.5.15)
'@types/webpack':
specifier: ^5.28.5
- version: 5.28.5(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ version: 5.28.5(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
css-loader:
specifier: ^7.1.2
- version: 7.1.2(@rspack/core@1.1.4)(webpack@5.96.1)
+ version: 7.1.2(@rspack/core@1.1.4(@swc/helpers@0.5.15))(webpack@5.96.1)
html-webpack-plugin:
specifier: ^5.6.3
- version: 5.6.3(@rspack/core@1.1.4)(webpack@5.96.1)
+ version: 5.6.3(@rspack/core@1.1.4(@swc/helpers@0.5.15))(webpack@5.96.1)
serve:
specifier: ^14.2.4
version: 14.2.4
@@ -230,13 +255,13 @@ importers:
version: 3.35.0
swc-loader:
specifier: ^0.2.6
- version: 0.2.6(@swc/core@1.9.3)(webpack@5.96.1)
+ version: 0.2.6(@swc/core@1.9.3(@swc/helpers@0.5.15))(webpack@5.96.1)
unplugin-vue:
specifier: workspace:*
version: link:../..
webpack:
specifier: ^5.96.1
- version: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ version: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
webpack-cli:
specifier: ^5.1.4
version: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1)
@@ -1156,6 +1181,9 @@ packages:
'@swc/counter@0.1.3':
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
+ '@swc/helpers@0.5.15':
+ resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
+
'@swc/types@0.1.17':
resolution: {integrity: sha512-V5gRru+aD8YVyCOMAjMpWR1Ui577DD5KSJsHP8RAxopAH22jFz6GZd/qxqjO6MJHQhcsjvjOFXyDhyLQUnMveQ==}
@@ -1882,6 +1910,9 @@ packages:
core-js-compat@3.38.1:
resolution: {integrity: sha512-JRH6gfXxGmrzF3tZ57lFx97YARxCXPaMzPo6jELZhv88pBH5VXpQ+y0znKGlFnzuaihqhLbefxSJxWJMPtfDzw==}
+ core-js@3.39.0:
+ resolution: {integrity: sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g==}
+
core-util-is@1.0.3:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
@@ -4031,6 +4062,9 @@ packages:
tslib@2.7.0:
resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==}
+ tslib@2.8.1:
+ resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
+
tsup@8.3.5:
resolution: {integrity: sha512-Tunf6r6m6tnZsG9GYWndg0z8dEV7fD733VBFzFJ5Vcm1FtlXB8xBD/rtrBi2a3YKEV7hHtxiZtW5EAVADoe1pA==}
engines: {node: '>=18'}
@@ -5057,11 +5091,11 @@ snapshots:
'@rspack/binding-win32-ia32-msvc': 1.1.4
'@rspack/binding-win32-x64-msvc': 1.1.4
- '@rspack/cli@1.1.4(@rspack/core@1.1.4)(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))':
+ '@rspack/cli@1.1.4(@rspack/core@1.1.4(@swc/helpers@0.5.15))(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))':
dependencies:
'@discoveryjs/json-ext': 0.5.7
- '@rspack/core': 1.1.4
- '@rspack/dev-server': 1.0.9(@rspack/core@1.1.4)(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ '@rspack/core': 1.1.4(@swc/helpers@0.5.15)
+ '@rspack/dev-server': 1.0.9(@rspack/core@1.1.4(@swc/helpers@0.5.15))(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
colorette: 2.0.19
exit-hook: 4.0.0
interpret: 3.1.1
@@ -5078,24 +5112,26 @@ snapshots:
- webpack
- webpack-cli
- '@rspack/core@1.1.4':
+ '@rspack/core@1.1.4(@swc/helpers@0.5.15)':
dependencies:
'@module-federation/runtime-tools': 0.5.1
'@rspack/binding': 1.1.4
'@rspack/lite-tapable': 1.0.1
caniuse-lite: 1.0.30001684
+ optionalDependencies:
+ '@swc/helpers': 0.5.15
- '@rspack/dev-server@1.0.9(@rspack/core@1.1.4)(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))':
+ '@rspack/dev-server@1.0.9(@rspack/core@1.1.4(@swc/helpers@0.5.15))(@types/express@4.17.21)(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))':
dependencies:
- '@rspack/core': 1.1.4
+ '@rspack/core': 1.1.4(@swc/helpers@0.5.15)
chokidar: 3.6.0
connect-history-api-fallback: 2.0.0
express: 4.21.0
http-proxy-middleware: 2.0.6(@types/express@4.17.21)(debug@4.3.7)
mime-types: 2.1.35
p-retry: 4.6.2
- webpack-dev-middleware: 7.4.2(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
- webpack-dev-server: 5.0.4(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ webpack-dev-middleware: 7.4.2(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
+ webpack-dev-server: 5.0.4(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
ws: 8.18.0
transitivePeerDependencies:
- '@types/express'
@@ -5138,7 +5174,7 @@ snapshots:
'@swc/core-win32-x64-msvc@1.9.3':
optional: true
- '@swc/core@1.9.3':
+ '@swc/core@1.9.3(@swc/helpers@0.5.15)':
dependencies:
'@swc/counter': 0.1.3
'@swc/types': 0.1.17
@@ -5153,9 +5189,15 @@ snapshots:
'@swc/core-win32-arm64-msvc': 1.9.3
'@swc/core-win32-ia32-msvc': 1.9.3
'@swc/core-win32-x64-msvc': 1.9.3
+ '@swc/helpers': 0.5.15
'@swc/counter@0.1.3': {}
+ '@swc/helpers@0.5.15':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@swc/types@0.1.17':
dependencies:
'@swc/counter': 0.1.3
@@ -5327,11 +5369,11 @@ snapshots:
'@types/unist@3.0.3': {}
- '@types/webpack@5.28.5(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)':
+ '@types/webpack@5.28.5(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)':
dependencies:
'@types/node': 22.10.0
tapable: 2.2.1
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
transitivePeerDependencies:
- '@swc/core'
- esbuild
@@ -5633,17 +5675,17 @@ snapshots:
'@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4)(webpack@5.96.1)':
dependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1)
'@webpack-cli/info@2.0.2(webpack-cli@5.1.4)(webpack@5.96.1)':
dependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1)
'@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack-dev-server@5.1.0)(webpack@5.96.1)':
dependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1)
optionalDependencies:
webpack-dev-server: 5.1.0(debug@4.3.7)(webpack-cli@5.1.4)(webpack@5.96.1)
@@ -6032,6 +6074,8 @@ snapshots:
dependencies:
browserslist: 4.24.2
+ core-js@3.39.0: {}
+
core-util-is@1.0.3: {}
create-require@1.1.1: {}
@@ -6042,7 +6086,7 @@ snapshots:
shebang-command: 2.0.0
which: 2.0.2
- css-loader@7.1.2(@rspack/core@1.1.4)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)):
+ css-loader@7.1.2(@rspack/core@1.1.4(@swc/helpers@0.5.15))(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)):
dependencies:
icss-utils: 5.1.0(postcss@8.4.49)
postcss: 8.4.49
@@ -6053,10 +6097,10 @@ snapshots:
postcss-value-parser: 4.2.0
semver: 7.6.3
optionalDependencies:
- '@rspack/core': 1.1.4
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)
+ '@rspack/core': 1.1.4(@swc/helpers@0.5.15)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)
- css-loader@7.1.2(@rspack/core@1.1.4)(webpack@5.96.1):
+ css-loader@7.1.2(@rspack/core@1.1.4(@swc/helpers@0.5.15))(webpack@5.96.1):
dependencies:
icss-utils: 5.1.0(postcss@8.4.49)
postcss: 8.4.49
@@ -6067,8 +6111,8 @@ snapshots:
postcss-value-parser: 4.2.0
semver: 7.6.3
optionalDependencies:
- '@rspack/core': 1.1.4
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ '@rspack/core': 1.1.4(@swc/helpers@0.5.15)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
css-select@4.3.0:
dependencies:
@@ -6869,7 +6913,7 @@ snapshots:
relateurl: 0.2.7
terser: 5.32.0
- html-webpack-plugin@5.6.3(@rspack/core@1.1.4)(webpack@5.96.1):
+ html-webpack-plugin@5.6.3(@rspack/core@1.1.4(@swc/helpers@0.5.15))(webpack@5.96.1):
dependencies:
'@types/html-minifier-terser': 6.1.0
html-minifier-terser: 6.1.0
@@ -6877,8 +6921,8 @@ snapshots:
pretty-error: 4.0.0
tapable: 2.2.1
optionalDependencies:
- '@rspack/core': 1.1.4
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ '@rspack/core': 1.1.4(@swc/helpers@0.5.15)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
htmlparser2@6.1.0:
dependencies:
@@ -8315,13 +8359,13 @@ snapshots:
strip-json-comments@3.1.1: {}
- style-loader@4.0.0(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)):
+ style-loader@4.0.0(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)):
dependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)
style-loader@4.0.0(webpack@5.96.1):
dependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
sucrase@3.35.0:
dependencies:
@@ -8347,11 +8391,11 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {}
- swc-loader@0.2.6(@swc/core@1.9.3)(webpack@5.96.1):
+ swc-loader@0.2.6(@swc/core@1.9.3(@swc/helpers@0.5.15))(webpack@5.96.1):
dependencies:
- '@swc/core': 1.9.3
+ '@swc/core': 1.9.3(@swc/helpers@0.5.15)
'@swc/counter': 0.1.3
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
synckit@0.6.2:
dependencies:
@@ -8373,28 +8417,28 @@ snapshots:
mkdirp: 1.0.4
yallist: 4.0.0
- terser-webpack-plugin@5.3.10(@swc/core@1.9.3)(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)):
+ terser-webpack-plugin@5.3.10(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)):
dependencies:
'@jridgewell/trace-mapping': 0.3.25
jest-worker: 27.5.1
schema-utils: 3.3.0
serialize-javascript: 6.0.2
terser: 5.32.0
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)
optionalDependencies:
- '@swc/core': 1.9.3
+ '@swc/core': 1.9.3(@swc/helpers@0.5.15)
esbuild: 0.24.0
- terser-webpack-plugin@5.3.10(@swc/core@1.9.3)(esbuild@0.24.0)(webpack@5.96.1):
+ terser-webpack-plugin@5.3.10(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack@5.96.1):
dependencies:
'@jridgewell/trace-mapping': 0.3.25
jest-worker: 27.5.1
schema-utils: 3.3.0
serialize-javascript: 6.0.2
terser: 5.32.0
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
optionalDependencies:
- '@swc/core': 1.9.3
+ '@swc/core': 1.9.3(@swc/helpers@0.5.15)
esbuild: 0.24.0
terser@5.32.0:
@@ -8459,7 +8503,7 @@ snapshots:
ts-interface-checker@0.1.13: {}
- ts-node@10.9.2(@swc/core@1.9.3)(@types/node@22.10.0)(typescript@5.7.2):
+ ts-node@10.9.2(@swc/core@1.9.3(@swc/helpers@0.5.15))(@types/node@22.10.0)(typescript@5.7.2):
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.11
@@ -8477,11 +8521,14 @@ snapshots:
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
optionalDependencies:
- '@swc/core': 1.9.3
+ '@swc/core': 1.9.3(@swc/helpers@0.5.15)
tslib@2.7.0: {}
- tsup@8.3.5(@swc/core@1.9.3)(jiti@1.21.6)(postcss@8.4.49)(tsx@4.19.1)(typescript@5.7.2)(yaml@2.5.1):
+ tslib@2.8.1:
+ optional: true
+
+ tsup@8.3.5(@swc/core@1.9.3(@swc/helpers@0.5.15))(jiti@1.21.6)(postcss@8.4.49)(tsx@4.19.1)(typescript@5.7.2)(yaml@2.5.1):
dependencies:
bundle-require: 5.0.0(esbuild@0.24.0)
cac: 6.7.14
@@ -8500,7 +8547,7 @@ snapshots:
tinyglobby: 0.2.10
tree-kill: 1.2.2
optionalDependencies:
- '@swc/core': 1.9.3
+ '@swc/core': 1.9.3(@swc/helpers@0.5.15)
postcss: 8.4.49
typescript: 5.7.2
transitivePeerDependencies:
@@ -8783,12 +8830,12 @@ snapshots:
import-local: 3.2.0
interpret: 3.1.1
rechoir: 0.8.0
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
webpack-merge: 5.10.0
optionalDependencies:
webpack-dev-server: 5.1.0(debug@4.3.7)(webpack-cli@5.1.4)(webpack@5.96.1)
- webpack-dev-middleware@7.4.2(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)):
+ webpack-dev-middleware@7.4.2(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)):
dependencies:
colorette: 2.0.20
memfs: 4.11.1
@@ -8797,7 +8844,7 @@ snapshots:
range-parser: 1.2.1
schema-utils: 4.2.0
optionalDependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)
webpack-dev-middleware@7.4.2(webpack@5.96.1):
dependencies:
@@ -8808,9 +8855,9 @@ snapshots:
range-parser: 1.2.1
schema-utils: 4.2.0
optionalDependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
- webpack-dev-server@5.0.4(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)):
+ webpack-dev-server@5.0.4(debug@4.3.7)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)):
dependencies:
'@types/bonjour': 3.5.13
'@types/connect-history-api-fallback': 1.5.4
@@ -8840,10 +8887,10 @@ snapshots:
serve-index: 1.9.1
sockjs: 0.3.24
spdy: 4.0.2
- webpack-dev-middleware: 7.4.2(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ webpack-dev-middleware: 7.4.2(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
ws: 8.18.0
optionalDependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)
transitivePeerDependencies:
- bufferutil
- debug
@@ -8881,7 +8928,7 @@ snapshots:
webpack-dev-middleware: 7.4.2(webpack@5.96.1)
ws: 8.18.0
optionalDependencies:
- webpack: 5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4)
+ webpack: 5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4)
webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1)
transitivePeerDependencies:
- bufferutil
@@ -8899,7 +8946,7 @@ snapshots:
webpack-virtual-modules@0.6.2: {}
- webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0):
+ webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0):
dependencies:
'@types/eslint-scope': 3.7.7
'@types/estree': 1.0.6
@@ -8921,7 +8968,7 @@ snapshots:
neo-async: 2.6.2
schema-utils: 3.3.0
tapable: 2.2.1
- terser-webpack-plugin: 5.3.10(@swc/core@1.9.3)(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0))
+ terser-webpack-plugin: 5.3.10(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0))
watchpack: 2.4.2
webpack-sources: 3.2.3
transitivePeerDependencies:
@@ -8929,7 +8976,7 @@ snapshots:
- esbuild
- uglify-js
- webpack@5.96.1(@swc/core@1.9.3)(esbuild@0.24.0)(webpack-cli@5.1.4):
+ webpack@5.96.1(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack-cli@5.1.4):
dependencies:
'@types/eslint-scope': 3.7.7
'@types/estree': 1.0.6
@@ -8951,7 +8998,7 @@ snapshots:
neo-async: 2.6.2
schema-utils: 3.3.0
tapable: 2.2.1
- terser-webpack-plugin: 5.3.10(@swc/core@1.9.3)(esbuild@0.24.0)(webpack@5.96.1)
+ terser-webpack-plugin: 5.3.10(@swc/core@1.9.3(@swc/helpers@0.5.15))(esbuild@0.24.0)(webpack@5.96.1)
watchpack: 2.4.2
webpack-sources: 3.2.3
optionalDependencies:
diff --git a/src/core/index.ts b/src/core/index.ts
index 9ce2c606..8667d12e 100644
--- a/src/core/index.ts
+++ b/src/core/index.ts
@@ -25,6 +25,7 @@ import {
getTempSrcDescriptor,
} from './utils/descriptorCache'
import { parseVueRequest } from './utils/query'
+import type { ResolvedUserConfig, Server } from '@farmfe/core'
import type {
SFCBlock,
SFCScriptCompileOptions,
@@ -231,10 +232,8 @@ export const plugin = createUnplugin(
},
version,
}
-
return {
name: 'unplugin-vue',
-
vite: {
api,
handleHotUpdate(ctx) {
@@ -321,6 +320,87 @@ export const plugin = createUnplugin(
},
},
+ farm: {
+ config(config: ResolvedUserConfig) {
+ return {
+ compilation: {
+ resolve: {
+ dedupe:
+ config.compilation.output?.targetEnv === 'node'
+ ? []
+ : ['vue'],
+ },
+ define: {
+ __VUE_OPTIONS_API__: !!(
+ (options.value.features?.optionsAPI ?? true) ||
+ config.define?.__VUE_OPTIONS_API__
+ ),
+ __VUE_PROD_DEVTOOLS__: !!(
+ options.value.features?.prodDevtools ||
+ config.define?.__VUE_PROD_DEVTOOLS__
+ ),
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !!(
+ options.value.features?.prodHydrationMismatchDetails ||
+ config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__
+ ),
+ },
+ },
+ }
+ },
+
+ configResolved(config) {
+ options.value = {
+ ...options.value,
+ root: config.root,
+ sourceMap: config.compilation?.sourcemap,
+ cssDevSourcemap: config.compilation?.sourcemap,
+ isProduction: config.compilation?.mode === 'production',
+ compiler: options.value.compiler || resolveCompiler(config.root),
+ devToolsEnabled: !!(
+ options.value.features.prodDevtools ||
+ config.compilation.define!.__VUE_PROD_DEVTOOLS__ ||
+ config.compilation?.mode !== 'production'
+ ),
+ }
+ },
+
+ configureServer(server: Server) {
+ const {
+ config: {
+ compilation: {
+ output: { publicPath },
+ },
+ },
+ } = server
+ options.value.devServer = Object.assign(server, {
+ config: { ...server.config, base: publicPath },
+ })
+ },
+
+ updateModules: {
+ executor(ctx) {
+ options.value.devServer.ws.send({
+ type: 'custom',
+ event: 'file-changed',
+ data: { file: normalizePath(ctx.file) },
+ })
+ if (options.value.compiler.invalidateTypeCache) {
+ options.value.compiler.invalidateTypeCache(ctx.file)
+ }
+ if (typeDepToSFCMap.has(ctx.file)) {
+ handleTypeDepChange(typeDepToSFCMap.get(ctx.file)!, ctx)
+ }
+ if (filter.value(ctx.file)) {
+ handleHotUpdate(
+ ctx,
+ options.value,
+ customElementFilter.value(ctx.file),
+ )
+ }
+ },
+ },
+ },
+
buildStart() {
const compiler = (options.value.compiler =
options.value.compiler || resolveCompiler(options.value.root))
@@ -345,7 +425,6 @@ export const plugin = createUnplugin(
loadInclude(id) {
if (id === EXPORT_HELPER_ID) return true
-
const { query } = parseVueRequest(id)
return query.vue
},
@@ -397,7 +476,7 @@ export const plugin = createUnplugin(
return true
},
- transform(code, id) {
+ async transform(code, id) {
const ssr = options.value.ssr
const { filename, query } = parseVueRequest(id)
const context = Object.assign({}, this, meta)
@@ -416,7 +495,7 @@ export const plugin = createUnplugin(
// sub block request
const descriptor = query.src
? getSrcDescriptor(filename, query) ||
- getTempSrcDescriptor(filename, query)
+ getTempSrcDescriptor(filename, query)
: getDescriptor(filename, options.value)!
if (query.type === 'template') {
diff --git a/src/farm.ts b/src/farm.ts
new file mode 100644
index 00000000..88532e17
--- /dev/null
+++ b/src/farm.ts
@@ -0,0 +1,4 @@
+import { plugin } from './core'
+
+// eslint-disable-next-line import/no-default-export
+export default plugin.farm as typeof plugin.farm
diff --git a/tsup.config.ts b/tsup.config.ts
index 522b3c7c..487df79c 100644
--- a/tsup.config.ts
+++ b/tsup.config.ts
@@ -6,7 +6,7 @@ export default defineConfig({
format: ['esm', 'cjs'],
target: 'node18',
clean: true,
- dts: true,
+ // dts: true,
splitting: true,
cjsInterop: true,
shims: true,