unplugin-relay 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
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,126 @@
1
+ # unplugin-relay
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/unplugin-relay?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-relay)
4
+
5
+ Starter template for [unplugin](https://github.com/unjs/unplugin).
6
+
7
+ ## Template Usage
8
+
9
+ To use this template, clone it down using:
10
+
11
+ ```bash
12
+ npx degit unplugin/unplugin-relay my-unplugin
13
+ ```
14
+
15
+ And do a global replacement of `unplugin-relay` with your plugin name.
16
+
17
+ Then you can start developing your unplugin 🔥
18
+
19
+ To test your plugin, run: `pnpm run dev`
20
+ To release a new version, run: `pnpm run release`
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm i unplugin-relay
26
+ ```
27
+
28
+ <details>
29
+ <summary>Vite</summary><br>
30
+
31
+ ```ts
32
+ // vite.config.ts
33
+ import Starter from "unplugin-relay/vite";
34
+
35
+ export default defineConfig({
36
+ plugins: [Starter({/* options */})],
37
+ });
38
+ ```
39
+
40
+ Example: [`playground/`](./playground/)
41
+
42
+ <br></details>
43
+
44
+ <details>
45
+ <summary>Rollup</summary><br>
46
+
47
+ ```ts
48
+ // rollup.config.js
49
+ import Starter from "unplugin-relay/rollup";
50
+
51
+ export default {
52
+ plugins: [Starter({/* options */})],
53
+ };
54
+ ```
55
+
56
+ <br></details>
57
+
58
+ <details>
59
+ <summary>Rolldown</summary><br>
60
+
61
+ ```ts
62
+ // rolldown.config.js
63
+ import Starter from "unplugin-relay/rolldown";
64
+
65
+ export default {
66
+ plugins: [Starter({/* options */})],
67
+ };
68
+ ```
69
+
70
+ <br></details>
71
+
72
+ <details>
73
+ <summary>Webpack</summary><br>
74
+
75
+ ```ts
76
+ // webpack.config.js
77
+ module.exports = {
78
+ /* ... */
79
+ plugins: [require("unplugin-relay/webpack")({/* options */})],
80
+ };
81
+ ```
82
+
83
+ <br></details>
84
+
85
+ <details>
86
+ <summary>Nuxt</summary><br>
87
+
88
+ ```ts
89
+ // nuxt.config.js
90
+ export default defineNuxtConfig({
91
+ modules: [["unplugin-relay/nuxt", {/* options */}]],
92
+ });
93
+ ```
94
+
95
+ > This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
96
+
97
+ <br></details>
98
+
99
+ <details>
100
+ <summary>Vue CLI</summary><br>
101
+
102
+ ```ts
103
+ // vue.config.js
104
+ module.exports = {
105
+ configureWebpack: {
106
+ plugins: [require("unplugin-relay/webpack")({/* options */})],
107
+ },
108
+ };
109
+ ```
110
+
111
+ <br></details>
112
+
113
+ <details>
114
+ <summary>esbuild</summary><br>
115
+
116
+ ```ts
117
+ // esbuild.config.js
118
+ import { build } from "esbuild";
119
+ import Starter from "unplugin-relay/esbuild";
120
+
121
+ build({
122
+ plugins: [Starter()],
123
+ });
124
+ ```
125
+
126
+ <br></details>
@@ -0,0 +1,7 @@
1
+ import { Options } from "./types-C903-00Z.js";
2
+
3
+ //#region src/astro.d.ts
4
+ declare const _default: (options: Options) => any;
5
+
6
+ //#endregion
7
+ export { _default as default };
package/dist/astro.js ADDED
@@ -0,0 +1,13 @@
1
+ import { src_default } from "./src-BsgyTMzn.js";
2
+
3
+ //#region src/astro.ts
4
+ var astro_default = (options) => ({
5
+ name: "unplugin-relay",
6
+ hooks: { "astro:config:setup": async (astro) => {
7
+ astro.config.vite.plugins ||= [];
8
+ astro.config.vite.plugins.push(src_default.vite(options));
9
+ } }
10
+ });
11
+
12
+ //#endregion
13
+ export { astro_default as default };
@@ -0,0 +1,8 @@
1
+ import * as oxc_transform_relay3 from "oxc-transform-relay";
2
+ import * as esbuild4 from "esbuild";
3
+
4
+ //#region src/esbuild.d.ts
5
+ declare const _default: (options?: oxc_transform_relay3.TransformOptions | undefined) => esbuild4.Plugin;
6
+
7
+ //#endregion
8
+ export { _default as default };
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createEsbuildPlugin } from "unplugin";
3
+
4
+ //#region src/esbuild.ts
5
+ var esbuild_default = createEsbuildPlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { esbuild_default as default };
package/dist/farm.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import * as oxc_transform_relay11 from "oxc-transform-relay";
2
+ import * as _farmfe_core12 from "@farmfe/core";
3
+
4
+ //#region src/farm.d.ts
5
+ declare const _default: (options?: oxc_transform_relay11.TransformOptions | undefined) => _farmfe_core12.JsPlugin;
6
+
7
+ //#endregion
8
+ export { _default as default };
package/dist/farm.js ADDED
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createFarmPlugin } from "unplugin";
3
+
4
+ //#region src/farm.ts
5
+ var farm_default = createFarmPlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { farm_default as default };
@@ -0,0 +1,10 @@
1
+ import { Options } from "./types-C903-00Z.js";
2
+ import * as unplugin13 from "unplugin";
3
+ import { UnpluginFactory } from "unplugin";
4
+
5
+ //#region src/index.d.ts
6
+ declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
+ declare const unplugin: unplugin13.UnpluginInstance<Options | undefined, boolean>;
8
+
9
+ //#endregion
10
+ export { unplugin as default, unplugin, unpluginFactory };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { src_default, unplugin, unpluginFactory } from "./src-BsgyTMzn.js";
2
+
3
+ export { src_default as default, unplugin, unpluginFactory };
package/dist/nuxt.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Options } from "./types-C903-00Z.js";
2
+ import * as _nuxt_schema5 from "@nuxt/schema";
3
+
4
+ //#region src/nuxt.d.ts
5
+ interface ModuleOptions extends Options {}
6
+ declare const _default: _nuxt_schema5.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
+
8
+ //#endregion
9
+ export { ModuleOptions, _default as default };
package/dist/nuxt.js ADDED
@@ -0,0 +1,20 @@
1
+ import "./src-BsgyTMzn.js";
2
+ import { vite_default } from "./vite-DT2H4_FH.js";
3
+ import { webpack_default } from "./webpack-B0bSjJna.js";
4
+ import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
5
+
6
+ //#region src/nuxt.ts
7
+ var nuxt_default = defineNuxtModule({
8
+ meta: {
9
+ name: "nuxt-unplugin-relay",
10
+ configKey: "unpluginStarter"
11
+ },
12
+ defaults: {},
13
+ setup(options, _nuxt) {
14
+ addVitePlugin(() => vite_default(options));
15
+ addWebpackPlugin(() => webpack_default(options));
16
+ }
17
+ });
18
+
19
+ //#endregion
20
+ export { nuxt_default as default };
@@ -0,0 +1,8 @@
1
+ import * as unplugin9 from "unplugin";
2
+ import * as oxc_transform_relay8 from "oxc-transform-relay";
3
+
4
+ //#region src/rolldown.d.ts
5
+ declare const _default: (options?: oxc_transform_relay8.TransformOptions | undefined) => unplugin9.RolldownPlugin<any> | unplugin9.RolldownPlugin<any>[];
6
+
7
+ //#endregion
8
+ export { _default as default };
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createRolldownPlugin } from "unplugin";
3
+
4
+ //#region src/rolldown.ts
5
+ var rolldown_default = createRolldownPlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { rolldown_default as default };
@@ -0,0 +1,8 @@
1
+ import * as oxc_transform_relay0 from "oxc-transform-relay";
2
+ import * as rollup1 from "rollup";
3
+
4
+ //#region src/rollup.d.ts
5
+ declare const _default: (options?: oxc_transform_relay0.TransformOptions | undefined) => rollup1.Plugin<any> | rollup1.Plugin<any>[];
6
+
7
+ //#endregion
8
+ export { _default as default };
package/dist/rollup.js ADDED
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createRollupPlugin } from "unplugin";
3
+
4
+ //#region src/rollup.ts
5
+ var rollup_default = createRollupPlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { rollup_default as default };
@@ -0,0 +1,7 @@
1
+ import * as oxc_transform_relay14 from "oxc-transform-relay";
2
+
3
+ //#region src/rspack.d.ts
4
+ declare const _default: (options?: oxc_transform_relay14.TransformOptions | undefined) => RspackPluginInstance;
5
+
6
+ //#endregion
7
+ export { _default as default };
package/dist/rspack.js ADDED
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createRspackPlugin } from "unplugin";
3
+
4
+ //#region src/rspack.ts
5
+ var rspack_default = createRspackPlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { rspack_default as default };
@@ -0,0 +1,27 @@
1
+ import { createUnplugin } from "unplugin";
2
+ import { transform } from "oxc-transform-relay";
3
+
4
+ //#region src/index.ts
5
+ const unpluginFactory = (options) => ({
6
+ name: "unplugin-relay",
7
+ transformInclude(id) {
8
+ return /.(t|j)sx?/.test(id);
9
+ },
10
+ async transform(code, id) {
11
+ const result = await transform(id.split("?")[0], code, {
12
+ sourcemap: true,
13
+ ...options
14
+ });
15
+ const diagnostics = result.errors.map((error) => `${error.message}${error.codeframe ? `\n${error.codeframe}` : ""}`);
16
+ for (const diagnostic of diagnostics) this.warn(diagnostic);
17
+ return {
18
+ code: result.code,
19
+ map: result.map
20
+ };
21
+ }
22
+ });
23
+ const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
24
+ var src_default = unplugin;
25
+
26
+ //#endregion
27
+ export { src_default, unplugin, unpluginFactory };
@@ -0,0 +1,2 @@
1
+ import { TransformOptions as Options } from "oxc-transform-relay";
2
+ export { Options };
@@ -0,0 +1,2 @@
1
+ import { Options } from "./types-C903-00Z.js";
2
+ export { Options };
package/dist/types.js ADDED
File without changes
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createVitePlugin } from "unplugin";
3
+
4
+ //#region src/vite.ts
5
+ var vite_default = createVitePlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { vite_default };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import * as oxc_transform_relay15 from "oxc-transform-relay";
2
+ import * as vite16 from "vite";
3
+
4
+ //#region src/vite.d.ts
5
+ declare const _default: (options?: oxc_transform_relay15.TransformOptions | undefined) => vite16.Plugin<any> | vite16.Plugin<any>[];
6
+
7
+ //#endregion
8
+ export { _default as default };
package/dist/vite.js ADDED
@@ -0,0 +1,4 @@
1
+ import "./src-BsgyTMzn.js";
2
+ import { vite_default } from "./vite-DT2H4_FH.js";
3
+
4
+ export { vite_default as default };
@@ -0,0 +1,8 @@
1
+ import { unpluginFactory } from "./src-BsgyTMzn.js";
2
+ import { createWebpackPlugin } from "unplugin";
3
+
4
+ //#region src/webpack.ts
5
+ var webpack_default = createWebpackPlugin(unpluginFactory);
6
+
7
+ //#endregion
8
+ export { webpack_default };
@@ -0,0 +1,8 @@
1
+ import * as oxc_transform_relay6 from "oxc-transform-relay";
2
+ import * as webpack7 from "webpack";
3
+
4
+ //#region src/webpack.d.ts
5
+ declare const _default: (options?: oxc_transform_relay6.TransformOptions | undefined) => webpack7.WebpackPluginInstance;
6
+
7
+ //#endregion
8
+ export { _default as default };
@@ -0,0 +1,4 @@
1
+ import "./src-BsgyTMzn.js";
2
+ import { webpack_default } from "./webpack-B0bSjJna.js";
3
+
4
+ export { webpack_default as default };
package/package.json ADDED
@@ -0,0 +1,111 @@
1
+ {
2
+ "name": "unplugin-relay",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "keywords": [
6
+ "rollup",
7
+ "transform",
8
+ "unplugin",
9
+ "vite",
10
+ "webpack"
11
+ ],
12
+ "homepage": "https://github.com/antfu/unplugin-relay#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/antfu/unplugin-relay/issues"
15
+ },
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/antfu/unplugin-relay.git"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "typesVersions": {
29
+ "*": {
30
+ "*": [
31
+ "./dist/*",
32
+ "./*"
33
+ ]
34
+ }
35
+ },
36
+ "exports": {
37
+ ".": "./dist/index.js",
38
+ "./astro": "./dist/astro.js",
39
+ "./esbuild": "./dist/esbuild.js",
40
+ "./farm": "./dist/farm.js",
41
+ "./nuxt": "./dist/nuxt.js",
42
+ "./rolldown": "./dist/rolldown.js",
43
+ "./rollup": "./dist/rollup.js",
44
+ "./rspack": "./dist/rspack.js",
45
+ "./types": "./dist/types.js",
46
+ "./vite": "./dist/vite.js",
47
+ "./webpack": "./dist/webpack.js",
48
+ "./package.json": "./package.json"
49
+ },
50
+ "dependencies": {
51
+ "oxc-transform-relay": "^0.145.0",
52
+ "unplugin": "^2.3.4"
53
+ },
54
+ "devDependencies": {
55
+ "@antfu/eslint-config": "^4.13.2",
56
+ "@nuxt/kit": "^3.17.4",
57
+ "@nuxt/schema": "^3.17.4",
58
+ "@types/node": "^22.15.21",
59
+ "bumpp": "^10.1.1",
60
+ "eslint": "^9.27.0",
61
+ "nodemon": "^3.1.10",
62
+ "rollup": "^4.41.0",
63
+ "tsdown": "^0.12.0",
64
+ "tsx": "^4.19.4",
65
+ "typescript": "^5.8.3",
66
+ "vite": "^6.3.5",
67
+ "vitest": "^3.1.4",
68
+ "webpack": "^5.99.9"
69
+ },
70
+ "peerDependencies": {
71
+ "@farmfe/core": ">=1",
72
+ "@nuxt/kit": "^3",
73
+ "@nuxt/schema": "^3",
74
+ "esbuild": "*",
75
+ "rollup": "^3",
76
+ "vite": ">=3",
77
+ "webpack": "^4 || ^5"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "@farmfe/core": {
81
+ "optional": true
82
+ },
83
+ "@nuxt/kit": {
84
+ "optional": true
85
+ },
86
+ "@nuxt/schema": {
87
+ "optional": true
88
+ },
89
+ "esbuild": {
90
+ "optional": true
91
+ },
92
+ "rollup": {
93
+ "optional": true
94
+ },
95
+ "vite": {
96
+ "optional": true
97
+ },
98
+ "webpack": {
99
+ "optional": true
100
+ }
101
+ },
102
+ "scripts": {
103
+ "build": "tsdown",
104
+ "dev": "tsdown -w",
105
+ "lint": "eslint .",
106
+ "play": "npm -C playground run dev",
107
+ "release": "bumpp && pnpm publish",
108
+ "start": "tsx src/index.ts",
109
+ "test": "vitest"
110
+ }
111
+ }