@opentf/afw-cli 1.39.0 → 1.40.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.
package/README.md CHANGED
@@ -27,8 +27,8 @@
27
27
  ],
28
28
  "build": {
29
29
  "targets": {
30
- "web": { "entry": "index.html", "outdir": "dist" },
31
- "site-ssg": { "entry": "ssg.js", "out": ".ssg/ssg.js", "then": "run" }
30
+ "web": { "entry": "index.html", "outDir": "dist" },
31
+ "site-ssg": { "entry": "ssg.js", "out": "dist/ssg.js", "then": "run" }
32
32
  }
33
33
  }
34
34
  }
@@ -36,7 +36,8 @@
36
36
 
37
37
  `esdev build` bundles the site, then runs `ssg.js`, which prerenders every route
38
38
  into the staged output. Only when every step succeeds does the new site replace the
39
- old one.
39
+ old one. esdev 0.29 and later remove the step's own bundle (`dist/ssg.js`) once it
40
+ has run, so it is never deployed.
40
41
 
41
42
  > [!NOTE]
42
43
  > **Alpha.** The package keeps its historical name; the old `afw` executable and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentf/afw-cli",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "Static generation for AFW apps, run as an esdev build step.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -16,11 +16,11 @@
16
16
  "esdev": ">=0.16.0"
17
17
  },
18
18
  "dependencies": {
19
- "@opentf/afw-build": "0.7.0",
20
- "@opentf/esdev-plugin-afw": "0.11.1"
19
+ "@opentf/afw-build": "0.8.0",
20
+ "@opentf/esdev-plugin-afw": "0.12.0"
21
21
  },
22
22
  "peerDependencies": {
23
- "@opentf/afw": "0.40.0"
23
+ "@opentf/afw": "0.41.0"
24
24
  },
25
25
  "keywords": [
26
26
  "afw",
package/src/shared.js CHANGED
@@ -433,6 +433,7 @@ export async function emitApiBundle({ root, appDir, afwEntry, exclude, i18n, out
433
433
  platform: "node",
434
434
  resolve: { alias: await afwAliases(afwEntry), extensions: EXTENSIONS },
435
435
  external: (id) => !id.startsWith(".") && !id.startsWith("/") && !id.startsWith("@opentf/afw"),
436
+ ...ENV_COMPILE(root),
436
437
  });
437
438
  try {
438
439
  await bundle.write({ dir: outDir, format: "esm", entryFileNames: "api.js" });
@@ -443,6 +444,14 @@ export async function emitApiBundle({ root, appDir, afwEntry, exclude, i18n, out
443
444
  return { routes: discovered.routes, middleware: discovered.middleware };
444
445
  }
445
446
 
447
+ /**
448
+ * `import.meta.env` for a server bundle, as `esdev build` compiles it into the browser one:
449
+ * `MODE`, `DEV`, `PROD` and the `PUBLIC_*` values from the project's `.env`, then the
450
+ * environment (`runtime:build`'s `mode`). `cwd` is the project root: the build's default is
451
+ * the entry's own directory, a temporary one here. Other variables are never compiled in.
452
+ */
453
+ const ENV_COMPILE = (root) => ({ mode: "production", cwd: root });
454
+
446
455
  /**
447
456
  * Entry source for the loader bundle (docs/DATA.md): statically import every
448
457
  * `loader.{js,ts}` module (keyed by absolute path so the registry derives each
@@ -486,6 +495,7 @@ export async function emitLoaderBundle({ root, appDir, afwEntry, exclude, i18n,
486
495
  platform: "node",
487
496
  resolve: { alias: await afwAliases(afwEntry), extensions: EXTENSIONS },
488
497
  external: (id) => !id.startsWith(".") && !id.startsWith("/") && !id.startsWith("@opentf/afw"),
498
+ ...ENV_COMPILE(root),
489
499
  });
490
500
  try {
491
501
  await bundle.write({ dir: outDir, format: "esm", entryFileNames: "loaders.js" });
@@ -602,6 +612,7 @@ export async function buildServerBundle({
602
612
  // no `process` global here to read it at runtime — so it has to be folded away at
603
613
  // bundle time. Server render is a production render.
604
614
  define: { "process.env.NODE_ENV": '"production"' },
615
+ ...ENV_COMPILE(root),
605
616
  plugins: [
606
617
  ...docsPlugins,
607
618
  afwPlugin(afwc, { failOnError: true, target: "ssg", quiet, onResult: (id) => onCompile?.(id) }),