@barefootjs/vite 0.31.7 → 0.31.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.
Files changed (2) hide show
  1. package/dist/index.js +9 -2
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -16391,6 +16391,13 @@ function csrInlinableConstantsFromCtx(ctx) {
16391
16391
  }
16392
16392
  return out;
16393
16393
  }
16394
+ function buildTemplateDefPart(ctx, templateHtml) {
16395
+ const envDecls = ctx.signals.filter((s) => Boolean(s.envReader) && Boolean(s.envFactory)).map((s) => `const [${s.getter}] = ${s.envFactory}()`);
16396
+ if (envDecls.length === 0) {
16397
+ return `template: (${PROPS_PARAM}) => \`${templateHtml}\``;
16398
+ }
16399
+ return `template: (${PROPS_PARAM}) => { ${envDecls.join("; ")}; return \`${templateHtml}\` }`;
16400
+ }
16394
16401
  function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
16395
16402
  const name = ctx.componentName;
16396
16403
  lines.push(`}`);
@@ -16407,13 +16414,13 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
16407
16414
  if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
16408
16415
  const templateHtml = irToComponentTemplate(_ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName);
16409
16416
  if (templateHtml) {
16410
- defParts.push(`template: (${PROPS_PARAM}) => \`${templateHtml}\``);
16417
+ defParts.push(buildTemplateDefPart(ctx, templateHtml));
16411
16418
  }
16412
16419
  } else {
16413
16420
  const csrInlinableConstants = csrInlinableConstantsFromCtx(ctx);
16414
16421
  const templateHtml = generateCsrTemplate(_ir.root, csrInlinableConstants, ctx, restSpreadNames, ctx.propsObjectName, unsafeLocalNames, ctx.deferredChildSlots);
16415
16422
  if (templateHtml) {
16416
- defParts.push(`template: (${PROPS_PARAM}) => \`${templateHtml}\``);
16423
+ defParts.push(buildTemplateDefPart(ctx, templateHtml));
16417
16424
  }
16418
16425
  }
16419
16426
  if (isCommentScope) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/vite",
3
- "version": "0.31.7",
3
+ "version": "0.31.8",
4
4
  "description": "Vite plugin for BarefootJS: Vite/Rollup owns bundling, hashing, chunking, tree-shaking and minification of client assets, BarefootJS keeps only the JSX to (template, client JS) compile",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,17 +38,17 @@
38
38
  "directory": "packages/vite"
39
39
  },
40
40
  "dependencies": {
41
- "@barefootjs/shared": "0.31.7"
41
+ "@barefootjs/shared": "0.31.8"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@barefootjs/jsx": ">=0.2.0",
45
45
  "vite": "^6.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@barefootjs/client": "0.31.7",
49
- "@barefootjs/go-template": "0.31.7",
50
- "@barefootjs/hono": "0.31.7",
51
- "@barefootjs/jsx": "0.31.7",
48
+ "@barefootjs/client": "0.31.8",
49
+ "@barefootjs/go-template": "0.31.8",
50
+ "@barefootjs/hono": "0.31.8",
51
+ "@barefootjs/jsx": "0.31.8",
52
52
  "typescript": "^5.0.0",
53
53
  "vite": "^6.0.0"
54
54
  }