vite-plugin-sinwan 0.2.4 → 0.2.6
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 +8 -0
- package/__tests__/plugin.test.ts +19 -0
- package/bun.lock +2 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/package.json +4 -3
- package/src/index.ts +12 -0
package/README.md
CHANGED
|
@@ -8,6 +8,14 @@ Vite plugin for [Sinwan](https://sinwanjs.com) — JSX transformation with templ
|
|
|
8
8
|
bun add -d vite-plugin-sinwan
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Compiler updates
|
|
12
|
+
|
|
13
|
+
The plugin depends on `sinwan-compiler` with `>=0.2.5 <1.0.0` and does not bundle it. Publishing a new 0.x compiler does **not** require a plugin release.
|
|
14
|
+
|
|
15
|
+
- New installs resolve the newest compatible compiler automatically.
|
|
16
|
+
- Existing apps keep a lockfile pin until they run `bun update sinwan-compiler`.
|
|
17
|
+
- Republish this plugin only when the plugin API itself changes, or when `sinwan-compiler` reaches 1.0.
|
|
18
|
+
|
|
11
19
|
## Usage
|
|
12
20
|
|
|
13
21
|
```ts
|
package/__tests__/plugin.test.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from "bun:test";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
2
4
|
import { sinwan } from "../src/index";
|
|
3
5
|
|
|
4
6
|
describe("sinwan vite plugin", () => {
|
|
@@ -6,7 +8,9 @@ describe("sinwan vite plugin", () => {
|
|
|
6
8
|
const plugin = sinwan({ cache: true });
|
|
7
9
|
expect(plugin.name).toBe("sinwan");
|
|
8
10
|
expect(typeof plugin.configResolved).toBe("function");
|
|
11
|
+
expect(typeof plugin.config).toBe("function");
|
|
9
12
|
expect(typeof plugin.transform).toBe("function");
|
|
13
|
+
expect(plugin.config()).toEqual({ resolve: { dedupe: ["sinwan"] } });
|
|
10
14
|
});
|
|
11
15
|
|
|
12
16
|
it("can be created with a custom cache root", () => {
|
|
@@ -28,3 +32,18 @@ describe("sinwan vite plugin", () => {
|
|
|
28
32
|
expect(plugin.name).toBe("sinwan");
|
|
29
33
|
});
|
|
30
34
|
});
|
|
35
|
+
|
|
36
|
+
const COMPILER_RANGE = ">=0.2.5 <1.0.0";
|
|
37
|
+
|
|
38
|
+
describe("sinwan-compiler dependency range", () => {
|
|
39
|
+
it("accepts any 0.x compiler without a plugin republish", () => {
|
|
40
|
+
const pkg = JSON.parse(
|
|
41
|
+
fs.readFileSync(path.join(import.meta.dir, "..", "package.json"), "utf8"),
|
|
42
|
+
) as {
|
|
43
|
+
dependencies: Record<string, string>;
|
|
44
|
+
peerDependencies: Record<string, string>;
|
|
45
|
+
};
|
|
46
|
+
expect(pkg.dependencies["sinwan-compiler"]).toBe(COMPILER_RANGE);
|
|
47
|
+
expect(pkg.peerDependencies["sinwan-compiler"]).toBe(COMPILER_RANGE);
|
|
48
|
+
});
|
|
49
|
+
});
|
package/bun.lock
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"": {
|
|
6
6
|
"name": "vite-plugin-sinwan",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"sinwan-compiler": "^0.2.
|
|
8
|
+
"sinwan-compiler": "^0.2.5",
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/bun": "latest",
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
|
|
207
207
|
"semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
|
208
208
|
|
|
209
|
-
"sinwan-compiler": ["sinwan-compiler@0.2.
|
|
209
|
+
"sinwan-compiler": ["sinwan-compiler@0.2.5", "", { "dependencies": { "@babel/core": "^7.24.0", "@babel/generator": "^7.24.0", "@babel/parser": "^7.24.0", "@babel/traverse": "^7.24.0", "@babel/types": "^7.24.0" }, "peerDependencies": { "typescript": "^5" }, "bin": { "sinwan": "dist/cli.js" } }, "sha512-km53R0sJvmypaPKIWu5QA067XCbhluhp1A3ilxA5Bi3+8gkMz/bMSdyehxvXfcLlcxC+m4Owi+3uXNRfQEBwFA=="],
|
|
210
210
|
|
|
211
211
|
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
|
212
212
|
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,15 @@ export interface SinwanOptions {
|
|
|
46
46
|
export declare function sinwan(options?: SinwanOptions): {
|
|
47
47
|
name: string;
|
|
48
48
|
enforce: string;
|
|
49
|
+
/**
|
|
50
|
+
* Same role as Vite's `resolve.dedupe` for React: linked `file:` / `link:`
|
|
51
|
+
* packages that depend on `sinwan` must share the app's runtime.
|
|
52
|
+
*/
|
|
53
|
+
config(): {
|
|
54
|
+
resolve: {
|
|
55
|
+
dedupe: string[];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
49
58
|
configResolved(config: any): void;
|
|
50
59
|
transform(code: string, id: string): {
|
|
51
60
|
code: string;
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,13 @@ function sinwan(options = {}) {
|
|
|
45
45
|
return {
|
|
46
46
|
name: "sinwan",
|
|
47
47
|
enforce: "pre",
|
|
48
|
+
config() {
|
|
49
|
+
return {
|
|
50
|
+
resolve: {
|
|
51
|
+
dedupe: ["sinwan"]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
},
|
|
48
55
|
configResolved(config) {
|
|
49
56
|
isServe = config?.command === "serve";
|
|
50
57
|
projectRoot = config?.root;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-sinwan",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Vite plugin for sinwan",
|
|
5
5
|
"author": "Mohammed Ben Cheikh",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
"typescript": "^5"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"sinwan-compiler": "
|
|
39
|
+
"sinwan-compiler": ">=0.2.5 <1.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"typescript": "^5",
|
|
43
|
-
"vite": "^5"
|
|
43
|
+
"vite": "^5",
|
|
44
|
+
"sinwan-compiler": ">=0.2.5 <1.0.0"
|
|
44
45
|
}
|
|
45
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -79,6 +79,18 @@ export function sinwan(options: SinwanOptions = {}) {
|
|
|
79
79
|
name: "sinwan",
|
|
80
80
|
enforce: "pre",
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Same role as Vite's `resolve.dedupe` for React: linked `file:` / `link:`
|
|
84
|
+
* packages that depend on `sinwan` must share the app's runtime.
|
|
85
|
+
*/
|
|
86
|
+
config() {
|
|
87
|
+
return {
|
|
88
|
+
resolve: {
|
|
89
|
+
dedupe: ["sinwan"],
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
|
|
82
94
|
configResolved(config: any) {
|
|
83
95
|
isServe = config?.command === "serve";
|
|
84
96
|
projectRoot = config?.root;
|