rspack-plugin-mock 1.3.0 → 2.0.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/README.md +7 -2
- package/README.zh-CN.md +7 -2
- package/dist/{helper.d.mts → helper.d.ts} +1 -1
- package/dist/helper.js +172 -0
- package/dist/{index.d.mts → index.d.ts} +3 -3
- package/dist/index.js +84 -0
- package/dist/json5-loader.mjs +8 -0
- package/dist/options-Bd0PSZeT.js +446 -0
- package/dist/{rsbuild.d.mts → rsbuild.d.ts} +1 -1
- package/dist/rsbuild.js +92 -0
- package/dist/{server-4ETytB7L.d.mts → server-_doRwsZm.d.ts} +15 -15
- package/dist/{server.d.mts → server.d.ts} +1 -2
- package/dist/server.js +2 -0
- package/dist/{types-Bt_OTa7I.d.mts → types-GT6M6WuI.d.ts} +3 -3
- package/dist/ws-BcLCWVaK.js +1003 -0
- package/package.json +33 -34
- package/dist/helper.mjs +0 -4
- package/dist/index.mjs +0 -1
- package/dist/json5-loader.cjs +0 -1
- package/dist/options-BUfaThYe.mjs +0 -43
- package/dist/rsbuild.mjs +0 -1
- package/dist/server.mjs +0 -1
- package/dist/ws-BM06pHhL.mjs +0 -1
package/README.md
CHANGED
|
@@ -10,18 +10,23 @@ Implement a mock-dev-server in `rspack` and `rsbuild` that is fully consistent w
|
|
|
10
10
|
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rspack/core?style=flat-square&colorA=564341&colorB=EDED91&label=rspack">
|
|
11
11
|
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91&label=rsbuild">
|
|
12
12
|
<img alt="npm" src="https://img.shields.io/npm/dm/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91">
|
|
13
|
-
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/pengzhanbo/rspack-plugin-mock/
|
|
13
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/pengzhanbo/rspack-plugin-mock/release.yaml?style=flat-square&colorA=564341&colorB=EDED91">
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<span>English</span> | <a href="./README.zh-CN.md">简体中文</a>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
|
+
> [!IMPORTANT]
|
|
21
|
+
> Starting from version 2.0 of the plugin, only `rspack@2.x` and `rsbuild@2.x` versions are supported.
|
|
22
|
+
>
|
|
23
|
+
> If you are using `rspack@1.x` or `rsbuild@1.x`, please use version `rspack-plugin-mock@1.x`.
|
|
24
|
+
|
|
20
25
|
## Features
|
|
21
26
|
|
|
22
27
|
- ⚡️ Lightweight, Flexible, Fast.
|
|
23
28
|
- 🧲 Not injection-based, non-intrusive to client code.
|
|
24
|
-
- 💡 ESModule
|
|
29
|
+
- 💡 Pure ESModule
|
|
25
30
|
- 🦾 Typescript.
|
|
26
31
|
- 🔥 HMR
|
|
27
32
|
- 🏷 Support `.[cm]?js`/ `.ts` /`.json` / `.json5`.
|
package/README.zh-CN.md
CHANGED
|
@@ -10,18 +10,23 @@
|
|
|
10
10
|
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rspack/core?style=flat-square&colorA=564341&colorB=EDED91&label=rspack">
|
|
11
11
|
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91&label=rsbuild">
|
|
12
12
|
<img alt="npm" src="https://img.shields.io/npm/dm/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91">
|
|
13
|
-
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/pengzhanbo/rspack-plugin-mock/
|
|
13
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/pengzhanbo/rspack-plugin-mock/release.yaml?style=flat-square&colorA=564341&colorB=EDED91">
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<a href="./README.md">English</a> | <span>简体中文</span>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
|
+
> [!IMPORTANT]
|
|
21
|
+
> 从插件 2.0 版本开始,仅支持 `rspack@2.x` 版本 和 `rsbuild@2.x` 版本.
|
|
22
|
+
>
|
|
23
|
+
> 如果您使用的是 `rspack@1.x` 或 `rsbuild@1.x` 版本,请使用 `rspack-plugin-mock@1.x` 版本.
|
|
24
|
+
|
|
20
25
|
## 特性
|
|
21
26
|
|
|
22
27
|
- ⚡️ 轻量,灵活,快速
|
|
23
28
|
- 🧲 非注入式,对客户端代码无侵入
|
|
24
|
-
- 💡 ESModule
|
|
29
|
+
- 💡 纯 ESModule
|
|
25
30
|
- 🦾 Typescript
|
|
26
31
|
- 🔥 热更新
|
|
27
32
|
- 🏷 支持 `.[cm]?js`/ `.ts` / `json` / `json5` 编写 mock 数据
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as WebSocketSetupContext, a as LogType, c as MockMatchPriority, d as MockRequest, f as MockResponse, g as ServerBuildOption, h as ResponseBody, i as LogLevel, l as MockMatchSpecialPriority, m as MockWebsocketItem, n as ExtraRequest, o as Method, p as MockServerPluginOptions, r as FormidableFile, s as MockHttpItem, t as BodyParserOptions, u as MockOptions } from "./types-
|
|
1
|
+
import { _ as WebSocketSetupContext, a as LogType, c as MockMatchPriority, d as MockRequest, f as MockResponse, g as ServerBuildOption, h as ResponseBody, i as LogLevel, l as MockMatchSpecialPriority, m as MockWebsocketItem, n as ExtraRequest, o as Method, p as MockServerPluginOptions, r as FormidableFile, s as MockHttpItem, t as BodyParserOptions, u as MockOptions } from "./types-GT6M6WuI.js";
|
|
2
2
|
import { Transform } from "node:stream";
|
|
3
3
|
import { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from "node:http";
|
|
4
4
|
|
package/dist/helper.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Transform } from "node:stream";
|
|
2
|
+
import { deepClone, deepEqual, isArray, isFunction } from "@pengzhanbo/utils";
|
|
3
|
+
//#region src/helper/createSSEStream.ts
|
|
4
|
+
/**
|
|
5
|
+
* Transforms "messages" to W3C event stream content.
|
|
6
|
+
* See https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
7
|
+
* A message is an object with one or more of the following properties:
|
|
8
|
+
* - data (String or object, which gets turned into JSON)
|
|
9
|
+
* - event
|
|
10
|
+
* - id
|
|
11
|
+
* - retry
|
|
12
|
+
* - comment
|
|
13
|
+
*
|
|
14
|
+
* If constructed with a HTTP Request, it will optimise the socket for streaming.
|
|
15
|
+
* If this stream is piped to an HTTP Response, it will set appropriate headers.
|
|
16
|
+
*/
|
|
17
|
+
var SSEStream = class extends Transform {
|
|
18
|
+
constructor(req) {
|
|
19
|
+
super({ objectMode: true });
|
|
20
|
+
req.socket.setKeepAlive(true);
|
|
21
|
+
req.socket.setNoDelay(true);
|
|
22
|
+
req.socket.setTimeout(0);
|
|
23
|
+
}
|
|
24
|
+
pipe(destination, options) {
|
|
25
|
+
if (destination.writeHead) {
|
|
26
|
+
destination.writeHead(200, {
|
|
27
|
+
"Content-Type": "text/event-stream; charset=utf-8",
|
|
28
|
+
"Transfer-Encoding": "identity",
|
|
29
|
+
"Cache-Control": "no-cache",
|
|
30
|
+
"Connection": "keep-alive"
|
|
31
|
+
});
|
|
32
|
+
destination.flushHeaders?.();
|
|
33
|
+
}
|
|
34
|
+
destination.write(":ok\n\n");
|
|
35
|
+
return super.pipe(destination, options);
|
|
36
|
+
}
|
|
37
|
+
_transform(message, encoding, callback) {
|
|
38
|
+
if (message.comment) this.push(`: ${message.comment}\n`);
|
|
39
|
+
if (message.event) this.push(`event: ${message.event}\n`);
|
|
40
|
+
if (message.id) this.push(`id: ${message.id}\n`);
|
|
41
|
+
if (message.retry) this.push(`retry: ${message.retry}\n`);
|
|
42
|
+
if (message.data) this.push(dataString(message.data));
|
|
43
|
+
this.push("\n");
|
|
44
|
+
callback();
|
|
45
|
+
}
|
|
46
|
+
write(message, ...args) {
|
|
47
|
+
return super.write(message, ...args);
|
|
48
|
+
}
|
|
49
|
+
destroy(error) {
|
|
50
|
+
if (error) this.write({
|
|
51
|
+
event: "error",
|
|
52
|
+
data: error.message
|
|
53
|
+
});
|
|
54
|
+
this.end();
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function dataString(data) {
|
|
59
|
+
if (typeof data === "object") return dataString(JSON.stringify(data));
|
|
60
|
+
return data.split(/\r\n|\r|\n/).map((line) => `data: ${line}\n`).join("");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 创建一个 Server-sent events 写入流,用于支持模拟 EventSource
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { createSSEStream, defineMock } from 'vite-plugin-mock-dev-server'
|
|
68
|
+
*
|
|
69
|
+
* export default defineMock({
|
|
70
|
+
* url: '/api',
|
|
71
|
+
* response: (req, res) => {
|
|
72
|
+
* const sse = createSSEStream(req, res)
|
|
73
|
+
* sse.write({ event: 'message', data: { message: 'hello world' } })
|
|
74
|
+
* }
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
function createSSEStream(req, res) {
|
|
79
|
+
const sse = new SSEStream(req);
|
|
80
|
+
sse.pipe(res);
|
|
81
|
+
return sse;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/helper/defineMock.ts
|
|
85
|
+
function defineMock(config) {
|
|
86
|
+
return config;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Return a custom defineMock function to support preprocessing of mock config.
|
|
90
|
+
*
|
|
91
|
+
* 返回一个自定义的 defineMock 函数,用于支持对 mock config 的预处理。
|
|
92
|
+
* @param transformer preprocessing function
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const definePostMock = createDefineMock((mock) => {
|
|
96
|
+
* mock.url = '/api/post/' + mock.url
|
|
97
|
+
* })
|
|
98
|
+
* export default definePostMock({
|
|
99
|
+
* url: 'list',
|
|
100
|
+
* body: [{ title: '1' }, { title: '2' }],
|
|
101
|
+
* })
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
function createDefineMock(transformer) {
|
|
105
|
+
const define = (config) => {
|
|
106
|
+
if (isArray(config)) config = config.map((item) => transformer(item) || item);
|
|
107
|
+
else config = transformer(config) || config;
|
|
108
|
+
return config;
|
|
109
|
+
};
|
|
110
|
+
return define;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/helper/defineMockData.ts
|
|
114
|
+
/**
|
|
115
|
+
* 由于插件是 分别独立对 `*.mock.*` 等文件作为单独入口进行编译的,
|
|
116
|
+
* 这导致了 mock 文件编译后的依赖关系不一致,每个 mock 文件拥有独立的作用域,
|
|
117
|
+
* 使得即使多个 `*.mock.*` 虽然引入了同一个 `data.ts` 文件,然而确是完全不同两份 `data`,
|
|
118
|
+
* 使得对 `data` 的操作,在不同的 `*.mock.*` 文件中并不能共享。
|
|
119
|
+
*
|
|
120
|
+
* 为此,插件提供了一种基于 memory 的数据共享机制。
|
|
121
|
+
*/
|
|
122
|
+
const mockDataCache = /* @__PURE__ */ new Map();
|
|
123
|
+
const responseCache = /* @__PURE__ */ new WeakMap();
|
|
124
|
+
const staleInterval = 70;
|
|
125
|
+
var CacheImpl = class {
|
|
126
|
+
value;
|
|
127
|
+
#initialValue;
|
|
128
|
+
#lastUpdate;
|
|
129
|
+
constructor(value) {
|
|
130
|
+
this.value = value;
|
|
131
|
+
this.#initialValue = deepClone(value);
|
|
132
|
+
this.#lastUpdate = Date.now();
|
|
133
|
+
}
|
|
134
|
+
hotUpdate(value) {
|
|
135
|
+
if (Date.now() - this.#lastUpdate < staleInterval) return;
|
|
136
|
+
if (!deepEqual(value, this.#initialValue)) {
|
|
137
|
+
this.value = value;
|
|
138
|
+
this.#initialValue = deepClone(value);
|
|
139
|
+
this.#lastUpdate = Date.now();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
function defineMockData(key, initialData) {
|
|
144
|
+
let cache = mockDataCache.get(key);
|
|
145
|
+
if (!cache) {
|
|
146
|
+
const newCache = new CacheImpl(initialData);
|
|
147
|
+
const existing = mockDataCache.get(key);
|
|
148
|
+
if (existing) cache = existing;
|
|
149
|
+
else {
|
|
150
|
+
mockDataCache.set(key, newCache);
|
|
151
|
+
cache = newCache;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
cache.hotUpdate(initialData);
|
|
155
|
+
if (responseCache.has(cache)) return responseCache.get(cache);
|
|
156
|
+
const res = [() => cache.value, (val) => {
|
|
157
|
+
if (isFunction(val)) val = val(cache.value) ?? cache.value;
|
|
158
|
+
cache.value = val;
|
|
159
|
+
}];
|
|
160
|
+
Object.defineProperty(res, "value", {
|
|
161
|
+
get() {
|
|
162
|
+
return cache.value;
|
|
163
|
+
},
|
|
164
|
+
set(val) {
|
|
165
|
+
cache.value = val;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
responseCache.set(cache, res);
|
|
169
|
+
return res;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { createDefineMock, createSSEStream, defineMock, defineMockData };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as WebSocketSetupContext, a as LogType, c as MockMatchPriority, d as MockRequest, f as MockResponse, g as ServerBuildOption, h as ResponseBody, i as LogLevel, l as MockMatchSpecialPriority, m as MockWebsocketItem, n as ExtraRequest, o as Method, p as MockServerPluginOptions, r as FormidableFile, s as MockHttpItem, t as BodyParserOptions, u as MockOptions } from "./types-
|
|
2
|
-
import { HeaderStream, MockData, SSEMessage, createDefineMock, createSSEStream, defineMock, defineMockData } from "./helper.
|
|
3
|
-
import { a as processMockData, c as Logger, i as baseMiddleware, l as createLogger, n as mockWebSocket, o as processRawData, r as BaseMiddlewareOptions, s as sortByValidator, t as MockSocketOptions, u as logLevels } from "./server-
|
|
1
|
+
import { _ as WebSocketSetupContext, a as LogType, c as MockMatchPriority, d as MockRequest, f as MockResponse, g as ServerBuildOption, h as ResponseBody, i as LogLevel, l as MockMatchSpecialPriority, m as MockWebsocketItem, n as ExtraRequest, o as Method, p as MockServerPluginOptions, r as FormidableFile, s as MockHttpItem, t as BodyParserOptions, u as MockOptions } from "./types-GT6M6WuI.js";
|
|
2
|
+
import { HeaderStream, MockData, SSEMessage, createDefineMock, createSSEStream, defineMock, defineMockData } from "./helper.js";
|
|
3
|
+
import { a as processMockData, c as Logger, i as baseMiddleware, l as createLogger, n as mockWebSocket, o as processRawData, r as BaseMiddlewareOptions, s as sortByValidator, t as MockSocketOptions, u as logLevels } from "./server-_doRwsZm.js";
|
|
4
4
|
import { Compiler, RspackPluginInstance } from "@rspack/core";
|
|
5
5
|
|
|
6
6
|
//#region src/rspack.d.ts
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createDefineMock, createSSEStream, defineMock, defineMockData } from "./helper.js";
|
|
2
|
+
import { a as processRawData, d as logLevels, i as processMockData, n as baseMiddleware, o as sortByValidator, r as rewriteRequest, s as waitingFor, t as mockWebSocket, u as createLogger } from "./ws-BcLCWVaK.js";
|
|
3
|
+
import { n as buildMockServer, r as createMockCompiler, t as resolvePluginOptions$1 } from "./options-Bd0PSZeT.js";
|
|
4
|
+
import "./server.js";
|
|
5
|
+
import { isFunction, isString, toArray, toTruthy } from "@pengzhanbo/utils";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import rspack from "@rspack/core";
|
|
9
|
+
//#region src/rspack.ts
|
|
10
|
+
const PLUGIN_NAME = "rspack-plugin-mock";
|
|
11
|
+
var MockServerPlugin = class {
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
apply(compiler) {
|
|
16
|
+
const compilerOptions = compiler.options;
|
|
17
|
+
const options = resolvePluginOptions(compiler, this.options);
|
|
18
|
+
if (process.env.NODE_ENV !== "production") {
|
|
19
|
+
if (compilerOptions.devServer === false) {
|
|
20
|
+
options.logger.warn(`${PLUGIN_NAME} is disabled, because devServer is disabled`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const mockCompiler = createMockCompiler(options);
|
|
24
|
+
const setupMiddlewares = compilerOptions.devServer?.setupMiddlewares;
|
|
25
|
+
const waitServerForMockWebSocket = waitingFor((server) => {
|
|
26
|
+
mockWebSocket(mockCompiler, server, options);
|
|
27
|
+
});
|
|
28
|
+
compilerOptions.devServer = {
|
|
29
|
+
...compilerOptions.devServer,
|
|
30
|
+
setupMiddlewares: (middlewares, devServer) => {
|
|
31
|
+
middlewares = setupMiddlewares?.(middlewares, devServer) || middlewares;
|
|
32
|
+
middlewares.unshift(baseMiddleware(mockCompiler, options));
|
|
33
|
+
if (options.reload) mockCompiler.on("update", () => {
|
|
34
|
+
if (devServer.webSocketServer?.clients) devServer.sendMessage(devServer.webSocketServer.clients, "static-changed");
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* 在 @rspack/dev-server 中, setupMiddlewares 优先于 createServer
|
|
38
|
+
* 执行,需要等待 server 启动后再注入 mock websocket
|
|
39
|
+
*/
|
|
40
|
+
waitServerForMockWebSocket(() => devServer.server);
|
|
41
|
+
return middlewares;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const wsPrefix = toArray(options.wsPrefix);
|
|
45
|
+
if (compilerOptions.devServer?.proxy?.length) {
|
|
46
|
+
const proxy = compilerOptions.devServer.proxy;
|
|
47
|
+
compilerOptions.devServer.proxy = proxy.filter((item) => {
|
|
48
|
+
if (!isFunction(item) && item.ws === true && wsPrefix.length) return !toArray(item.pathFilter || item.context).filter(isString).some((context) => wsPrefix.includes(context));
|
|
49
|
+
return true;
|
|
50
|
+
}).map((item) => {
|
|
51
|
+
if (!isFunction(item) && !item.ws) {
|
|
52
|
+
const on = item.on ??= {};
|
|
53
|
+
const onProxyReq = on.proxyReq;
|
|
54
|
+
on.proxyReq = (proxyReq, req, ...args) => {
|
|
55
|
+
onProxyReq?.(proxyReq, req, ...args);
|
|
56
|
+
rewriteRequest(proxyReq, req);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return item;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
compiler.hooks.watchRun.tap(PLUGIN_NAME, () => mockCompiler.run());
|
|
63
|
+
compiler.hooks.watchClose.tap(PLUGIN_NAME, () => mockCompiler.close());
|
|
64
|
+
} else if (options.build !== false) compiler.hooks.afterEmit.tap(PLUGIN_NAME, () => buildMockServer(options, compilerOptions.output.path || path.resolve(process.cwd(), "dist")));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function resolvePluginOptions(compiler, options = {}) {
|
|
68
|
+
const compilerOptions = compiler.options;
|
|
69
|
+
const alias = compilerOptions.resolve?.alias || {};
|
|
70
|
+
const context = compilerOptions.context;
|
|
71
|
+
const definePluginInstance = compilerOptions.plugins?.find((plugin) => plugin instanceof rspack.DefinePlugin);
|
|
72
|
+
const proxies = ((compilerOptions.devServer || {}).proxy || []).flatMap((item) => {
|
|
73
|
+
if (!isFunction(item) && !item.ws) return item.pathFilter || item.context;
|
|
74
|
+
return [];
|
|
75
|
+
}).filter(toTruthy);
|
|
76
|
+
return resolvePluginOptions$1(options, {
|
|
77
|
+
alias,
|
|
78
|
+
context,
|
|
79
|
+
plugins: toArray(definePluginInstance),
|
|
80
|
+
proxies
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { MockServerPlugin, baseMiddleware, createDefineMock, createLogger, createSSEStream, defineMock, defineMockData, logLevels, mockWebSocket, processMockData, processRawData, sortByValidator };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import JSON5 from "json5";
|
|
2
|
+
//#region src/json5-loader.ts
|
|
3
|
+
function json5_loader_default(content) {
|
|
4
|
+
if (!content) return "export default {}";
|
|
5
|
+
return `export default ${JSON.stringify(JSON5.parse(content))}`;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { json5_loader_default as default };
|