@uniweb/build 1.3.1 → 1.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/build",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -56,15 +56,15 @@
56
56
  "js-yaml": "^4.1.0",
57
57
  "sharp": "^0.35.3",
58
58
  "yaml": "^2.5.0",
59
- "@uniweb/theming": "~1.2.0",
60
59
  "@uniweb/projections": "~1.1.1",
61
- "@uniweb/content-reader": "~1.3.1",
62
- "@uniweb/semantic-parser": "~1.7.0",
63
- "@uniweb/schemas": "~1.2.1",
64
- "@uniweb/content-writer": "~1.1.1"
60
+ "@uniweb/theming": "~1.2.0",
61
+ "@uniweb/semantic-parser": "~1.8.0",
62
+ "@uniweb/content-writer": "~1.1.2",
63
+ "@uniweb/schemas": "~1.3.0",
64
+ "@uniweb/content-reader": "~1.3.2"
65
65
  },
66
66
  "optionalDependencies": {
67
- "@uniweb/runtime": "~1.1.2"
67
+ "@uniweb/runtime": "~1.1.3"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -73,8 +73,8 @@
73
73
  "@tailwindcss/vite": "^4.0.0",
74
74
  "@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
75
75
  "vite-plugin-svgr": "^4.0.0",
76
- "@uniweb/core": "~1.2.1",
77
- "@uniweb/runtime": "~1.1.2"
76
+ "@uniweb/core": "~1.2.2",
77
+ "@uniweb/runtime": "~1.1.3"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "vite": {
@@ -26,6 +26,7 @@
26
26
  import { resolve } from 'node:path'
27
27
  import { foundationPlugin } from '../vite-foundation-plugin.js'
28
28
  import { jsxExtensionGuard } from '../jsx-extension.js'
29
+ import { nodeEnvDefine } from './node-env.js'
29
30
  import { resolveFoundationSrcDir } from '../utils/foundation-source-root.js'
30
31
  // The ONE definition. This list used to be re-typed here, and again in
31
32
  // vite-foundation-plugin.js — three hand-synced copies of "what a foundation
@@ -36,6 +37,8 @@ import { resolveFoundationSrcDir } from '../utils/foundation-source-root.js'
36
37
  // cycle risk.
37
38
  import { DEFAULT_EXTERNALS } from '../import-map-plugin.js'
38
39
 
40
+ export { nodeEnvDefine }
41
+
39
42
  /**
40
43
  * Create a complete Vite configuration for a Uniweb foundation
41
44
  *
@@ -110,6 +113,7 @@ export async function defineFoundationConfig(options = {}) {
110
113
  foundationPlugin({ srcDir, sections: sectionPaths }),
111
114
  // JSX compiles only in .jsx files: a .js file holding it fails with that said.
112
115
  jsxExtensionGuard(),
116
+ nodeEnvDefine(),
113
117
  tailwind && tailwindcss(),
114
118
  react(),
115
119
  svgr(),
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The `process.env.NODE_ENV` define a foundation build needs — a leaf, so the
3
+ * browser build (`foundation/config.js`) and the SSR twin
4
+ * (`vite-foundation-plugin.js::buildEntrySSR`) share one definition.
5
+ */
6
+
7
+ /**
8
+ * Replace `process.env.NODE_ENV` in the foundation bundle.
9
+ *
10
+ * Library mode replaces `import.meta.env.*` and deliberately leaves
11
+ * `process.env.*` alone, so a bundled CommonJS dependency that branches on
12
+ * `process.env.NODE_ENV` (common in the React ecosystem) ships the read as
13
+ * written — and a browser, which has no `process`, throws
14
+ * `ReferenceError: process is not defined` when the foundation loads, so the
15
+ * site renders nothing. A foundation is a browser module, never a library a
16
+ * consumer re-bundles, so the read is resolved here, from the build's mode.
17
+ *
18
+ * An author's own `define` for the key wins: it is left untouched.
19
+ */
20
+ export function nodeEnvDefine() {
21
+ const KEY = 'process.env.NODE_ENV'
22
+ return {
23
+ name: 'uniweb:foundation-node-env',
24
+ config(config, { mode }) {
25
+ if (config.define && KEY in config.define) return
26
+ const value = mode === 'development' ? 'development' : 'production'
27
+ return { define: { [KEY]: JSON.stringify(value) } }
28
+ }
29
+ }
30
+ }
@@ -460,9 +460,9 @@ function lowerLeaf(field, resolve, optResolve, { multiple = false, path = '' } =
460
460
  if (field.label) out.label = field.label
461
461
  if (field.description) out.description = field.description
462
462
  if (field.required) out.required = true
463
- // A field's rules, as written — `max_length`, `min`, `max`, `mime_types`, `max_size`
464
- // (`FIELD_RULES`): a registry keeps each as the field's own key and checks it on every
465
- // write. ⛔ Until 2026-10-15 the normalizer dropped them before this saw them.
463
+ // A field's rules, as written — `max_length`, `min`, `max`, `mime_types`, `max_size`,
464
+ // `pattern` (`FIELD_RULES`): a registry keeps each as the field's own key and checks it on
465
+ // every write. ⛔ Until 2026-10-15 the normalizer dropped them before this saw them.
466
466
  for (const key of Object.keys(FIELD_RULES)) {
467
467
  if (field[key] !== undefined) out[key] = field[key]
468
468
  }
@@ -17,6 +17,7 @@ import { generateFoundationVars } from './theme/index.js'
17
17
  import { DEFAULT_EXTERNALS } from './import-map-plugin.js'
18
18
  import { deriveSupports } from './foundation/derive-supports.js'
19
19
  import { proseWithoutStyles, PROSE_WITHOUT_STYLES_WARNING } from './foundation/prose-styles.js'
20
+ import { nodeEnvDefine } from './foundation/node-env.js'
20
21
 
21
22
  // Foundations already told that their prose has no stylesheet — once per process, so a dev
22
23
  // server's rebuild on every save does not repeat it.
@@ -347,7 +348,7 @@ async function buildEntrySSR(foundationRoot, entrySourcePath, outDir) {
347
348
  }
348
349
  const react = (await import('@vitejs/plugin-react')).default
349
350
  const svgr = (await import('vite-plugin-svgr')).default
350
- plugins.push(react(), svgr())
351
+ plugins.push(react(), svgr(), nodeEnvDefine())
351
352
 
352
353
  await viteBuild({
353
354
  root: foundationRoot,