@uniweb/build 1.12.2 → 1.13.1

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.12.2",
3
+ "version": "1.13.1",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -57,14 +57,14 @@
57
57
  "sharp": "^0.35.5",
58
58
  "yaml": "^2.5.0",
59
59
  "@uniweb/content-reader": "~1.5.7",
60
+ "@uniweb/content-writer": "~1.3.1",
60
61
  "@uniweb/schemas": "~1.6.7",
61
- "@uniweb/theming": "~1.2.1",
62
62
  "@uniweb/projections": "~1.2.8",
63
63
  "@uniweb/semantic-parser": "~1.13.0",
64
- "@uniweb/content-writer": "~1.3.1"
64
+ "@uniweb/theming": "~1.2.1"
65
65
  },
66
66
  "optionalDependencies": {
67
- "@uniweb/runtime": "~1.2.14"
67
+ "@uniweb/runtime": "~1.3.2"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -73,7 +73,7 @@
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/runtime": "~1.2.14",
76
+ "@uniweb/runtime": "~1.3.2",
77
77
  "@uniweb/core": "~1.5.0"
78
78
  },
79
79
  "peerDependenciesMeta": {
@@ -0,0 +1,49 @@
1
+ import { hasDevRebuildMarker } from './dev-rebuild.js'
2
+
3
+ /**
4
+ * A foundation's built code has no whitespace or comments in it.
5
+ *
6
+ * Vite minifies a library's names and syntax but keeps its whitespace and comments, on purpose: a
7
+ * library is read by the next bundler, which needs its `@__PURE__` annotations. A foundation has no
8
+ * next bundler. A browser loads `entry.js` and a request-time host loads `entry-ssr.js` as they are,
9
+ * and a site that bundles its foundation builds it from source. So all that text went to every
10
+ * visitor: 130 KB of a 345 KB entry, on a real foundation (measured 2026-10-30).
11
+ *
12
+ * Legal comments stay, as they do in anything else Vite minifies.
13
+ *
14
+ * ⛔ `order: 'post'` on the hook, not `enforce: 'post'` on the plugin. Vite's own esbuild pass runs
15
+ * after every plugin, `enforce: 'post'` included, and it prints the whitespace back.
16
+ *
17
+ * A dev rebuild (`dev-rebuild.js`) is left readable, and keeps the reference to its map for the
18
+ * browser's devtools. A build that ships has no use for the reference: `register` uploads no maps,
19
+ * so it would name a file that is not there.
20
+ */
21
+ export function compactOutput() {
22
+ let compact = false
23
+ return {
24
+ name: 'uniweb:foundation-compact-output',
25
+ apply: 'build',
26
+ config(config) {
27
+ if (hasDevRebuildMarker(config) && config.build?.sourcemap === 'hidden') {
28
+ return { build: { sourcemap: true } }
29
+ }
30
+ },
31
+ configResolved(config) {
32
+ compact = config.build.minify !== false && !hasDevRebuildMarker(config)
33
+ },
34
+ renderChunk: {
35
+ order: 'post',
36
+ async handler(code, chunk, output) {
37
+ if (!compact) return null
38
+ const { transformWithEsbuild } = await import('vite')
39
+ const result = await transformWithEsbuild(code, chunk.fileName, {
40
+ loader: 'js',
41
+ charset: 'utf8',
42
+ minifyWhitespace: true,
43
+ sourcemap: Boolean(output.sourcemap),
44
+ })
45
+ return { code: result.code, map: result.map }
46
+ },
47
+ },
48
+ }
49
+ }
@@ -28,6 +28,7 @@ import { foundationPlugin } from '../vite-foundation-plugin.js'
28
28
  import { jsxExtensionGuard } from '../jsx-extension.js'
29
29
  import { nodeEnvDefine } from './node-env.js'
30
30
  import { foundationScopeDefine } from './scope-define.js'
31
+ import { compactOutput } from './compact-output.js'
31
32
  import { resolveFoundationSrcDir } from '../utils/foundation-source-root.js'
32
33
  // The ONE definition. This list used to be re-typed here, and again in
33
34
  // vite-foundation-plugin.js — three hand-synced copies of "what a foundation
@@ -53,7 +54,8 @@ export { nodeEnvDefine }
53
54
  * @param {boolean} [options.includeDefaultExternals] - Include default externals (default: true)
54
55
  * @param {Array} [options.plugins] - Additional Vite plugins
55
56
  * @param {boolean} [options.tailwind] - Include Tailwind CSS v4 plugin (default: true)
56
- * @param {boolean} [options.sourcemap] - Generate sourcemaps (default: true)
57
+ * @param {boolean|'hidden'} [options.sourcemap] - Generate sourcemaps (default: 'hidden', maps
58
+ * beside the code and no reference to them in it)
57
59
  * @param {Object} [options.build] - Additional build options to merge
58
60
  * @param {Object} [options.experimental] - Vite experimental options to merge
59
61
  * @returns {Promise<Object>} Vite configuration
@@ -75,7 +77,7 @@ export async function defineFoundationConfig(options = {}) {
75
77
  includeDefaultExternals = true,
76
78
  plugins: extraPlugins = [],
77
79
  tailwind = true,
78
- sourcemap = true,
80
+ sourcemap = 'hidden',
79
81
  build: buildOverrides = {},
80
82
  experimental: experimentalOverrides = {},
81
83
  ...restOptions
@@ -119,6 +121,7 @@ export async function defineFoundationConfig(options = {}) {
119
121
  nodeEnvDefine(),
120
122
  // `__FOUNDATION_SCOPE__` — the scope the foundation's own `@/x` names (`scope-define.js`).
121
123
  foundationScopeDefine({ foundationDir: foundationRoot }),
124
+ compactOutput(),
122
125
  tailwind && tailwindcss(),
123
126
  react(),
124
127
  svgr(),
@@ -168,7 +168,7 @@ export async function buildSiteData({
168
168
  // ⛔ `config.icons` is a HOST-owned slot on this lane — drop it.
169
169
  //
170
170
  // This is the build for a backend (link mode is what `uniweb publish` runs),
171
- // and `config` is site.yml spread whole, so an author's `icons.cdnUrl` would
171
+ // and `config` is site.yml spread whole, so an author's `icons.base` would
172
172
  // otherwise sit in a slot the host is supposed to fill. The icon base is a
173
173
  // property of the DEPLOYMENT, identical for every site a given backend
174
174
  // serves — not something one site gets to choose [Diego, 2026-08-17].
@@ -31,7 +31,7 @@ import { existsSync, statSync, realpathSync, readdirSync } from 'node:fs'
31
31
  import yaml from 'js-yaml'
32
32
  import { YAML_OPTIONS } from '../utils/yaml-schema.js'
33
33
  import { collectSectionAssets, mergeAssetCollections, collectConfigAssets, disambiguateAssetRefs } from './assets.js'
34
- import { collectSectionIcons, mergeIconCollections, buildIconManifest } from './icons.js'
34
+ import { collectSectionIcons, mergeIconCollections, buildIconManifest, refuseRetiredIconKey } from './icons.js'
35
35
  import { normalizeHideIn, dropUnpublishedPages, dropHiddenSections } from './nav-visibility.js'
36
36
  import { parseFetchConfig, toFetchList } from './data-fetcher.js'
37
37
  import { resolveExtensionUrls } from './extension-urls.js'
@@ -2579,6 +2579,7 @@ export async function collectSiteContent(sitePath, options = {}) {
2579
2579
  // for a placement its type does not offer is told (`./placement-warnings.js`).
2580
2580
  sectionTypes = await foundationSections(sitePath, siteConfig)
2581
2581
  refuseRetiredServiceKeys(siteConfig, configFile)
2582
+ refuseRetiredIconKey(siteConfig, configFile)
2582
2583
  refuseUnreadableAddress(siteConfig, configFile)
2583
2584
  refuseUnreadableServices(siteConfig, configFile)
2584
2585
 
package/src/site/icons.js CHANGED
@@ -60,6 +60,18 @@ function normalizeLibrary(library) {
60
60
  return FAMILY_MAP[library?.toLowerCase()] || library?.toLowerCase() || null
61
61
  }
62
62
 
63
+ /**
64
+ * `icons.cdnUrl` is now `icons.base`, the name a host states it under. The runtime reads only that,
65
+ * so a file still writing the old one would quietly load its icons from the default origin.
66
+ *
67
+ * @param {Object} siteYml
68
+ * @param {string} [where]
69
+ */
70
+ export function refuseRetiredIconKey(siteYml, where = 'site.yml') {
71
+ if (siteYml?.icons?.cdnUrl === undefined) return
72
+ throw new Error(`[uniweb] ${where}: \`icons.cdnUrl\` is now \`icons.base\`. Rename the key; its value stays.`)
73
+ }
74
+
63
75
  /**
64
76
  * Walk a ProseMirror document and collect icon references
65
77
  *
@@ -20,6 +20,7 @@ import { proseWithoutStyles, PROSE_WITHOUT_STYLES_WARNING } from './foundation/p
20
20
  import { nodeEnvDefine } from './foundation/node-env.js'
21
21
  import { foundationScopeDefine } from './foundation/scope-define.js'
22
22
  import { ssrDormantDynamicImports } from './foundation/ssr-dormant-imports.js'
23
+ import { compactOutput } from './foundation/compact-output.js'
23
24
  import { DEV_REBUILD_MARKER, hasDevRebuildMarker } from './foundation/dev-rebuild.js'
24
25
 
25
26
  // Foundations already told that their prose has no stylesheet — once per process, so a dev
@@ -356,7 +357,7 @@ async function buildEntrySSR(foundationRoot, entrySourcePath, outDir) {
356
357
  const svgr = (await import('vite-plugin-svgr')).default
357
358
  // ssrDormantDynamicImports: a package imported dynamically stays `import('pkg')`, dormant,
358
359
  // rather than folded in to run at load (see its module).
359
- plugins.push(react(), svgr(), nodeEnvDefine(), foundationScopeDefine({ foundationDir: foundationRoot }), ssrDormantDynamicImports())
360
+ plugins.push(react(), svgr(), nodeEnvDefine(), foundationScopeDefine({ foundationDir: foundationRoot }), ssrDormantDynamicImports(), compactOutput())
360
361
 
361
362
  await viteBuild({
362
363
  root: foundationRoot,