vite-plugin-sinwan 0.2.0 → 0.2.3

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.
@@ -15,4 +15,16 @@ describe("sinwan vite plugin", () => {
15
15
  });
16
16
  expect(plugin.name).toBe("sinwan");
17
17
  });
18
+
19
+ it("enables explicit bindings and the incremental analyzer by default", () => {
20
+ const plugin = sinwan();
21
+ expect(plugin.name).toBe("sinwan");
22
+ expect(typeof plugin.configResolved).toBe("function");
23
+ expect(typeof plugin.transform).toBe("function");
24
+ });
25
+
26
+ it("allows disabling the cache and explicit bindings", () => {
27
+ const plugin = sinwan({ cache: false, explicitBindings: false });
28
+ expect(plugin.name).toBe("sinwan");
29
+ });
18
30
  });
package/bun.lock CHANGED
@@ -5,8 +5,7 @@
5
5
  "": {
6
6
  "name": "vite-plugin-sinwan",
7
7
  "dependencies": {
8
- "@babel/parser": "^7.24.0",
9
- "sinwan-compiler": "^0.2.0",
8
+ "sinwan-compiler": "^0.2.3",
10
9
  },
11
10
  "devDependencies": {
12
11
  "@types/bun": "latest",
@@ -19,37 +18,37 @@
19
18
  },
20
19
  },
