@pyreon/vite-plugin 0.16.0 → 0.18.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.
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
5386
5386
  </script>
5387
5387
  <script>
5388
5388
  /*<!--*/
5389
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src/index.ts","uid":"8d2ce63a-1"}]}],"isRoot":true},"nodeParts":{"8d2ce63a-1":{"renderedLength":28850,"gzipLength":9498,"brotliLength":0,"metaUid":"8d2ce63a-0"}},"nodeMetas":{"8d2ce63a-0":{"id":"/src/index.ts","moduleParts":{"index.js":"8d2ce63a-1"},"imported":[{"uid":"8d2ce63a-2"},{"uid":"8d2ce63a-3"},{"uid":"8d2ce63a-4"}],"importedBy":[],"isEntry":true},"8d2ce63a-2":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"8d2ce63a-0"}]},"8d2ce63a-3":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"8d2ce63a-0"}]},"8d2ce63a-4":{"id":"@pyreon/compiler","moduleParts":{},"imported":[],"importedBy":[{"uid":"8d2ce63a-0"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5389
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src/index.ts","uid":"9860678c-1"}]}],"isRoot":true},"nodeParts":{"9860678c-1":{"renderedLength":29090,"gzipLength":9553,"brotliLength":0,"metaUid":"9860678c-0"}},"nodeMetas":{"9860678c-0":{"id":"/src/index.ts","moduleParts":{"index.js":"9860678c-1"},"imported":[{"uid":"9860678c-2"},{"uid":"9860678c-3"},{"uid":"9860678c-4"}],"importedBy":[],"isEntry":true},"9860678c-2":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"9860678c-0"}]},"9860678c-3":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"9860678c-0"}]},"9860678c-4":{"id":"@pyreon/compiler","moduleParts":{},"imported":[],"importedBy":[{"uid":"9860678c-0"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5390
5390
 
5391
5391
  const run = () => {
5392
5392
  const width = window.innerWidth;
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
- import { generateContext, transformJSX } from "@pyreon/compiler";
3
+ import { generateContext, transformDeferInline, transformJSX } from "@pyreon/compiler";
4
4
 
5
5
  //#region src/index.ts
6
6
  /**
@@ -222,8 +222,11 @@ function pyreonPlugin(options) {
222
222
  }
223
223
  scanSignalExports(code, normalizeModuleId(id), signalExportRegistry);
224
224
  if (islandsEnabled) scanIslandDeclarations(code, id, islandRegistry);
225
- const knownSignals = await resolveImportedSignals(code, id, signalExportRegistry, this, resolveCache);
226
- const result = transformJSX(code, id, {
225
+ const deferResult = transformDeferInline(code, id);
226
+ const sourceForJsx = deferResult.changed ? deferResult.code : code;
227
+ for (const w of deferResult.warnings) this.warn(`${w.message} (${id}:${w.line}:${w.column})`);
228
+ const knownSignals = await resolveImportedSignals(sourceForJsx, id, signalExportRegistry, this, resolveCache);
229
+ const result = transformJSX(sourceForJsx, id, {
227
230
  ssr: transformOptions?.ssr === true,
228
231
  knownSignals
229
232
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/vite-plugin",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Vite plugin for Pyreon — .pyreon SFC support, HMR, compiler integration",
5
5
  "homepage": "https://github.com/pyreon/pyreon/tree/main/packages/vite-plugin#readme",
6
6
  "bugs": {
@@ -43,7 +43,7 @@
43
43
  "prepublishOnly": "bun run build"
44
44
  },
45
45
  "dependencies": {
46
- "@pyreon/compiler": "^0.16.0"
46
+ "@pyreon/compiler": "^0.18.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "vite": "^8.0.0"
package/src/index.ts CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
36
36
  import { dirname, join as pathJoin } from 'node:path'
37
- import { generateContext, transformJSX } from '@pyreon/compiler'
37
+ import { generateContext, transformDeferInline, transformJSX } from '@pyreon/compiler'
38
38
  import type { Plugin, ViteDevServer } from 'vite'
39
39
 
40
40
  // Virtual module ID for the HMR runtime
@@ -429,16 +429,31 @@ export default function pyreonPlugin(options?: PyreonPluginOptions): Plugin {
429
429
  // next dev-server module reload.
430
430
  if (islandsEnabled) scanIslandDeclarations(code, id, islandRegistry)
431
431
 
432
+ // ── Inline-Defer pre-pass ──────────────────────────────────────────
433
+ // Rewrites `<Defer when={x}><Modal /></Defer>` into the explicit
434
+ // chunk-prop form so Rolldown emits a proper per-Defer chunk and
435
+ // the main bundle drops the static `import { Modal } from ...`
436
+ // when it's exclusively used inside this Defer's subtree. Runs
437
+ // BEFORE the JSX→runtime transform so the downstream pipeline
438
+ // sees an already-explicit `<Defer chunk={...}>` shape with no
439
+ // special-casing needed in `transformJSX`. See
440
+ // `@pyreon/compiler/defer-inline` for the rewrite contract.
441
+ const deferResult = transformDeferInline(code, id)
442
+ const sourceForJsx = deferResult.changed ? deferResult.code : code
443
+ for (const w of deferResult.warnings) {
444
+ this.warn(`${w.message} (${id}:${w.line}:${w.column})`)
445
+ }
446
+
432
447
  // ── Resolve imported signals from the registry ─────────────────────
433
448
  // Check each import in this file: if the imported module has signal
434
449
  // exports in the registry, pass them as knownSignals to the compiler.
435
- const knownSignals = await resolveImportedSignals(code, id, signalExportRegistry, this, resolveCache)
450
+ const knownSignals = await resolveImportedSignals(sourceForJsx, id, signalExportRegistry, this, resolveCache)
436
451
 
437
452
  // Vite passes `ssr: true` when transforming for the SSR module graph
438
453
  // (both build --ssr and dev `ssrLoadModule`). The compiler emits plain
439
454
  // `h()` calls in that mode so `runtime-server` can render to a string.
440
455
  const isSsr = transformOptions?.ssr === true
441
- const result = transformJSX(code, id, { ssr: isSsr, knownSignals })
456
+ const result = transformJSX(sourceForJsx, id, { ssr: isSsr, knownSignals })
442
457
  // Surface compiler warnings in the terminal
443
458
  for (const w of result.warnings) {
444
459
  this.warn(`${w.message} (${id}:${w.line}:${w.column})`)