@addfox/rsbuild-plugin-vue 0.1.1-beta.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 addfox
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/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # @addfox/rsbuild-plugin-vue
2
+
3
+ [中文](README-zh_CN.md) | English
4
+
5
+ ---
6
+
7
+ Rsbuild plugin: enables Vue 3 (SFC, Vue JSX, Babel) for addfox projects. Use in addfox.config as `plugins: [vue()]`.
8
+
9
+ - Users: `import vue from "@addfox/rsbuild-plugin-vue"; plugins: [vue()]`
10
+ - Depends on @rsbuild/plugin-vue, @rsbuild/plugin-vue-jsx, @rsbuild/plugin-babel.
@@ -0,0 +1,11 @@
1
+ import type { RsbuildPlugin } from "@rsbuild/core";
2
+ /** Return Rsbuild plugins to prepend before addfox-vue (Vue + Vue JSX via @rsbuild/plugin-vue-jsx; Babel required by vue-jsx). */
3
+ export declare function getVueRsbuildPlugins(appRoot: string,
4
+ /** Optional require (e.g. for tests to simulate missing deps). */
5
+ appRequireOverride?: NodeRequire): unknown[];
6
+ /**
7
+ * Rsbuild plugin for Vue 3 + Vue JSX (via @rsbuild/plugin-vue-jsx).
8
+ * Usage: import vue from "@addfox/rsbuild-plugin-vue"; plugins: [vue()]
9
+ */
10
+ export declare function addfoxVuePlugin(): RsbuildPlugin;
11
+ export default addfoxVuePlugin;
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ import { createRequire } from "module";
2
+ import { resolve } from "path";
3
+ function createAppRequire(appRoot) {
4
+ return createRequire(resolve(appRoot, "package.json"));
5
+ }
6
+ function getVueRsbuildPlugins(appRoot, appRequireOverride) {
7
+ const appRequire = appRequireOverride ?? createAppRequire(appRoot);
8
+ try {
9
+ const { pluginBabel } = appRequire("@rsbuild/plugin-babel");
10
+ const { pluginVue } = appRequire("@rsbuild/plugin-vue");
11
+ const { pluginVueJsx } = appRequire("@rsbuild/plugin-vue-jsx");
12
+ return [
13
+ pluginBabel({
14
+ include: /\.(?:jsx|tsx)$/
15
+ }),
16
+ pluginVue(),
17
+ pluginVueJsx()
18
+ ];
19
+ } catch {
20
+ return [];
21
+ }
22
+ }
23
+ function addfoxVuePlugin() {
24
+ return {
25
+ name: "rsbuild-plugin-vue",
26
+ enforce: "pre",
27
+ setup () {}
28
+ };
29
+ }
30
+ const src = addfoxVuePlugin;
31
+ export default src;
32
+ export { addfoxVuePlugin, getVueRsbuildPlugins };
33
+
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from \"module\";\nimport { resolve } from \"path\";\nimport type { RsbuildPlugin } from \"@rsbuild/core\";\n\n/**\n * Create require that resolves from app root so @rsbuild/plugin-vue, @rsbuild/plugin-vue-jsx and @rsbuild/plugin-babel\n * are found in the app's node_modules (e.g. examples/manual-install).\n */\nfunction createAppRequire(appRoot: string) {\n return createRequire(resolve(appRoot, \"package.json\"));\n}\n\n/** Return Rsbuild plugins to prepend before addfox-vue (Vue + Vue JSX via @rsbuild/plugin-vue-jsx; Babel required by vue-jsx). */\nexport function getVueRsbuildPlugins(\n appRoot: string,\n /** Optional require (e.g. for tests to simulate missing deps). */\n appRequireOverride?: NodeRequire\n): unknown[] {\n const appRequire = appRequireOverride ?? createAppRequire(appRoot);\n try {\n const { pluginBabel } = appRequire(\"@rsbuild/plugin-babel\");\n const { pluginVue } = appRequire(\"@rsbuild/plugin-vue\");\n const { pluginVueJsx } = appRequire(\"@rsbuild/plugin-vue-jsx\");\n return [\n pluginBabel({ include: /\\.(?:jsx|tsx)$/ }),\n pluginVue(),\n pluginVueJsx(),\n ];\n } catch {\n return [];\n }\n}\n\n/**\n * Rsbuild plugin for Vue 3 + Vue JSX (via @rsbuild/plugin-vue-jsx).\n * Usage: import vue from \"@addfox/rsbuild-plugin-vue\"; plugins: [vue()]\n */\nexport function addfoxVuePlugin(): RsbuildPlugin {\n return {\n name: \"rsbuild-plugin-vue\",\n enforce: \"pre\",\n setup() {\n // Vue/Babel plugins are injected by CLI via getVueRsbuildPlugins before createRsbuild.\n },\n } satisfies RsbuildPlugin;\n}\n\nexport default addfoxVuePlugin;\n"],"names":["createAppRequire","appRoot","createRequire","resolve","getVueRsbuildPlugins","appRequireOverride","appRequire","pluginBabel","pluginVue","pluginVueJsx","addfoxVuePlugin"],"mappings":";;AAQA,SAASA,iBAAiBC,OAAe;IACvC,OAAOC,cAAcC,QAAQF,SAAS;AACxC;AAGO,SAASG,qBACdH,OAAe,EAEfI,kBAAgC;IAEhC,MAAMC,aAAaD,sBAAsBL,iBAAiBC;IAC1D,IAAI;QACF,MAAM,EAAEM,WAAW,EAAE,GAAGD,WAAW;QACnC,MAAM,EAAEE,SAAS,EAAE,GAAGF,WAAW;QACjC,MAAM,EAAEG,YAAY,EAAE,GAAGH,WAAW;QACpC,OAAO;YACLC,YAAY;gBAAE,SAAS;YAAiB;YACxCC;YACAC;SACD;IACH,EAAE,OAAM;QACN,OAAO,EAAE;IACX;AACF;AAMO,SAASC;IACd,OAAO;QACL,MAAM;QACN,SAAS;QACT,UAEA;IACF;AACF;AAEA,YAAeA"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@addfox/rsbuild-plugin-vue",
3
+ "version": "0.1.1-beta.2",
4
+ "description": "addfox plugin: enable Vue 3 (SFC, JSX via @rsbuild/plugin-vue-jsx) for the project",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "main": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "devDependencies": {
21
+ "@rspack/core": "^1.7.8",
22
+ "@rsbuild/core": "^1.7.3",
23
+ "@rsbuild/plugin-babel": "^1.1.2",
24
+ "@rsbuild/plugin-vue": "^1.2.7",
25
+ "@rsbuild/plugin-vue-jsx": "^1.1.2",
26
+ "@rslib/core": "^0.20.0",
27
+ "@rstest/core": "^0.9.2",
28
+ "@rstest/coverage-istanbul": "^0.3.0",
29
+ "@types/node": "^20.0.0",
30
+ "@vue/compiler-sfc": "^3.2.47",
31
+ "typescript": "^5.0.0"
32
+ },
33
+ "peerDependencies": {
34
+ "@rsbuild/core": ">=1.0.0",
35
+ "@rspack/core": ">=1.0.0",
36
+ "@rsbuild/plugin-babel": ">=1.0.0",
37
+ "@rsbuild/plugin-vue": ">=1.0.0",
38
+ "@rsbuild/plugin-vue-jsx": ">=1.0.0",
39
+ "@vue/compiler-sfc": ">=3.0.0",
40
+ "vue": ">=3.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "vue": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "scripts": {
48
+ "build": "rslib build",
49
+ "dev": "rslib build --watch",
50
+ "test": "rstest run",
51
+ "test:coverage": "rstest run --coverage"
52
+ }
53
+ }