21
20
  "packages": {
22
- "@babel/code-frame": ["@babel/code-frame@7.29.0", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw=="],
21
+ "@babel/code-frame": ["@babel/code-frame@7.29.7", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw=="],
23
22
 
24
- "@babel/compat-data": ["@babel/compat-data@7.29.3", "", {}, "sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg=="],
23
+ "@babel/compat-data": ["@babel/compat-data@7.29.7", "", {}, "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg=="],
25
24
 
26
- "@babel/core": ["@babel/core@7.29.0", "", { "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", "@babel/helper-compilation-targets": "^7.28.6", "@babel/helper-module-transforms": "^7.28.6", "@babel/helpers": "^7.28.6", "@babel/parser": "^7.29.0", "@babel/template": "^7.28.6", "@babel/traverse": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", "semver": "^6.3.1" } }, "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA=="],
25
+ "@babel/core": ["@babel/core@7.29.7", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.7", "@babel/helper-compilation-targets": "^7.29.7", "@babel/helper-module-transforms": "^7.29.7", "@babel/helpers": "^7.29.7", "@babel/parser": "^7.29.7", "@babel/template": "^7.29.7", "@babel/traverse": "^7.29.7", "@babel/types": "^7.29.7", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", "semver": "^6.3.1" } }, "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA=="],
27
26
 
28
- "@babel/generator": ["@babel/generator@7.29.1", "", { "dependencies": { "@babel/parser": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw=="],
27
+ "@babel/generator": ["@babel/generator@7.29.8", "", { "dependencies": { "@babel/parser": "^7.29.8", "@babel/types": "^7.29.8", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg=="],
29
28
 
30
- "@babel/helper-compilation-targets": ["@babel/helper-compilation-targets@7.28.6", "", { "dependencies": { "@babel/compat-data": "^7.28.6", "@babel/helper-validator-option": "^7.27.1", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" } }, "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA=="],
29
+ "@babel/helper-compilation-targets": ["@babel/helper-compilation-targets@7.29.7", "", { "dependencies": { "@babel/compat-data": "^7.29.7", "@babel/helper-validator-option": "^7.29.7", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" } }, "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g=="],
31
30
 
32
- "@babel/helper-globals": ["@babel/helper-globals@7.28.0", "", {}, "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw=="],
31
+ "@babel/helper-globals": ["@babel/helper-globals@7.29.7", "", {}, "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA=="],
33
32
 
34
- "@babel/helper-module-imports": ["@babel/helper-module-imports@7.28.6", "", { "dependencies": { "@babel/traverse": "^7.28.6", "@babel/types": "^7.28.6" } }, "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw=="],
33
+ "@babel/helper-module-imports": ["@babel/helper-module-imports@7.29.7", "", { "dependencies": { "@babel/traverse": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g=="],
35
34
 
36
- "@babel/helper-module-transforms": ["@babel/helper-module-transforms@7.28.6", "", { "dependencies": { "@babel/helper-module-imports": "^7.28.6", "@babel/helper-validator-identifier": "^7.28.5", "@babel/traverse": "^7.28.6" }, "peerDependencies": { "@babel/core": "^7.0.0" } }, "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA=="],
35
+ "@babel/helper-module-transforms": ["@babel/helper-module-transforms@7.29.7", "", { "dependencies": { "@babel/helper-module-imports": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7", "@babel/traverse": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0" } }, "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg=="],
37
36
 
38
- "@babel/helper-string-parser": ["@babel/helper-string-parser@7.27.1", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
37
+ "@babel/helper-string-parser": ["@babel/helper-string-parser@7.29.7", "", {}, "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw=="],
39
38
 
40
- "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.28.5", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
39
+ "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.29.7", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="],
41
40
 
42
- "@babel/helper-validator-option": ["@babel/helper-validator-option@7.27.1", "", {}, "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg=="],
41
+ "@babel/helper-validator-option": ["@babel/helper-validator-option@7.29.7", "", {}, "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw=="],
43
42
 
44
- "@babel/helpers": ["@babel/helpers@7.29.2", "", { "dependencies": { "@babel/template": "^7.28.6", "@babel/types": "^7.29.0" } }, "sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw=="],
43
+ "@babel/helpers": ["@babel/helpers@7.29.7", "", { "dependencies": { "@babel/template": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg=="],
45
44
 
46
- "@babel/parser": ["@babel/parser@7.29.3", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
45
+ "@babel/parser": ["@babel/parser@7.29.8", "", { "dependencies": { "@babel/types": "^7.29.8" }, "bin": "./bin/babel-parser.js" }, "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA=="],
47
46
 
48
- "@babel/template": ["@babel/template@7.28.6", "", { "dependencies": { "@babel/code-frame": "^7.28.6", "@babel/parser": "^7.28.6", "@babel/types": "^7.28.6" } }, "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ=="],
47
+ "@babel/template": ["@babel/template@7.29.7", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/parser": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg=="],
49
48
 
50
- "@babel/traverse": ["@babel/traverse@7.29.0", "", { "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", "@babel/helper-globals": "^7.28.0", "@babel/parser": "^7.29.0", "@babel/template": "^7.28.6", "@babel/types": "^7.29.0", "debug": "^4.3.1" } }, "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA=="],
49
+ "@babel/traverse": ["@babel/traverse@7.29.8", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.8", "@babel/helper-globals": "^7.29.7", "@babel/parser": "^7.29.8", "@babel/template": "^7.29.7", "@babel/types": "^7.29.8", "debug": "^4.3.1" } }, "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg=="],
51
50
 
52
- "@babel/types": ["@babel/types@7.29.0", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
51
+ "@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=="],
53
52
 
54
53
  "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="],
55
54
 
@@ -103,7 +102,7 @@
103
102
 
104
103
  "@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
105
104
 
106
- "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="],
105
+ "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
107
106
 
108
107
  "@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=="],
109
108
 
@@ -163,19 +162,19 @@
163
162
 
164
163
  "@types/node": ["@types/node@25.6.2", "", { "dependencies": { "undici-types": "~7.19.0" } }, "sha512-sokuT28dxf9JT5Kady1fsXOvI4HVpjZa95NKT5y9PNTIrs2AsobR4GFAA90ZG8M+nxVRLysCXsVj6eGC7Vbrlw=="],
165
164
 
166
- "baseline-browser-mapping": ["baseline-browser-mapping@2.10.29", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-Asa2krT+XTPZINCS+2QcyS8WTkObE77RwkydwF7h6DmnKqbvlalz93m/dnphUyCa6SWSP51VgtEUf2FN+gelFQ=="],
165
+ "baseline-browser-mapping": ["baseline-browser-mapping@2.11.20", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw=="],
167
166
 
168
- "browserslist": ["browserslist@4.28.2", "", { "dependencies": { "baseline-browser-mapping": "^2.10.12", "caniuse-lite": "^1.0.30001782", "electron-to-chromium": "^1.5.328", "node-releases": "^2.0.36", "update-browserslist-db": "^1.2.3" }, "bin": { "browserslist": "cli.js" } }, "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg=="],
167
+ "browserslist": ["browserslist@4.28.8", "", { "dependencies": { "baseline-browser-mapping": "^2.11.12", "caniuse-lite": "^1.0.30001809", "electron-to-chromium": "^1.5.402", "node-releases": "^2.0.53", "update-browserslist-db": "^1.3.0" }, "bin": { "browserslist": "cli.js" } }, "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA=="],
169
168
 
170
169
  "bun-types": ["bun-types@1.3.13", "", { "dependencies": { "@types/node": "*" } }, "sha512-QXKeHLlOLqQX9LgYaHJfzdBaV21T63HhFJnvuRCcjZiaUDpbs5ED1MgxbMra71CsryN/1dAoXuJJJwIv/2drVA=="],
171
170
 
172
- "caniuse-lite": ["caniuse-lite@1.0.30001792", "", {}, "sha512-hVLMUZFgR4JJ6ACt1uEESvQN1/dBVqPAKY0hgrV70eN3391K6juAfTjKZLKvOMsx8PxA7gsY1/tLMMTcfFLLpw=="],
171
+ "caniuse-lite": ["caniuse-lite@1.0.30001810", "", {}, "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg=="],
173
172
 
174
173
  "convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
175
174
 
176
- "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
175
+ "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
177
176
 
178
- "electron-to-chromium": ["electron-to-chromium@1.5.356", "", {}, "sha512-9NgFd7m5t5MCJ5rUSjJITUXAH9mEGlrlofnMf4YEr+pz6JlP7cWmTAH+JFmbPnaSW8koVTkuW7pacORWAnA5Yw=="],
177
+ "electron-to-chromium": ["electron-to-chromium@1.5.416", "", {}, "sha512-K6bvB2BjnNrugtIih6ewlbBI9DXa976jIdiIlRLHhBoEI9a4JaQjjHyF+A1IQI543aQYR4LnmOrT/K5fZj0aPA=="],
179
178
 
180
179
  "esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="],
181
180
 
@@ -197,7 +196,7 @@
197
196
 
198
197
  "nanoid": ["nanoid@3.3.12", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ=="],
199
198
 
200
- "node-releases": ["node-releases@2.0.44", "", {}, "sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ=="],
199
+ "node-releases": ["node-releases@2.0.54", "", {}, "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ=="],
201
200
 
202
201
  "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
203
202
 
@@ -207,7 +206,7 @@
207
206
 
208
207
  "semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
209
208
 
210
- "sinwan-compiler": ["sinwan-compiler@0.2.0", "", { "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-a66GYxxo8VtJRV6R07C13oHkgjRZ8PQsGO9KXDF3rQ6hcPW4laYG1t1WlQxrV1GopIejC7LMifZNUPqq4en14A=="],
209
+ "sinwan-compiler": ["sinwan-compiler@0.2.3", "", { "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-Lt8CSorN5Xue1WKxnrZoweT87oBZMIeVb7KVURKMu3cEVttJnyvmcDo3j2BxZvjm7Lju1HnzxqaPqZUjCwle1w=="],
211
210
 
212
211
  "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
213
212
 
@@ -215,7 +214,7 @@
215
214
 
216
215
  "undici-types": ["undici-types@7.19.2", "", {}, "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg=="],
217
216
 
218
- "update-browserslist-db": ["update-browserslist-db@1.2.3", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w=="],
217
+ "update-browserslist-db": ["update-browserslist-db@1.3.2", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw=="],
219
218
 
220
219
  "vite": ["vite@5.4.21", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw=="],
221
220
 
@@ -9,10 +9,9 @@
9
9
  * instead of falling back to the entry — and state is preserved by the
10
10
  * runtime's resolve-to-latest mechanism.
11
11
  *
12
- * Detection is intentionally conservative: only top-level exports whose name
13
- * starts with an uppercase letter (the component naming convention) are
14
- * registered. The runtime safely ignores anything that is not used as a
15
- * component, so over-matching is harmless.
12
+ * Component detection is delegated to `sinwan-compiler`'s shared
13
+ * `collectExportedComponents` utility so both Vite and Bun plugins use the
14
+ * same logic without duplicating Babel parsing.
16
15
  */
17
16
  /**
18
17
  * Append a Fast Refresh HMR footer to a component module's source.
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export type SinwanCacheOptions = boolean | {
12
12
  export interface SinwanOptions {
13
13
  /** Enable template hoisting (default: true) */
14
14
  hoist?: boolean;
15
- /** Emit explicit compiler-driven binding descriptors (Phase 2, default: false). */
15
+ /** Emit explicit compiler-driven binding descriptors (default: true). */
16
16
  explicitBindings?: boolean;
17
17
  /** Path to the reactive-props metadata file produced by `sinwan analyze`. */
18
18
  analyze?: string;
@@ -20,6 +20,8 @@ export interface SinwanOptions {
20
20
  * Enable incremental in-memory cross-file analysis for dev/HMR. When true,
21
21
  * the plugin analyzes each transformed file and passes the current metadata
22
22
  * to the transform without requiring a separate `sinwan analyze` step.
23
+ * Default: true (in-memory only; set to `false` to disable, or pass an object
24
+ * to configure root/paths and persistent cache).
23
25
  */
24
26
  cache?: SinwanCacheOptions;
25
27
  /**
package/dist/index.js CHANGED
@@ -3,61 +3,7 @@
3
3
  import { transformJSX, AnalyzerCache } from "sinwan-compiler";
4
4
 
5
5
  // src/compiler/hmr.ts
6
- import { parse } from "@babel/parser";
7
- function isComponentName(name) {
8
- return !!name && name[0] === name[0].toUpperCase() && /^[A-Z]/.test(name);
9
- }
10
- function collectExportedComponents(code, filename) {
11
- let ast;
12
- try {
13
- ast = parse(code, {
14
- sourceType: "module",
15
- plugins: ["jsx", "typescript"],
16
- sourceFilename: filename
17
- });
18
- } catch {
19
- return [];
20
- }
21
- const found = [];
22
- const seen = new Set;
23
- const add = (local, key) => {
24
- const sig = `${local}::${key}`;
25
- if (seen.has(sig))
26
- return;
27
- seen.add(sig);
28
- found.push({ local, key });
29
- };
30
- for (const node of ast.program.body) {
31
- if (node.type === "ExportNamedDeclaration") {
32
- if (node.declaration) {
33
- const decl = node.declaration;
34
- if (decl.type === "FunctionDeclaration" && decl.id && isComponentName(decl.id.name)) {
35
- add(decl.id.name, decl.id.name);
36
- } else if (decl.type === "VariableDeclaration") {
37
- for (const d of decl.declarations) {
38
- if (d.id?.type === "Identifier" && isComponentName(d.id.name)) {
39
- add(d.id.name, d.id.name);
40
- }
41
- }
42
- }
43
- } else if (node.specifiers && !node.source) {
44
- for (const spec of node.specifiers) {
45
- if (spec.type === "ExportSpecifier" && spec.local?.type === "Identifier" && spec.exported?.type === "Identifier" && isComponentName(spec.exported.name)) {
46
- add(spec.local.name, spec.exported.name);
47
- }
48
- }
49
- }
50
- } else if (node.type === "ExportDefaultDeclaration") {
51
- const decl = node.declaration;
52
- if (decl.type === "Identifier") {
53
- add(decl.name, "default");
54
- } else if (decl.type === "FunctionDeclaration" && decl.id) {
55
- add(decl.id.name, "default");
56
- }
57
- }
58
- }
59
- return found;
60
- }
6
+ import { collectExportedComponents } from "sinwan-compiler";
61
7
  function injectComponentHmr(code, filename) {
62
8
  const components = collectExportedComponents(code, filename);
63
9
  if (components.length === 0)
@@ -69,7 +15,7 @@ function injectComponentHmr(code, filename) {
69
15
  `);
70
16
  const footer = `
71
17
 
72
- import { $$sinwanReplace as __$sinwanReplace, $$sinwanRefresh as __$sinwanRefresh } from "sinwan/react-client";
18
+ import { $$sinwanReplace as __$sinwanReplace, $$sinwanRefresh as __$sinwanRefresh } from "sinwan/react";
73
19
  if (import.meta.hot) {
74
20
  import.meta.hot.accept((__m) => {
75
21
  if (!__m) return;
@@ -88,7 +34,8 @@ var DEFAULT_SINWAN_OPTIONS = {
88
34
  hoist: true,
89
35
  explicitBindings: false,
90
36
  fastRefresh: true,
91
- analyze: undefined
37
+ analyze: undefined,
38
+ cache: true
92
39
  };
93
40
  function sinwan(options = {}) {
94
41
  const opts = { ...DEFAULT_SINWAN_OPTIONS, ...options };
@@ -125,8 +72,10 @@ function sinwan(options = {}) {
125
72
  result = transformJSX(code, id, {
126
73
  hoist: opts.hoist,
127
74
  explicitBindings: opts.explicitBindings,
75
+ dev: true,
128
76
  analyze: opts.analyze,
129
- analyzeMetadata: cache ? cache.reactiveProps : undefined
77
+ analyzeMetadata: cache ? cache.reactiveProps : undefined,
78
+ resolveImport: cache ? cache.resolve : undefined
130
79
  });
131
80
  }
132
81
  const idPath = id.split("?")[0];
@@ -142,6 +91,6 @@ function sinwan(options = {}) {
142
91
  };
143
92
  }
144
93
  export {
145
- transformJSX,
146
- sinwan
94
+ sinwan,
95
+ transformJSX
147
96
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-sinwan",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Vite plugin for sinwan",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -36,8 +36,7 @@
36
36
  "typescript": "^5"
37
37
  },
38
38
  "dependencies": {
39
- "@babel/parser": "^7.24.0",
40
- "sinwan-compiler": "^0.2.0"
39
+ "sinwan-compiler": "^0.2.3"
41
40
  },
42
41
  "peerDependencies": {
43
42
  "typescript": "^5",
@@ -9,94 +9,12 @@
9
9
  * instead of falling back to the entry — and state is preserved by the
10
10
  * runtime's resolve-to-latest mechanism.
11
11
  *
12
- * Detection is intentionally conservative: only top-level exports whose name
13
- * starts with an uppercase letter (the component naming convention) are
14
- * registered. The runtime safely ignores anything that is not used as a
15
- * component, so over-matching is harmless.
12
+ * Component detection is delegated to `sinwan-compiler`'s shared
13
+ * `collectExportedComponents` utility so both Vite and Bun plugins use the
14
+ * same logic without duplicating Babel parsing.
16
15
  */
17
16
 
18
- import { parse } from "@babel/parser";
19
-
20
- interface ExportedComponent {
21
- /** Local binding name in the module (referenced in the accept callback). */
22
- local: string;
23
- /** Export key on the module namespace ("default" for the default export). */
24
- key: string;
25
- }
26
-
27
- function isComponentName(name: string | undefined): name is string {
28
- return !!name && name[0] === name[0]!.toUpperCase() && /^[A-Z]/.test(name);
29
- }
30
-
31
- /**
32
- * Collect top-level exported component bindings from a module.
33
- */
34
- function collectExportedComponents(
35
- code: string,
36
- filename: string,
37
- ): ExportedComponent[] {
38
- let ast: any;
39
- try {
40
- ast = parse(code, {
41
- sourceType: "module",
42
- plugins: ["jsx", "typescript"],
43
- sourceFilename: filename,
44
- });
45
- } catch {
46
- return [];
47
- }
48
-
49
- const found: ExportedComponent[] = [];
50
- const seen = new Set<string>();
51
- const add = (local: string, key: string) => {
52
- const sig = `${local}::${key}`;
53
- if (seen.has(sig)) return;
54
- seen.add(sig);
55
- found.push({ local, key });
56
- };
57
-
58
- for (const node of ast.program.body as any[]) {
59
- if (node.type === "ExportNamedDeclaration") {
60
- if (node.declaration) {
61
- const decl = node.declaration;
62
- if (
63
- decl.type === "FunctionDeclaration" &&
64
- decl.id &&
65
- isComponentName(decl.id.name)
66
- ) {
67
- add(decl.id.name, decl.id.name);
68
- } else if (decl.type === "VariableDeclaration") {
69
- for (const d of decl.declarations) {
70
- if (d.id?.type === "Identifier" && isComponentName(d.id.name)) {
71
- add(d.id.name, d.id.name);
72
- }
73
- }
74
- }
75
- } else if (node.specifiers && !node.source) {
76
- // export { A, B as C }
77
- for (const spec of node.specifiers) {
78
- if (
79
- spec.type === "ExportSpecifier" &&
80
- spec.local?.type === "Identifier" &&
81
- spec.exported?.type === "Identifier" &&
82
- isComponentName(spec.exported.name)
83
- ) {
84
- add(spec.local.name, spec.exported.name);
85
- }
86
- }
87
- }
88
- } else if (node.type === "ExportDefaultDeclaration") {
89
- const decl = node.declaration;
90
- if (decl.type === "Identifier") {
91
- add(decl.name, "default");
92
- } else if (decl.type === "FunctionDeclaration" && decl.id) {
93
- add(decl.id.name, "default");
94
- }
95
- }
96
- }
97
-
98
- return found;
99
- }
17
+ import { collectExportedComponents } from "sinwan-compiler";
100
18
 
101
19
  /**
102
20
  * Append a Fast Refresh HMR footer to a component module's source.
@@ -120,7 +38,7 @@ export function injectComponentHmr(
120
38
 
121
39
  const footer = `
122
40
 
123
- import { $$sinwanReplace as __$sinwanReplace, $$sinwanRefresh as __$sinwanRefresh } from "sinwan/react-client";
41
+ import { $$sinwanReplace as __$sinwanReplace, $$sinwanRefresh as __$sinwanRefresh } from "sinwan/react";
124
42
  if (import.meta.hot) {
125
43
  import.meta.hot.accept((__m) => {
126
44
  if (!__m) return;
package/src/index.ts CHANGED
@@ -19,7 +19,7 @@ export type SinwanCacheOptions =
19
19
  export interface SinwanOptions {
20
20
  /** Enable template hoisting (default: true) */
21
21
  hoist?: boolean;
22
- /** Emit explicit compiler-driven binding descriptors (Phase 2, default: false). */
22
+ /** Emit explicit compiler-driven binding descriptors (default: true). */
23
23
  explicitBindings?: boolean;
24
24
  /** Path to the reactive-props metadata file produced by `sinwan analyze`. */
25
25
  analyze?: string;
@@ -27,6 +27,8 @@ export interface SinwanOptions {
27
27
  * Enable incremental in-memory cross-file analysis for dev/HMR. When true,
28
28
  * the plugin analyzes each transformed file and passes the current metadata
29
29
  * to the transform without requiring a separate `sinwan analyze` step.
30
+ * Default: true (in-memory only; set to `false` to disable, or pass an object
31
+ * to configure root/paths and persistent cache).
30
32
  */
31
33
  cache?: SinwanCacheOptions;
32
34
  /**
@@ -39,12 +41,16 @@ export interface SinwanOptions {
39
41
  }
40
42
 
41
43
  const DEFAULT_SINWAN_OPTIONS: Required<
42
- Pick<SinwanOptions, "hoist" | "explicitBindings" | "fastRefresh" | "analyze">
44
+ Pick<
45
+ SinwanOptions,
46
+ "hoist" | "explicitBindings" | "fastRefresh" | "analyze" | "cache"
47
+ >
43
48
  > = {
44
49
  hoist: true,
45
50
  explicitBindings: false,
46
51
  fastRefresh: true,
47
52
  analyze: undefined as any,
53
+ cache: true,
48
54
  };
49
55
 
50
56
  /**
@@ -111,8 +117,10 @@ export function sinwan(options: SinwanOptions = {}) {
111
117
  result = transformJSX(code, id, {
112
118
  hoist: opts.hoist,
113
119
  explicitBindings: opts.explicitBindings,
120
+ dev: process.env.NODE_ENV !== "production",
114
121
  analyze: opts.analyze,
115
122
  analyzeMetadata: cache ? cache.reactiveProps : undefined,
123
+ resolveImport: cache ? cache.resolve : undefined,
116
124
  });
117
125
  }
118
126