vite-plugin-sinwan 0.2.6 → 0.2.8
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/CHANGELOG.md +26 -0
- package/README.md +12 -7
- package/__tests__/plugin.test.ts +372 -3
- package/bun.lock +89 -84
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -1
- package/package.json +7 -8
- package/src/index.ts +22 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to **vite-plugin-sinwan** are documented in this file. The format follows [Keep a Changelog](https://keepachangelog.com) and vite-plugin-sinwan adheres to [Semantic Versioning](https://semver.org).
|
|
4
|
+
|
|
5
|
+
## [0.2.8] — @sinwan-pure Resolver Forwarding
|
|
6
|
+
|
|
7
|
+
vite-plugin-sinwan 0.2.8 forwards the analyzer cache `resolve` callback to the compiler as `resolveImport`, enabling `@sinwan-pure` JSDoc annotation scanning across all import types (relative, bare specifiers, scoped packages, subpaths). Pair with **sinwan-compiler 0.4.0**.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`resolveImport` forwarding (`src/index.ts`)**: When the analyzer cache is enabled (`cache: true`, the default), the plugin forwards `cache.resolve` to the compiler as the `resolveImport` option. This allows the compiler to resolve imports using the plugin's module resolver, which handles workspace packages, tsconfig paths, and Vite module resolution. The compiler uses this resolver to find `@sinwan-pure`-annotated source files for purity scanning.
|
|
12
|
+
|
|
13
|
+
### Internal
|
|
14
|
+
|
|
15
|
+
- Documentation updated in `README.md` — references the `@sinwan-pure` JSDoc contract in `sinwan-compiler/docs/transform.md`.
|
|
16
|
+
- `bun run build` clean.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## [0.2.7] — Derived Locals
|
|
21
|
+
|
|
22
|
+
vite-plugin-sinwan 0.2.7 forwards the `derivedLocals` option to the compiler. Pair with **sinwan-compiler 0.3.2**.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **`derivedLocals` option**: When `true`, the compiler promotes eligible derived `const` initializers to zero-arity getters.
|
package/README.md
CHANGED
|
@@ -34,6 +34,8 @@ export default defineConfig({
|
|
|
34
34
|
sinwan({
|
|
35
35
|
// Enable template hoisting (default: true)
|
|
36
36
|
hoist: true,
|
|
37
|
+
// Warn when hoisting is skipped (default: Vite mode !== "production")
|
|
38
|
+
dev: true,
|
|
37
39
|
// Emit explicit binding descriptors (default: false)
|
|
38
40
|
explicitBindings: false,
|
|
39
41
|
// Path to reactive-props metadata from `sinwan analyze`
|
|
@@ -50,13 +52,16 @@ sinwan({
|
|
|
50
52
|
});
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
| Option | Type | Default
|
|
54
|
-
| ------------------ | ------------------------------- |
|
|
55
|
-
| `hoist` | `boolean` | `true`
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
55
|
+
| Option | Type | Default | Description |
|
|
56
|
+
| ------------------ | ------------------------------- | ---------------------------- | ----------------------------------------------------- |
|
|
57
|
+
| `hoist` | `boolean` | `true` | Hoist static DOM to module-level templates |
|
|
58
|
+
| `dev` | `boolean` | Vite `mode !== "production"` | Warn when template hoisting is skipped |
|
|
59
|
+
| `explicitBindings` | `boolean` | `false` | Emit compiler-driven binding descriptors |
|
|
60
|
+
| `analyze` | `string` | `undefined` | Path to reactive-props metadata from `sinwan analyze` |
|
|
61
|
+
| `cache` | `boolean \| SinwanCacheOptions` | `false` | Enable incremental in-memory cross-file analysis |
|
|
62
|
+
| `fastRefresh` | `boolean` | `true` | Inject per-component HMR boundaries (dev server only) |
|
|
63
|
+
|
|
64
|
+
Enable `sinwan({ derivedLocals: true })` to promote eligible reactive `const` derivations inside component setup. This defaults to `false`; use compiler and runtime builds containing derived-local promotion and getter-attribute hydration support. `/* sinwan-snapshot */` preserves an intentional one-shot read. In development, the compiler diagnoses eligible JSX snapshots and setup `if` reads. Imported functions annotated with `/** @sinwan-pure */` JSDoc are also promoted; see the [`@sinwan-pure` JSDoc contract](../sinwan-compiler/docs/transform.md#sinwan-pure-jsdoc-contract) in the compiler docs.
|
|
60
65
|
|
|
61
66
|
## How it works
|
|
62
67
|
|
package/__tests__/plugin.test.ts
CHANGED
|
@@ -4,6 +4,37 @@ import * as path from "path";
|
|
|
4
4
|
import { sinwan } from "../src/index";
|
|
5
5
|
|
|
6
6
|
describe("sinwan vite plugin", () => {
|
|
7
|
+
it("forwards opt-in derived locals to the linked compiler in dev and production", () => {
|
|
8
|
+
const input = `export function App() {
|
|
9
|
+
const open = state.value > 0;
|
|
10
|
+
return <div title={open}>{open}</div>;
|
|
11
|
+
}`;
|
|
12
|
+
for (const derivedLocals of [false, true]) {
|
|
13
|
+
for (const command of ["serve", "build"]) {
|
|
14
|
+
const plugin = sinwan({
|
|
15
|
+
cache: false,
|
|
16
|
+
dev: false,
|
|
17
|
+
hoist: false,
|
|
18
|
+
derivedLocals,
|
|
19
|
+
});
|
|
20
|
+
plugin.configResolved({
|
|
21
|
+
command,
|
|
22
|
+
mode: command === "build" ? "production" : "development",
|
|
23
|
+
});
|
|
24
|
+
const result = plugin.transform(input, "App.tsx");
|
|
25
|
+
expect(
|
|
26
|
+
result?.code.includes("const open = () => state.value > 0;"),
|
|
27
|
+
).toBe(derivedLocals);
|
|
28
|
+
expect(result?.code.includes("title={() => open()}")).toBe(
|
|
29
|
+
derivedLocals,
|
|
30
|
+
);
|
|
31
|
+
expect(result?.code.includes("import.meta.hot")).toBe(
|
|
32
|
+
command === "serve",
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
7
38
|
it("can be created with cache enabled", () => {
|
|
8
39
|
const plugin = sinwan({ cache: true });
|
|
9
40
|
expect(plugin.name).toBe("sinwan");
|
|
@@ -33,7 +64,347 @@ describe("sinwan vite plugin", () => {
|
|
|
33
64
|
});
|
|
34
65
|
});
|
|
35
66
|
|
|
36
|
-
const
|
|
67
|
+
const SPREAD_JSX =
|
|
68
|
+
"const Card = (props) => <div {...props}><p>Hello</p></div>;";
|
|
69
|
+
|
|
70
|
+
function collectWarns(run: () => void): string[] {
|
|
71
|
+
const warns: string[] = [];
|
|
72
|
+
const originalWarn = console.warn;
|
|
73
|
+
console.warn = (...args: unknown[]) => {
|
|
74
|
+
warns.push(String(args[0]));
|
|
75
|
+
};
|
|
76
|
+
try {
|
|
77
|
+
run();
|
|
78
|
+
return warns;
|
|
79
|
+
} finally {
|
|
80
|
+
console.warn = originalWarn;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
describe("compiler dev warnings", () => {
|
|
85
|
+
it("does not warn about skipped hoists when dev is false", () => {
|
|
86
|
+
const plugin = sinwan({ cache: false, dev: false });
|
|
87
|
+
const warns = collectWarns(() => {
|
|
88
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
89
|
+
});
|
|
90
|
+
expect(
|
|
91
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
92
|
+
).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("warns about skipped hoists when dev is true", () => {
|
|
96
|
+
const plugin = sinwan({ cache: false, dev: true });
|
|
97
|
+
const warns = collectWarns(() => {
|
|
98
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
99
|
+
});
|
|
100
|
+
expect(
|
|
101
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
102
|
+
).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("uses Vite production mode after configResolved unless dev is set", () => {
|
|
106
|
+
const plugin = sinwan({ cache: false });
|
|
107
|
+
plugin.configResolved({
|
|
108
|
+
command: "build",
|
|
109
|
+
mode: "production",
|
|
110
|
+
root: "/app",
|
|
111
|
+
});
|
|
112
|
+
const warns = collectWarns(() => {
|
|
113
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
114
|
+
});
|
|
115
|
+
expect(
|
|
116
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
117
|
+
).toBe(false);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("uses Vite development mode after configResolved unless dev is set", () => {
|
|
121
|
+
const plugin = sinwan({ cache: false });
|
|
122
|
+
plugin.configResolved({
|
|
123
|
+
command: "serve",
|
|
124
|
+
mode: "development",
|
|
125
|
+
root: "/app",
|
|
126
|
+
});
|
|
127
|
+
const warns = collectWarns(() => {
|
|
128
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
129
|
+
});
|
|
130
|
+
expect(
|
|
131
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
132
|
+
).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("keeps an explicit dev option after configResolved production mode", () => {
|
|
136
|
+
const plugin = sinwan({ cache: false, dev: true });
|
|
137
|
+
plugin.configResolved({
|
|
138
|
+
command: "build",
|
|
139
|
+
mode: "production",
|
|
140
|
+
root: "/app",
|
|
141
|
+
});
|
|
142
|
+
const warns = collectWarns(() => {
|
|
143
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
144
|
+
});
|
|
145
|
+
expect(
|
|
146
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
147
|
+
).toBe(true);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("defaults to quiet when NODE_ENV is production before configResolved", () => {
|
|
151
|
+
const previous = process.env.NODE_ENV;
|
|
152
|
+
process.env.NODE_ENV = "production";
|
|
153
|
+
try {
|
|
154
|
+
const plugin = sinwan({ cache: false });
|
|
155
|
+
const warns = collectWarns(() => {
|
|
156
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
157
|
+
});
|
|
158
|
+
expect(
|
|
159
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
160
|
+
).toBe(false);
|
|
161
|
+
} finally {
|
|
162
|
+
if (previous === undefined) {
|
|
163
|
+
delete process.env.NODE_ENV;
|
|
164
|
+
} else {
|
|
165
|
+
process.env.NODE_ENV = previous;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("does not override captured env when config.mode is not a string", () => {
|
|
171
|
+
const previous = process.env.NODE_ENV;
|
|
172
|
+
process.env.NODE_ENV = "production";
|
|
173
|
+
try {
|
|
174
|
+
const plugin = sinwan({ cache: false });
|
|
175
|
+
plugin.configResolved({ command: "serve", root: "/app" });
|
|
176
|
+
const warns = collectWarns(() => {
|
|
177
|
+
plugin.transform(SPREAD_JSX, "Card.tsx");
|
|
178
|
+
});
|
|
179
|
+
expect(
|
|
180
|
+
warns.some((line) => line.includes("template hoisting skipped")),
|
|
181
|
+
).toBe(false);
|
|
182
|
+
} finally {
|
|
183
|
+
if (previous === undefined) {
|
|
184
|
+
delete process.env.NODE_ENV;
|
|
185
|
+
} else {
|
|
186
|
+
process.env.NODE_ENV = previous;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe("vite transform, cache, and Fast Refresh", () => {
|
|
193
|
+
it("returns null for non-jsx files", () => {
|
|
194
|
+
const plugin = sinwan({ cache: false, fastRefresh: false });
|
|
195
|
+
expect(plugin.transform("const x = 1;", "file.ts")).toBeNull();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("transforms jsx and updates cache when bunfig exists", () => {
|
|
199
|
+
const tmpDir = fs.mkdtempSync(path.join(import.meta.dir, ".tmp-"));
|
|
200
|
+
const bunfig = path.join(tmpDir, "bunfig.toml");
|
|
201
|
+
fs.writeFileSync(bunfig, "[install]\n");
|
|
202
|
+
try {
|
|
203
|
+
const plugin = sinwan({
|
|
204
|
+
cache: {
|
|
205
|
+
root: tmpDir,
|
|
206
|
+
tsConfigPath: path.join(tmpDir, "tsconfig.json"),
|
|
207
|
+
cachePath: path.join(tmpDir, "cache.json"),
|
|
208
|
+
bunfigPath: bunfig,
|
|
209
|
+
workspaces: tmpDir,
|
|
210
|
+
},
|
|
211
|
+
fastRefresh: false,
|
|
212
|
+
dev: false,
|
|
213
|
+
});
|
|
214
|
+
plugin.configResolved({
|
|
215
|
+
command: "build",
|
|
216
|
+
mode: "production",
|
|
217
|
+
root: tmpDir,
|
|
218
|
+
});
|
|
219
|
+
const result = plugin.transform(
|
|
220
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
221
|
+
path.join(tmpDir, "Hello.tsx"),
|
|
222
|
+
);
|
|
223
|
+
expect(result?.code).toContain("_$createTemplate");
|
|
224
|
+
} finally {
|
|
225
|
+
fs.rmSync(tmpDir, { recursive: true });
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("uses projectRoot when cache is a boolean", () => {
|
|
230
|
+
const plugin = sinwan({ cache: true, fastRefresh: false, dev: false });
|
|
231
|
+
plugin.configResolved({
|
|
232
|
+
command: "build",
|
|
233
|
+
mode: "production",
|
|
234
|
+
root: process.cwd(),
|
|
235
|
+
});
|
|
236
|
+
const result = plugin.transform(
|
|
237
|
+
"const App = () => <div>ok</div>;",
|
|
238
|
+
"App.tsx",
|
|
239
|
+
);
|
|
240
|
+
expect(result?.code).toBeDefined();
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it("falls back to cwd when cache is a boolean and root is omitted", () => {
|
|
244
|
+
const plugin = sinwan({ cache: true, fastRefresh: false, dev: false });
|
|
245
|
+
plugin.configResolved({ command: "build", mode: "production" });
|
|
246
|
+
const result = plugin.transform(
|
|
247
|
+
"const App = () => <div>ok</div>;",
|
|
248
|
+
"App.tsx",
|
|
249
|
+
);
|
|
250
|
+
expect(result?.code).toBeDefined();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("uses cache object defaults without root or bunfigPath", () => {
|
|
254
|
+
const plugin = sinwan({
|
|
255
|
+
cache: {},
|
|
256
|
+
fastRefresh: false,
|
|
257
|
+
dev: false,
|
|
258
|
+
});
|
|
259
|
+
plugin.configResolved({
|
|
260
|
+
command: "build",
|
|
261
|
+
mode: "production",
|
|
262
|
+
root: "/app",
|
|
263
|
+
});
|
|
264
|
+
const result = plugin.transform(
|
|
265
|
+
"const App = () => <div>ok</div>;",
|
|
266
|
+
"App.jsx",
|
|
267
|
+
);
|
|
268
|
+
expect(result?.code).toBeDefined();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("uses cwd when a cache object has no root and config has no root", () => {
|
|
272
|
+
const plugin = sinwan({
|
|
273
|
+
cache: {},
|
|
274
|
+
fastRefresh: false,
|
|
275
|
+
dev: false,
|
|
276
|
+
});
|
|
277
|
+
plugin.configResolved({ command: "build", mode: "production" });
|
|
278
|
+
const result = plugin.transform(
|
|
279
|
+
"const App = () => <div>ok</div>;",
|
|
280
|
+
"App.tsx",
|
|
281
|
+
);
|
|
282
|
+
expect(result?.code).toBeDefined();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("injects Fast Refresh in serve for an exported component", () => {
|
|
286
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
287
|
+
plugin.configResolved({
|
|
288
|
+
command: "serve",
|
|
289
|
+
mode: "development",
|
|
290
|
+
root: "/app",
|
|
291
|
+
});
|
|
292
|
+
const result = plugin.transform(
|
|
293
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
294
|
+
"/app/src/Hello.tsx",
|
|
295
|
+
);
|
|
296
|
+
expect(result?.code).toContain("$$sinwanReplace");
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it("injects Fast Refresh using original source when the id has a query", () => {
|
|
300
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
301
|
+
plugin.configResolved({
|
|
302
|
+
command: "serve",
|
|
303
|
+
mode: "development",
|
|
304
|
+
root: "/app",
|
|
305
|
+
});
|
|
306
|
+
const result = plugin.transform(
|
|
307
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
308
|
+
"/app/src/Hello.tsx?t=1",
|
|
309
|
+
);
|
|
310
|
+
expect(result?.code).toContain("$$sinwanReplace");
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it("skips Fast Refresh for node_modules", () => {
|
|
314
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
315
|
+
plugin.configResolved({
|
|
316
|
+
command: "serve",
|
|
317
|
+
mode: "development",
|
|
318
|
+
root: "/app",
|
|
319
|
+
});
|
|
320
|
+
const result = plugin.transform(
|
|
321
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
322
|
+
"/app/node_modules/lib/Hello.tsx",
|
|
323
|
+
);
|
|
324
|
+
expect(result?.code ?? "").not.toContain("$$sinwanReplace");
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("skips Fast Refresh for virtual modules", () => {
|
|
328
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
329
|
+
plugin.configResolved({
|
|
330
|
+
command: "serve",
|
|
331
|
+
mode: "development",
|
|
332
|
+
root: "/app",
|
|
333
|
+
});
|
|
334
|
+
const result = plugin.transform(
|
|
335
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
336
|
+
"\0virtual/Hello.tsx",
|
|
337
|
+
);
|
|
338
|
+
expect(result?.code ?? "").not.toContain("$$sinwanReplace");
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("skips Fast Refresh when the module exports no component", () => {
|
|
342
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
343
|
+
plugin.configResolved({
|
|
344
|
+
command: "serve",
|
|
345
|
+
mode: "development",
|
|
346
|
+
root: "/app",
|
|
347
|
+
});
|
|
348
|
+
const result = plugin.transform("const x = 1;", "/app/src/util.tsx");
|
|
349
|
+
expect(result?.code ?? "").not.toContain("$$sinwanReplace");
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it("does not inject Fast Refresh during build", () => {
|
|
353
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
354
|
+
plugin.configResolved({
|
|
355
|
+
command: "build",
|
|
356
|
+
mode: "production",
|
|
357
|
+
root: "/app",
|
|
358
|
+
});
|
|
359
|
+
const result = plugin.transform(
|
|
360
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
361
|
+
"/app/src/Hello.tsx",
|
|
362
|
+
);
|
|
363
|
+
expect(result?.code ?? "").not.toContain("$$sinwanReplace");
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it("does not inject Fast Refresh when disabled", () => {
|
|
367
|
+
const plugin = sinwan({ cache: false, fastRefresh: false, dev: false });
|
|
368
|
+
plugin.configResolved({
|
|
369
|
+
command: "serve",
|
|
370
|
+
mode: "development",
|
|
371
|
+
root: "/app",
|
|
372
|
+
});
|
|
373
|
+
const result = plugin.transform(
|
|
374
|
+
"export function Hello() { return <div>hi</div>; }",
|
|
375
|
+
"/app/src/Hello.tsx",
|
|
376
|
+
);
|
|
377
|
+
expect(result?.code ?? "").not.toContain("$$sinwanReplace");
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("does not double-inject Fast Refresh", () => {
|
|
381
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
382
|
+
plugin.configResolved({
|
|
383
|
+
command: "serve",
|
|
384
|
+
mode: "development",
|
|
385
|
+
root: "/app",
|
|
386
|
+
});
|
|
387
|
+
const alreadyWired =
|
|
388
|
+
"export function Hello() { return <div>hi</div>; }\nconst $$sinwanReplace = 1;";
|
|
389
|
+
const result = plugin.transform(alreadyWired, "/app/src/Hello.tsx");
|
|
390
|
+
expect(result?.code).not.toContain("import.meta.hot.accept");
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it("skips Fast Refresh when the refresh helper is already present", () => {
|
|
394
|
+
const plugin = sinwan({ cache: false, fastRefresh: true, dev: false });
|
|
395
|
+
plugin.configResolved({
|
|
396
|
+
command: "serve",
|
|
397
|
+
mode: "development",
|
|
398
|
+
root: "/app",
|
|
399
|
+
});
|
|
400
|
+
const alreadyWired =
|
|
401
|
+
"export function Hello() { return <div>hi</div>; }\nconst __$sinwanRefresh = 1;";
|
|
402
|
+
const result = plugin.transform(alreadyWired, "/app/src/Hello.tsx");
|
|
403
|
+
expect(result?.code).not.toContain("import.meta.hot.accept");
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const COMPILER_RANGE = ">=0.4.0 <1.0.0";
|
|
37
408
|
|
|
38
409
|
describe("sinwan-compiler dependency range", () => {
|
|
39
410
|
it("accepts any 0.x compiler without a plugin republish", () => {
|
|
@@ -41,9 +412,7 @@ describe("sinwan-compiler dependency range", () => {
|
|
|
41
412
|
fs.readFileSync(path.join(import.meta.dir, "..", "package.json"), "utf8"),
|
|
42
413
|
) as {
|
|
43
414
|
dependencies: Record<string, string>;
|
|
44
|
-
peerDependencies: Record<string, string>;
|
|
45
415
|
};
|
|
46
416
|
expect(pkg.dependencies["sinwan-compiler"]).toBe(COMPILER_RANGE);
|
|
47
|
-
expect(pkg.peerDependencies["sinwan-compiler"]).toBe(COMPILER_RANGE);
|
|
48
417
|
});
|
|
49
418
|
});
|
package/bun.lock
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"lockfileVersion":
|
|
2
|
+
"lockfileVersion": 2,
|
|
3
3
|
"configVersion": 1,
|
|
4
4
|
"workspaces": {
|
|
5
5
|
"": {
|
|
6
6
|
"name": "vite-plugin-sinwan",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"sinwan-compiler": "
|
|
8
|
+
"sinwan-compiler": ">=0.4.0 <1.0.0",
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/bun": "latest",
|
|
12
|
-
"typescript": "^5",
|
|
13
12
|
},
|
|
14
13
|
"peerDependencies": {
|
|
15
|
-
"typescript": "
|
|
16
|
-
"vite": "
|
|
14
|
+
"typescript": ">=5.0.0 <8.0.0",
|
|
15
|
+
"vite": ">=5.0.0 <9.0.0",
|
|
17
16
|
},
|
|
18
17
|
},
|
|
19
18
|
},
|
|
@@ -50,173 +49,179 @@
|
|
|
50
49
|
|
|
51
50
|
"@babel/types": ["@babel/types@7.29.8", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg=="],
|
|
52
51
|
|
|
53
|
-
"@
|
|
52
|
+
"@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
|
|
54
53
|
|
|
55
|
-
"@
|
|
54
|
+
"@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
|
|
56
55
|
|
|
57
|
-
"@
|
|
56
|
+
"@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
|
|
58
57
|
|
|
59
|
-
"@
|
|
58
|
+
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
|
|
60
59
|
|
|
61
|
-
"@
|
|
60
|
+
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
|
62
61
|
|
|
63
|
-
"@
|
|
62
|
+
"@oxc-project/types": ["@oxc-project/types@0.149.0", "", {}, "sha512-Efcc+iF0j3Bf67YjEqIqWXbX5XddXoK/Mw4K1/JuXwRCZ8N16VR7iT23nlCc9XrveFVh/E5Rqs2StT0V8v9LdA=="],
|
|
64
63
|
|
|
65
|
-
"@
|
|
64
|
+
"@rolldown/binding-android-arm-eabi": ["@rolldown/binding-android-arm-eabi@1.2.8", "", { "os": "android", "cpu": "arm" }, "sha512-tN5aztYkKCte4i5SIrrz5yK/HMjEuCqCSCJa418jOV8tZ1cBY3YF2otxB1ktPxzsLA1BeTqwapK0bfjxNvHJVw=="],
|
|
66
65
|
|
|
67
|
-
"@
|
|
66
|
+
"@rolldown/binding-android-arm64": ["@rolldown/binding-android-arm64@1.2.8", "", { "os": "android", "cpu": "arm64" }, "sha512-dIYTWl9XprMUiQFoc55KUyk/oS8SKYH3zFl0LTR7RT0Xj4hgSVyuJcroH8JUu8RcpF8fTB6E0aOwCkZoYPcDSQ=="],
|
|
68
67
|
|
|
69
|
-
"@
|
|
68
|
+
"@rolldown/binding-darwin-arm64": ["@rolldown/binding-darwin-arm64@1.2.8", "", { "os": "darwin", "cpu": "arm64" }, "sha512-PCSDQGXD2IyTEFrcgPyBM8jJuGmrbCMuoIOXdbEGVemruKACXoLQJrb+A45Z0L5t1RQkdfJprAYPkikbh7dzdA=="],
|
|
70
69
|
|
|
71
|
-
"@
|
|
70
|
+
"@rolldown/binding-darwin-x64": ["@rolldown/binding-darwin-x64@1.2.8", "", { "os": "darwin", "cpu": "x64" }, "sha512-Uk7lRsGhPFHVX/sAUC6D5H9Ol30dFHd6iquokll2th3LpdJ3F5CzQB+7DHn0Ri2mG+U7k2zXiPHDrwZenXhwSA=="],
|
|
72
71
|
|
|
73
|
-
"@
|
|
72
|
+
"@rolldown/binding-freebsd-x64": ["@rolldown/binding-freebsd-x64@1.2.8", "", { "os": "freebsd", "cpu": "x64" }, "sha512-DjszaTEVogPqA5bYzsEeqDCQxbcp2fexQwKcRspYji2yzR68fCf+e4fx6kBSRDwX5/brZaHw/hWS9+A/+/w9sQ=="],
|
|
74
73
|
|
|
75
|
-
"@
|
|
74
|
+
"@rolldown/binding-linux-arm-gnueabihf": ["@rolldown/binding-linux-arm-gnueabihf@1.2.8", "", { "os": "linux", "cpu": "arm" }, "sha512-zmwa7FTmdzB6aaEEuuls18H6Ap5JmJPSoPTuXixeJZV6tG40SyLkApQtz1g8ptZtiEKqj9OM0oNLPh1AgvE31Q=="],
|
|
76
75
|
|
|
77
|
-
"@
|
|
76
|
+
"@rolldown/binding-linux-arm64-gnu": ["@rolldown/binding-linux-arm64-gnu@1.2.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-KdYQDPHwJVnbFwdTGMgxsI9SqblBlz6STGM+w1We/d5B8OWWidYH0MwkU/uA1wM5fIpO2MkOVxXrNzzuZhw9ew=="],
|
|
78
77
|
|
|
79
|
-
"@
|
|
78
|
+
"@rolldown/binding-linux-arm64-musl": ["@rolldown/binding-linux-arm64-musl@1.2.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-jFJTifHnNPY+yzOoNZQfSIysrVyXzEQPhPnOUjmD1bcQGHH6s7c8cViKWar8YplQImE5N9JRqMCLrM2CdxOrZA=="],
|
|
80
79
|
|
|
81
|
-
"@
|
|
80
|
+
"@rolldown/binding-linux-ppc64-gnu": ["@rolldown/binding-linux-ppc64-gnu@1.2.8", "", { "os": "linux", "cpu": "ppc64" }, "sha512-FhiOziBDWPBjbcmRzfLyIJnaP7AVMFXT7YCXPjXxj7wKU3vx24RjrCNN/zjvVa+N2vVoHJwCoUBvsrN/DG3zIA=="],
|
|
82
81
|
|
|
83
|
-
"@
|
|
82
|
+
"@rolldown/binding-linux-s390x-gnu": ["@rolldown/binding-linux-s390x-gnu@1.2.8", "", { "os": "linux", "cpu": "s390x" }, "sha512-WnHfADMzOV2Y55wlx1hzzQnar/wDt/VdvWSD99r18Mz9ylNieIGOkRx3UV21h7m/eJvjySYJkO26VvGNFkwsIQ=="],
|
|
84
83
|
|
|
85
|
-
"@
|
|
84
|
+
"@rolldown/binding-linux-x64-gnu": ["@rolldown/binding-linux-x64-gnu@1.2.8", "", { "os": "linux", "cpu": "x64" }, "sha512-H9tRr5ibfXFVLxbPOseVewewFpl28zcEdjRDt2FTUZU7odxP0gEv1ki4/kGmcGOh78oRwZuuQllGLZ9zTJp84g=="],
|
|
86
85
|
|
|
87
|
-
"@
|
|
86
|
+
"@rolldown/binding-linux-x64-musl": ["@rolldown/binding-linux-x64-musl@1.2.8", "", { "os": "linux", "cpu": "x64" }, "sha512-UefiqfM3D6IVNlZ8tSGs9+Ejjud2T+oxO0IHADU45Y+lyEjD2dVFyZHbkfX0LUb5Zugo/oIv1eCO/KVYhgYJYA=="],
|
|
88
87
|
|
|
89
|
-
"@
|
|
88
|
+
"@rolldown/binding-openharmony-arm64": ["@rolldown/binding-openharmony-arm64@1.2.8", "", { "os": "none", "cpu": "arm64" }, "sha512-637Ke4kWSy6rp9cxQ9gMOXlxPgIw/c1beASV4M//3+9I4uwBVOOl74G+e3zyU3u19U7RkRl/HuewixZ/Z6+Rjg=="],
|
|
90
89
|
|
|
91
|
-
"@
|
|
90
|
+
"@rolldown/binding-win32-arm64-msvc": ["@rolldown/binding-win32-arm64-msvc@1.2.8", "", { "os": "win32", "cpu": "arm64" }, "sha512-xWBkPOF1Q9k/Gv1nQXnVdLxKu74jXppuOM4Z3mnypVUJJJwLsMl7hNJGRAUJoG8A5MgOI1ACKM+wBFxSJzKy4A=="],
|
|
92
91
|
|
|
93
|
-
"@
|
|
92
|
+
"@rolldown/binding-win32-x64-msvc": ["@rolldown/binding-win32-x64-msvc@1.2.8", "", { "os": "win32", "cpu": "x64" }, "sha512-uz2ZvfgXbxqNwijjjbxrnvALwpyODDcgc1T1N8N3rf/DXKQmaFwmB4LX4yyjggpwN2obdQLb2rgirX5ffCWYng=="],
|
|
94
93
|
|
|
95
|
-
"@
|
|
94
|
+
"@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.1", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="],
|
|
96
95
|
|
|
97
|
-
"@
|
|
96
|
+
"@types/bun": ["@types/bun@1.4.2", "", { "dependencies": { "bun-types": "1.4.2" } }, "sha512-GimotNn7+ZV0uVArItBbriZsR1oNf0+WTzPkdcFrzShI7k2norL0uzEaJT8T33dWr7O/c9ZDuAFQrctKCi72oQ=="],
|
|
98
97
|
|
|
99
|
-
"@
|
|
98
|
+
"@types/node": ["@types/node@26.5.1", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g=="],
|
|
100
99
|
|
|
101
|
-
"@
|
|
100
|
+
"@typescript/typescript-aix-ppc64": ["@typescript/typescript-aix-ppc64@7.0.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="],
|
|
102
101
|
|
|
103
|
-
"@
|
|
102
|
+
"@typescript/typescript-darwin-arm64": ["@typescript/typescript-darwin-arm64@7.0.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA=="],
|
|
104
103
|
|
|
105
|
-
"@
|
|
104
|
+
"@typescript/typescript-darwin-x64": ["@typescript/typescript-darwin-x64@7.0.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA=="],
|
|
106
105
|
|
|
107
|
-
"@
|
|
106
|
+
"@typescript/typescript-freebsd-arm64": ["@typescript/typescript-freebsd-arm64@7.0.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ=="],
|
|
108
107
|
|
|
109
|
-
"@
|
|
108
|
+
"@typescript/typescript-freebsd-x64": ["@typescript/typescript-freebsd-x64@7.0.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw=="],
|
|
110
109
|
|
|
111
|
-
"@
|
|
110
|
+
"@typescript/typescript-linux-arm": ["@typescript/typescript-linux-arm@7.0.2", "", { "os": "linux", "cpu": "arm" }, "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ=="],
|
|
112
111
|
|
|
113
|
-
"@
|
|
112
|
+
"@typescript/typescript-linux-arm64": ["@typescript/typescript-linux-arm64@7.0.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ=="],
|
|
114
113
|
|
|
115
|
-
"@
|
|
114
|
+
"@typescript/typescript-linux-loong64": ["@typescript/typescript-linux-loong64@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ=="],
|
|
116
115
|
|
|
117
|
-
"@
|
|
116
|
+
"@typescript/typescript-linux-mips64el": ["@typescript/typescript-linux-mips64el@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA=="],
|
|
118
117
|
|
|
119
|
-
"@
|
|
118
|
+
"@typescript/typescript-linux-ppc64": ["@typescript/typescript-linux-ppc64@7.0.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA=="],
|
|
120
119
|
|
|
121
|
-
"@
|
|
120
|
+
"@typescript/typescript-linux-riscv64": ["@typescript/typescript-linux-riscv64@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ=="],
|
|
122
121
|
|
|
123
|
-
"@
|
|
122
|
+
"@typescript/typescript-linux-s390x": ["@typescript/typescript-linux-s390x@7.0.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw=="],
|
|
124
123
|
|
|
125
|
-
"@
|
|
124
|
+
"@typescript/typescript-linux-x64": ["@typescript/typescript-linux-x64@7.0.2", "", { "os": "linux", "cpu": "x64" }, "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A=="],
|
|
126
125
|
|
|
127
|
-
"@
|
|
126
|
+
"@typescript/typescript-netbsd-arm64": ["@typescript/typescript-netbsd-arm64@7.0.2", "", { "os": "none", "cpu": "arm64" }, "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA=="],
|
|
128
127
|
|
|
129
|
-
"@
|
|
128
|
+
"@typescript/typescript-netbsd-x64": ["@typescript/typescript-netbsd-x64@7.0.2", "", { "os": "none", "cpu": "x64" }, "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA=="],
|
|
130
129
|
|
|
131
|
-
"@
|
|
130
|
+
"@typescript/typescript-openbsd-arm64": ["@typescript/typescript-openbsd-arm64@7.0.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ=="],
|
|
132
131
|
|
|
133
|
-
"@
|
|
132
|
+
"@typescript/typescript-openbsd-x64": ["@typescript/typescript-openbsd-x64@7.0.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg=="],
|
|
134
133
|
|
|
135
|
-
"@
|
|
134
|
+
"@typescript/typescript-sunos-x64": ["@typescript/typescript-sunos-x64@7.0.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g=="],
|
|
136
135
|
|
|
137
|
-
"@
|
|
136
|
+
"@typescript/typescript-win32-arm64": ["@typescript/typescript-win32-arm64@7.0.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ=="],
|
|
138
137
|
|
|
139
|
-
"@
|
|
138
|
+
"@typescript/typescript-win32-x64": ["@typescript/typescript-win32-x64@7.0.2", "", { "os": "win32", "cpu": "x64" }, "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="],
|
|
140
139
|
|
|
141
|
-
"
|
|
140
|
+
"baseline-browser-mapping": ["baseline-browser-mapping@2.11.23", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-le521dGVfxM7yRX0EikCoSz+rOK+hHzdDt/E7mG1jOJB/6WAAUuwVroLwaB7ApaUsz5Q0kFlDXLSA9MheUIfRQ=="],
|
|
142
141
|
|
|
143
|
-
"
|
|
142
|
+
"browserslist": ["browserslist@4.28.9", "", { "dependencies": { "baseline-browser-mapping": "^2.11.20", "caniuse-lite": "^1.0.30001810", "electron-to-chromium": "^1.5.420", "node-releases": "^2.0.54", "update-browserslist-db": "^1.3.2" }, "bin": { "browserslist": "cli.js" } }, "sha512-EWazOblFYUvlGZcfGhPUPmYh3nikUxBVb+y9MJun5f3hBi812X+8MSQTujLBtgK3cf51fJWbWfOjyeO954d+Eg=="],
|
|
144
143
|
|
|
145
|
-
"
|
|
144
|
+
"bun-types": ["bun-types@1.4.2", "", { "dependencies": { "@types/node": "*" } }, "sha512-bxV1FgK7yBIzjRe5zBozIM4Bem11ZJcCXSrjWRG3YWLt8yFDePu4cLjpebO8OvPeIE9trbyPF4fuj3Cia4Fj3w=="],
|
|
146
145
|
|
|
147
|
-
"
|
|
146
|
+
"caniuse-lite": ["caniuse-lite@1.0.30001810", "", {}, "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg=="],
|
|
148
147
|
|
|
149
|
-
"
|
|
148
|
+
"convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
|
|
150
149
|
|
|
151
|
-
"
|
|
150
|
+
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
|
152
151
|
|
|
153
|
-
"
|
|
152
|
+
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
|
154
153
|
|
|
155
|
-
"
|
|
154
|
+
"electron-to-chromium": ["electron-to-chromium@1.5.427", "", {}, "sha512-n14zb3FdsChZ2BNobqNHAJMcP3ifFv4paox2LvCrfVAQcqGiSURgbJl+PfMpHVCNFkStnNc+RRVtPBTVW5PDgw=="],
|
|
156
155
|
|
|
157
|
-
"
|
|
156
|
+
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
|
158
157
|
|
|
159
|
-
"
|
|
158
|
+
"fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
|
|
160
159
|
|
|
161
|
-
"
|
|
160
|
+
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
|
162
161
|
|
|
163
|
-
"
|
|
162
|
+
"gensync": ["gensync@1.0.0-beta.2", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
|
|
164
163
|
|
|
165
|
-
"
|
|
164
|
+
"js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
|
|
166
165
|
|
|
167
|
-
"
|
|
166
|
+
"jsesc": ["jsesc@3.1.0", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="],
|
|
168
167
|
|
|
169
|
-
"
|
|
168
|
+
"json5": ["json5@2.2.3", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="],
|
|
170
169
|
|
|
171
|
-
"
|
|
170
|
+
"lightningcss": ["lightningcss@1.33.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.33.0", "lightningcss-darwin-arm64": "1.33.0", "lightningcss-darwin-x64": "1.33.0", "lightningcss-freebsd-x64": "1.33.0", "lightningcss-linux-arm-gnueabihf": "1.33.0", "lightningcss-linux-arm64-gnu": "1.33.0", "lightningcss-linux-arm64-musl": "1.33.0", "lightningcss-linux-x64-gnu": "1.33.0", "lightningcss-linux-x64-musl": "1.33.0", "lightningcss-win32-arm64-msvc": "1.33.0", "lightningcss-win32-x64-msvc": "1.33.0" } }, "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA=="],
|
|
172
171
|
|
|
173
|
-
"
|
|
172
|
+
"lightningcss-android-arm64": ["lightningcss-android-arm64@1.33.0", "", { "os": "android", "cpu": "arm64" }, "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg=="],
|
|
174
173
|
|
|
175
|
-
"
|
|
174
|
+
"lightningcss-darwin-arm64": ["lightningcss-darwin-arm64@1.33.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg=="],
|
|
176
175
|
|
|
177
|
-
"
|
|
176
|
+
"lightningcss-darwin-x64": ["lightningcss-darwin-x64@1.33.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ=="],
|
|
178
177
|
|
|
179
|
-
"
|
|
178
|
+
"lightningcss-freebsd-x64": ["lightningcss-freebsd-x64@1.33.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg=="],
|
|
180
179
|
|
|
181
|
-
"
|
|
180
|
+
"lightningcss-linux-arm-gnueabihf": ["lightningcss-linux-arm-gnueabihf@1.33.0", "", { "os": "linux", "cpu": "arm" }, "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ=="],
|
|
182
181
|
|
|
183
|
-
"
|
|
182
|
+
"lightningcss-linux-arm64-gnu": ["lightningcss-linux-arm64-gnu@1.33.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg=="],
|
|
184
183
|
|
|
185
|
-
"
|
|
184
|
+
"lightningcss-linux-arm64-musl": ["lightningcss-linux-arm64-musl@1.33.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ=="],
|
|
186
185
|
|
|
187
|
-
"
|
|
186
|
+
"lightningcss-linux-x64-gnu": ["lightningcss-linux-x64-gnu@1.33.0", "", { "os": "linux", "cpu": "x64" }, "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg=="],
|
|
188
187
|
|
|
189
|
-
"
|
|
188
|
+
"lightningcss-linux-x64-musl": ["lightningcss-linux-x64-musl@1.33.0", "", { "os": "linux", "cpu": "x64" }, "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw=="],
|
|
190
189
|
|
|
191
|
-
"
|
|
190
|
+
"lightningcss-win32-arm64-msvc": ["lightningcss-win32-arm64-msvc@1.33.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA=="],
|
|
191
|
+
|
|
192
|
+
"lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.33.0", "", { "os": "win32", "cpu": "x64" }, "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA=="],
|
|
192
193
|
|
|
193
194
|
"lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
|
194
195
|
|
|
195
196
|
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
|
196
197
|
|
|
197
|
-
"nanoid": ["nanoid@3.3.
|
|
198
|
+
"nanoid": ["nanoid@3.3.19", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug=="],
|
|
198
199
|
|
|
199
|
-
"node-releases": ["node-releases@2.0.
|
|
200
|
+
"node-releases": ["node-releases@2.0.55", "", {}, "sha512-mIrE/Cw9y+9Au6dS5vDKDhQza9YvG6w+ZrS6X+ZzA7yFW/soAeaups4Qzn1bL6g5FVy8WtP79+0j82oPIbqRjQ=="],
|
|
200
201
|
|
|
201
202
|
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
|
202
203
|
|
|
203
|
-
"
|
|
204
|
+
"picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="],
|
|
205
|
+
|
|
206
|
+
"postcss": ["postcss@8.5.28", "", { "dependencies": { "nanoid": "^3.3.18", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A=="],
|
|
204
207
|
|
|
205
|
-
"
|
|
208
|
+
"rolldown": ["rolldown@1.2.8", "", { "dependencies": { "@oxc-project/types": "=0.149.0", "@rolldown/pluginutils": "^1.0.0" }, "optionalDependencies": { "@rolldown/binding-android-arm-eabi": "1.2.8", "@rolldown/binding-android-arm64": "1.2.8", "@rolldown/binding-darwin-arm64": "1.2.8", "@rolldown/binding-darwin-x64": "1.2.8", "@rolldown/binding-freebsd-x64": "1.2.8", "@rolldown/binding-linux-arm-gnueabihf": "1.2.8", "@rolldown/binding-linux-arm64-gnu": "1.2.8", "@rolldown/binding-linux-arm64-musl": "1.2.8", "@rolldown/binding-linux-ppc64-gnu": "1.2.8", "@rolldown/binding-linux-s390x-gnu": "1.2.8", "@rolldown/binding-linux-x64-gnu": "1.2.8", "@rolldown/binding-linux-x64-musl": "1.2.8", "@rolldown/binding-openharmony-arm64": "1.2.8", "@rolldown/binding-win32-arm64-msvc": "1.2.8", "@rolldown/binding-win32-x64-msvc": "1.2.8" }, "bin": { "rolldown": "./bin/cli.mjs" } }, "sha512-Z67nTmhZe7anqnM/EjI392w5i/ANUinjip7QYsOyN37oayduxt3ksdX0hf5OOamkAd53BiIHfbfSzfUmzKFQqQ=="],
|
|
206
209
|
|
|
207
210
|
"semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
|
208
211
|
|
|
209
|
-
"sinwan-compiler": ["sinwan-compiler@0.
|
|
212
|
+
"sinwan-compiler": ["sinwan-compiler@0.4.0", "", { "dependencies": { "@babel/core": "^7.29.7", "@babel/generator": "^7.29.8", "@babel/parser": "^7.29.8", "@babel/traverse": "^7.29.8", "@babel/types": "^7.29.8" }, "peerDependencies": { "typescript": ">=5.0.0 <8.0.0" }, "bin": { "sinwan": "dist/cli.js" } }, "sha512-kjT2tpNMvIfgOtK5sQhXvn/dvGpnbYO5vhkcv3drlnWKudc1HIGT1DMVQbwbaLEkdvKOpC0qqvD4DSi8vNa1sg=="],
|
|
210
213
|
|
|
211
214
|
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
|
212
215
|
|
|
213
|
-
"
|
|
216
|
+
"tinyglobby": ["tinyglobby@0.2.17", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
|
|
217
|
+
|
|
218
|
+
"typescript": ["typescript@7.0.2", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
|
|
214
219
|
|
|
215
|
-
"undici-types": ["undici-types@
|
|
220
|
+
"undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
|
|
216
221
|
|
|
217
|
-
"update-browserslist-db": ["update-browserslist-db@1.3.
|
|
222
|
+
"update-browserslist-db": ["update-browserslist-db@1.3.3", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ=="],
|
|
218
223
|
|
|
219
|
-
"vite": ["vite@
|
|
224
|
+
"vite": ["vite@8.3.0", "", { "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", "postcss": "^8.5.28", "rolldown": "~1.2.6", "tinyglobby": "^0.2.17" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.7.1", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "@vitejs/devtools", "esbuild", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-lhZBVvEHefgE+HQZC9O7EBJgCU/nVzFNl7vkS4RE0APtWLP02/8QVIkQtzBxPquh7lq5/78NHipTj7ODQ6XuyQ=="],
|
|
220
225
|
|
|
221
226
|
"yallist": ["yallist@3.1.1", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
|
|
222
227
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type SinwanCacheOptions = boolean | {
|
|
|
10
10
|
workspaces?: import("sinwan-compiler").WorkspacesConfig;
|
|
11
11
|
};
|
|
12
12
|
export interface SinwanOptions {
|
|
13
|
+
derivedLocals?: boolean;
|
|
13
14
|
/** Enable template hoisting (default: true) */
|
|
14
15
|
hoist?: boolean;
|
|
15
16
|
/** Emit explicit compiler-driven binding descriptors (default: true). */
|
|
@@ -31,6 +32,12 @@ export interface SinwanOptions {
|
|
|
31
32
|
* Only active in `vite serve`; never affects production builds.
|
|
32
33
|
*/
|
|
33
34
|
fastRefresh?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Warn when template hoisting is skipped (spreads, enhancer tags, …).
|
|
37
|
+
* Default: Vite `config.mode !== "production"` after `configResolved`,
|
|
38
|
+
* otherwise `process.env.NODE_ENV !== "production"` when `sinwan()` runs.
|
|
39
|
+
*/
|
|
40
|
+
dev?: boolean;
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* Unified Sinwan Vite plugin.
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,9 @@ ${replaces}
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
import * as fs from "fs";
|
|
32
32
|
import * as path from "path";
|
|
33
|
+
function defaultCompilerDev() {
|
|
34
|
+
return process.env["NODE_ENV"] !== "production";
|
|
35
|
+
}
|
|
33
36
|
var DEFAULT_SINWAN_OPTIONS = {
|
|
34
37
|
hoist: true,
|
|
35
38
|
explicitBindings: false,
|
|
@@ -39,6 +42,8 @@ var DEFAULT_SINWAN_OPTIONS = {
|
|
|
39
42
|
};
|
|
40
43
|
function sinwan(options = {}) {
|
|
41
44
|
const opts = { ...DEFAULT_SINWAN_OPTIONS, ...options };
|
|
45
|
+
const explicitDev = options.dev;
|
|
46
|
+
let compilerDev = explicitDev ?? defaultCompilerDev();
|
|
42
47
|
let isServe = false;
|
|
43
48
|
let projectRoot;
|
|
44
49
|
let cache = null;
|
|
@@ -55,6 +60,9 @@ function sinwan(options = {}) {
|
|
|
55
60
|
configResolved(config) {
|
|
56
61
|
isServe = config?.command === "serve";
|
|
57
62
|
projectRoot = config?.root;
|
|
63
|
+
if (explicitDev === undefined && typeof config?.mode === "string") {
|
|
64
|
+
compilerDev = config.mode !== "production";
|
|
65
|
+
}
|
|
58
66
|
if (opts.cache) {
|
|
59
67
|
const root = typeof opts.cache === "object" ? opts.cache.root ?? projectRoot ?? process.cwd() : projectRoot ?? process.cwd();
|
|
60
68
|
const tsConfigPath = typeof opts.cache === "object" ? opts.cache.tsConfigPath : undefined;
|
|
@@ -78,8 +86,9 @@ function sinwan(options = {}) {
|
|
|
78
86
|
}
|
|
79
87
|
result = transformJSX(code, id, {
|
|
80
88
|
hoist: opts.hoist,
|
|
89
|
+
derivedLocals: opts.derivedLocals,
|
|
81
90
|
explicitBindings: opts.explicitBindings,
|
|
82
|
-
dev:
|
|
91
|
+
dev: compilerDev,
|
|
83
92
|
analyze: opts.analyze,
|
|
84
93
|
analyzeMetadata: cache ? cache.reactiveProps : undefined,
|
|
85
94
|
resolveImport: cache ? cache.resolve : undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-sinwan",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Vite plugin for sinwan",
|
|
5
5
|
"author": "Mohammed Ben Cheikh",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,18 +29,17 @@
|
|
|
29
29
|
"sinwan": "./dist/cli.js"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "bun run build.ts"
|
|
32
|
+
"build": "bun run build.ts",
|
|
33
|
+
"test": "bun test --coverage __tests__/plugin.test.ts"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@types/bun": "latest"
|
|
36
|
-
"typescript": "^5"
|
|
36
|
+
"@types/bun": "latest"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"sinwan-compiler": ">=0.
|
|
39
|
+
"sinwan-compiler": ">=0.4.0 <1.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"typescript": "
|
|
43
|
-
"vite": "
|
|
44
|
-
"sinwan-compiler": ">=0.2.5 <1.0.0"
|
|
42
|
+
"typescript": ">=5.0.0 <8.0.0",
|
|
43
|
+
"vite": ">=5.0.0 <9.0.0"
|
|
45
44
|
}
|
|
46
45
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type SinwanCacheOptions =
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export interface SinwanOptions {
|
|
20
|
+
derivedLocals?: boolean;
|
|
20
21
|
/** Enable template hoisting (default: true) */
|
|
21
22
|
hoist?: boolean;
|
|
22
23
|
/** Emit explicit compiler-driven binding descriptors (default: true). */
|
|
@@ -38,6 +39,20 @@ export interface SinwanOptions {
|
|
|
38
39
|
* Only active in `vite serve`; never affects production builds.
|
|
39
40
|
*/
|
|
40
41
|
fastRefresh?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Warn when template hoisting is skipped (spreads, enhancer tags, …).
|
|
44
|
+
* Default: Vite `config.mode !== "production"` after `configResolved`,
|
|
45
|
+
* otherwise `process.env.NODE_ENV !== "production"` when `sinwan()` runs.
|
|
46
|
+
*/
|
|
47
|
+
dev?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Bracket access so Bun.build cannot fold `process.env.NODE_ENV` into `true`
|
|
52
|
+
* when this plugin itself is bundled.
|
|
53
|
+
*/
|
|
54
|
+
function defaultCompilerDev(): boolean {
|
|
55
|
+
return process.env["NODE_ENV"] !== "production";
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
const DEFAULT_SINWAN_OPTIONS: Required<
|
|
@@ -66,6 +81,8 @@ const DEFAULT_SINWAN_OPTIONS: Required<
|
|
|
66
81
|
*/
|
|
67
82
|
export function sinwan(options: SinwanOptions = {}) {
|
|
68
83
|
const opts = { ...DEFAULT_SINWAN_OPTIONS, ...options };
|
|
84
|
+
const explicitDev = options.dev;
|
|
85
|
+
let compilerDev = explicitDev ?? defaultCompilerDev();
|
|
69
86
|
|
|
70
87
|
// Whether we are running the dev server (`vite serve`). Fast Refresh
|
|
71
88
|
// injection only happens here; production builds are never touched.
|
|
@@ -94,6 +111,9 @@ export function sinwan(options: SinwanOptions = {}) {
|
|
|
94
111
|
configResolved(config: any) {
|
|
95
112
|
isServe = config?.command === "serve";
|
|
96
113
|
projectRoot = config?.root;
|
|
114
|
+
if (explicitDev === undefined && typeof config?.mode === "string") {
|
|
115
|
+
compilerDev = config.mode !== "production";
|
|
116
|
+
}
|
|
97
117
|
|
|
98
118
|
if (opts.cache) {
|
|
99
119
|
const root =
|
|
@@ -128,8 +148,9 @@ export function sinwan(options: SinwanOptions = {}) {
|
|
|
128
148
|
}
|
|
129
149
|
result = transformJSX(code, id, {
|
|
130
150
|
hoist: opts.hoist,
|
|
151
|
+
derivedLocals: opts.derivedLocals,
|
|
131
152
|
explicitBindings: opts.explicitBindings,
|
|
132
|
-
dev:
|
|
153
|
+
dev: compilerDev,
|
|
133
154
|
analyze: opts.analyze,
|
|
134
155
|
analyzeMetadata: cache ? cache.reactiveProps : undefined,
|
|
135
156
|
resolveImport: cache ? cache.resolve : undefined,
|