@ogygia/compiler 0.0.0 → 0.14.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.
Files changed (160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -1
  3. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  4. package/dist/app-spec.d.ts +18 -0
  5. package/dist/app-spec.js +22 -0
  6. package/dist/blank-styles.d.ts +1 -0
  7. package/dist/blank-styles.js +24 -0
  8. package/dist/bom.d.ts +2 -0
  9. package/dist/bom.js +7 -0
  10. package/dist/build-cache.d.ts +13 -0
  11. package/dist/build-cache.js +65 -0
  12. package/dist/ctx.d.ts +238 -0
  13. package/dist/ctx.js +221 -0
  14. package/dist/dev/css-scope.d.ts +16 -0
  15. package/dist/dev/css-scope.js +32 -0
  16. package/dist/dev/dev-hmr.d.ts +24 -0
  17. package/dist/dev/dev-hmr.js +51 -0
  18. package/dist/dev/hmr.d.ts +34 -0
  19. package/dist/dev/hmr.js +52 -0
  20. package/dist/driver.d.ts +351 -0
  21. package/dist/driver.js +1402 -0
  22. package/dist/exports/index.d.ts +77 -0
  23. package/dist/exports/index.js +349 -0
  24. package/dist/exports/parse.d.ts +65 -0
  25. package/dist/exports/parse.js +251 -0
  26. package/dist/fouc-css.d.ts +112 -0
  27. package/dist/fouc-css.js +314 -0
  28. package/dist/free-vars.d.ts +32 -0
  29. package/dist/free-vars.js +454 -0
  30. package/dist/fs.d.ts +31 -0
  31. package/dist/fs.js +82 -0
  32. package/dist/ids.d.ts +49 -0
  33. package/dist/ids.js +52 -0
  34. package/dist/index.d.ts +23 -0
  35. package/dist/index.js +23 -0
  36. package/dist/kit.d.ts +204 -0
  37. package/dist/kit.js +554 -0
  38. package/dist/leg.d.ts +34 -0
  39. package/dist/leg.js +26 -0
  40. package/dist/link/analyses.d.ts +26 -0
  41. package/dist/link/analyses.js +237 -0
  42. package/dist/link/build-output.d.ts +47 -0
  43. package/dist/link/build-output.js +168 -0
  44. package/dist/link/caps.d.ts +32 -0
  45. package/dist/link/caps.js +39 -0
  46. package/dist/link/context-detect.d.ts +28 -0
  47. package/dist/link/context-detect.js +143 -0
  48. package/dist/link/emit-gate.d.ts +43 -0
  49. package/dist/link/emit-gate.js +55 -0
  50. package/dist/link/file-token.d.ts +11 -0
  51. package/dist/link/file-token.js +15 -0
  52. package/dist/link/island-deps.d.ts +183 -0
  53. package/dist/link/island-deps.js +802 -0
  54. package/dist/link/location-map.d.ts +24 -0
  55. package/dist/link/location-map.js +51 -0
  56. package/dist/link/own-reach.d.ts +15 -0
  57. package/dist/link/own-reach.js +188 -0
  58. package/dist/link/registry-stub.d.ts +50 -0
  59. package/dist/link/registry-stub.js +163 -0
  60. package/dist/link/relocations.d.ts +79 -0
  61. package/dist/link/relocations.js +204 -0
  62. package/dist/link/router-css.d.ts +38 -0
  63. package/dist/link/router-css.js +124 -0
  64. package/dist/link/runtime-entry.d.ts +103 -0
  65. package/dist/link/runtime-entry.js +183 -0
  66. package/dist/link/server-manifest.d.ts +25 -0
  67. package/dist/link/server-manifest.js +102 -0
  68. package/dist/link/transport.d.ts +42 -0
  69. package/dist/link/transport.js +91 -0
  70. package/dist/macros/dollar.d.ts +24 -0
  71. package/dist/macros/dollar.js +397 -0
  72. package/dist/macros/pipeline.d.ts +50 -0
  73. package/dist/macros/pipeline.js +133 -0
  74. package/dist/macros/source.d.ts +9 -0
  75. package/dist/macros/source.js +115 -0
  76. package/dist/macros/store.d.ts +22 -0
  77. package/dist/macros/store.js +217 -0
  78. package/dist/macros/wire.d.ts +17 -0
  79. package/dist/macros/wire.js +116 -0
  80. package/dist/map-chain.d.ts +18 -0
  81. package/dist/map-chain.js +42 -0
  82. package/dist/messages.d.ts +673 -0
  83. package/dist/messages.js +938 -0
  84. package/dist/ownership-stamps.d.ts +11 -0
  85. package/dist/ownership-stamps.js +112 -0
  86. package/dist/parse/oxc.d.ts +36 -0
  87. package/dist/parse/oxc.js +35 -0
  88. package/dist/parse/roots.d.ts +4 -0
  89. package/dist/parse/roots.js +27 -0
  90. package/dist/parse/scan.d.ts +65 -0
  91. package/dist/parse/scan.js +297 -0
  92. package/dist/parse/svelte-ast.d.ts +7 -0
  93. package/dist/parse/svelte-ast.js +99 -0
  94. package/dist/program.d.ts +140 -0
  95. package/dist/program.js +304 -0
  96. package/dist/queries.d.ts +105 -0
  97. package/dist/queries.js +326 -0
  98. package/dist/region/emit.d.ts +168 -0
  99. package/dist/region/emit.js +292 -0
  100. package/dist/region/identity.d.ts +32 -0
  101. package/dist/region/identity.js +46 -0
  102. package/dist/region/ir.d.ts +56 -0
  103. package/dist/region/ir.js +0 -0
  104. package/dist/region/marked-imports.d.ts +27 -0
  105. package/dist/region/marked-imports.js +265 -0
  106. package/dist/region/transform.d.ts +189 -0
  107. package/dist/region/transform.js +1565 -0
  108. package/dist/scan-facts.d.ts +36 -0
  109. package/dist/scan-facts.js +54 -0
  110. package/dist/script-request.d.ts +1 -0
  111. package/dist/script-request.js +33 -0
  112. package/dist/splice.d.ts +11 -0
  113. package/dist/splice.js +33 -0
  114. package/dist/transportables.d.ts +23 -0
  115. package/dist/transportables.js +144 -0
  116. package/dist/virtual/core.d.ts +158 -0
  117. package/dist/virtual/core.js +588 -0
  118. package/dist/virtual/resolver.d.ts +62 -0
  119. package/dist/virtual/resolver.js +265 -0
  120. package/dist/virtual/specifier.d.ts +10 -0
  121. package/dist/virtual/specifier.js +6 -0
  122. package/dist/virtual/table.d.ts +120 -0
  123. package/dist/virtual/table.js +54 -0
  124. package/dist/virtual/types.d.ts +17 -0
  125. package/dist/virtual/types.js +100 -0
  126. package/dist/virtual/value-names.d.ts +2 -0
  127. package/dist/virtual/value-names.js +18 -0
  128. package/dist/vite/definers.d.ts +16 -0
  129. package/dist/vite/definers.js +69 -0
  130. package/dist/vite/dev-maps.d.ts +34 -0
  131. package/dist/vite/dev-maps.js +91 -0
  132. package/dist/vite/index.d.ts +21 -0
  133. package/dist/vite/index.js +890 -0
  134. package/dist/vite/kit-dirs.d.ts +6 -0
  135. package/dist/vite/kit-dirs.js +53 -0
  136. package/dist/vite/late-island.d.ts +8 -0
  137. package/dist/vite/late-island.js +18 -0
  138. package/dist/vite/lazy-files.d.ts +2 -0
  139. package/dist/vite/lazy-files.js +72 -0
  140. package/dist/vite/options.d.ts +195 -0
  141. package/dist/vite/options.js +72 -0
  142. package/dist/vite/package-files.d.ts +3 -0
  143. package/dist/vite/package-files.js +88 -0
  144. package/dist/vite/paths.d.ts +16 -0
  145. package/dist/vite/paths.js +39 -0
  146. package/dist/vite/plugin-api.d.ts +316 -0
  147. package/dist/vite/plugin-api.js +328 -0
  148. package/dist/vite/route-watch.d.ts +15 -0
  149. package/dist/vite/route-watch.js +32 -0
  150. package/dist/vite/session.d.ts +28 -0
  151. package/dist/vite/session.js +43 -0
  152. package/dist/vite/sourcemaps.d.ts +19 -0
  153. package/dist/vite/sourcemaps.js +75 -0
  154. package/dist/vite/style-preprocess.d.ts +2 -0
  155. package/dist/vite/style-preprocess.js +84 -0
  156. package/dist/vite/svelte-entries.d.ts +4 -0
  157. package/dist/vite/svelte-entries.js +10 -0
  158. package/dist/vite/svelte-options.d.ts +20 -0
  159. package/dist/vite/svelte-options.js +22 -0
  160. package/package.json +87 -12
@@ -0,0 +1,938 @@
1
+ import { define_messages, prose } from "@ogygia/core/contract";
2
+ // src/messages.ts
3
+ const BUG = "An ogygia bug: please report it with the file that shows it.";
4
+ /** The errors: `throw new OgygiaError(code, args)`. */
5
+ const BUILD_ERRORS = {
6
+ macro_store_misuse: {
7
+ text: (a) => prose`
8
+ ${a.file}:${a.line} — ${a.problem}. import.meta.og.store is legal in exactly one shape: a
9
+ direct call wrapping a store factory — import.meta.og.store((seed) => ({ subscribe, … })).
10
+ It registers the factory under a build tag so islands rebuild the store THROUGH it (custom
11
+ methods survive); the factory's first parameter is the seed value.
12
+ `,
13
+ details: () => prose`
14
+ \`import.meta.og.store\` is a compile-time mark, not a value: it only works as a direct
15
+ call around a store factory, \`import.meta.og.store((seed) => writable(seed))\`. The
16
+ build registers that factory so an island rebuilds the store through it, custom methods
17
+ and all.
18
+
19
+ \`problem\` names what was written instead (no argument, two arguments, a bare
20
+ reference). Wrap the factory itself in one call.
21
+ `
22
+ },
23
+ macro_dollar_misuse: {
24
+ text: (a) => prose`
25
+ ${a.file}:${a.line} — ${a.problem}. import.meta.og.$ is legal in exactly one shape: a
26
+ direct call wrapping an inline function — import.meta.og.$((args) => { … }). It hoists
27
+ that function so its VALUE can cross an island boundary as a handle.
28
+ `,
29
+ details: () => prose`
30
+ \`import.meta.og.$\` hoists a function into its own module so a handle to it can cross an
31
+ island boundary. The build has to see the function itself, so the mark only works as a
32
+ direct call around an inline function: \`import.meta.og.$((args) => ...)\`.
33
+
34
+ \`problem\` names what was written instead. Pass the function inline, as the one argument.
35
+ `
36
+ },
37
+ macro_wire_misuse: {
38
+ text: (a) => prose`
39
+ ${a.file}:${a.line} — ${a.problem}. import.meta.og.wire is legal in exactly one position:
40
+ \`static wire = import.meta.og.wire({ encode, decode })\` inside a class body. The macro
41
+ consumes that member and mints the symbol key; the construct is not a value.
42
+ `,
43
+ details: () => prose`
44
+ \`import.meta.og.wire\` makes a class transportable across an island boundary. The build
45
+ replaces the member that holds it, so it only works in one place: a static member of a
46
+ class, \`static wire = import.meta.og.wire(codec)\`, where the codec has \`encode\` and
47
+ \`decode\`.
48
+
49
+ \`problem\` names what was written instead. Move the call into that member.
50
+ `
51
+ },
52
+ wire_class_anonymous: {
53
+ text: (a) => prose`
54
+ ${a.file}:${a.line} — an anonymous \`export default class\` has a wire codec. Give the
55
+ class a name (\`export default class Cart\`) so the build can register it.
56
+ `,
57
+ details: () => prose`
58
+ A class with a wire codec is registered while its module compiles: the build appends a
59
+ call that hands the class to ogygia, tagged by its module and export name. An anonymous
60
+ \`export default class { … }\` has no binding that call can name, so its instances could
61
+ not cross into an island. Name the class; the export stays the default one.
62
+ `
63
+ },
64
+ macro_source_misuse: {
65
+ text: (a) => prose`
66
+ ${a.file}:${a.line} — ${a.problem}. import.meta.og.source is legal in exactly one
67
+ position: \`export const <name> = import.meta.og.source(fn)\` (optionally
68
+ \`(fn, { key })\`) at module top level. The compiler stamps the source id from that
69
+ export's identity.
70
+ `,
71
+ details: () => prose`
72
+ \`import.meta.og.source\` declares a data source. Its id is the file and export name it is
73
+ declared under, so the build only accepts it as the initializer of a top-level
74
+ \`export const\`: \`export const loadThing = import.meta.og.source(fn)\`.
75
+
76
+ \`problem\` names what was written instead. Declare the source as its own exported
77
+ constant.
78
+ `
79
+ },
80
+ macro_outside_app: {
81
+ text: (a) => `${a.file} — import.meta.og.${a.macro}() is used in an installed package that does not declare this file in "ogygia.files".`,
82
+ details: () => prose`
83
+ The \`import.meta.og.*\` macros (\`bake\` runs code at build time) work in the app's own
84
+ source, and in the files a package lists under \`"ogygia.files"\` in its package.json.
85
+ An installed file outside that list that uses one fails the build, and nothing in it
86
+ runs. If the package is meant to ship ogygia code, add the file (or a glob for it) to
87
+ that package's \`"ogygia.files"\`; otherwise it should not use the macro.
88
+ `
89
+ },
90
+ macro_needs_plugin: {
91
+ text: (a) => `${a.file} — import.meta.og.${a.macro}() needs the \`${a.plugin}\` plugin from \`${a.package}\`, listed beside ogygia().`,
92
+ details: () => prose`
93
+ This \`import.meta.og.*\` macro is compiled by a plugin, and that plugin is not in the
94
+ app's Vite plugins. Without it the call would reach the browser or the server as is, and
95
+ fail there. Install the package and list its plugin beside \`ogygia()\` in vite.config
96
+ \`plugins\` (before \`sveltekit()\`).
97
+ `
98
+ },
99
+ kit_config_not_literal: {
100
+ text: (a) => `${a.file}: \`config.${a.key}\` must be a literal (true, false, a number, a string or null) — ogygia reads it at build time.`,
101
+ details: () => prose`
102
+ ogygia reads some keys of a route's \`export const config\` while it builds, from the
103
+ source. This one is an expression (a variable, a call), which only has a value when the
104
+ app runs. Write the value itself: \`true\`, \`false\`, a number, a string or \`null\`.
105
+ `
106
+ },
107
+ island_import_unresolved: {
108
+ text: (a) => prose`
109
+ cannot resolve '${a.specifier}' imported by the generated island module for ${a.host}.
110
+ That island was marked on a package import, so the specifier must resolve from the host
111
+ file: check the package is installed and its "exports" map exposes this subpath (with a
112
+ "svelte" condition for .svelte components).
113
+ `,
114
+ details: () => prose`
115
+ An island was marked on an import from a package, and the module ogygia generates for it
116
+ imports that same specifier. It does not resolve from the file that marked it.
117
+
118
+ Check the package is installed in the app, and that its \`exports\` map lists this
119
+ subpath, with a \`svelte\` condition for a \`.svelte\` component.
120
+ `
121
+ },
122
+ call_arg_not_literal: {
123
+ text: (a) => `${a.call}: the first argument must be a static string literal, got '${a.got}…'`,
124
+ details: () => prose`
125
+ The build reads this call's first argument from the source, so it has to be a plain
126
+ string, written out. \`got\` is what was written instead (a variable, a call). Put the
127
+ string itself there.
128
+ `
129
+ },
130
+ call_arg_interpolated: {
131
+ text: (a) => prose`
132
+ ${a.call}: the first argument must be a static string literal — a template literal with
133
+ \${…} interpolation is a runtime value the build cannot resolve.
134
+ `,
135
+ details: () => prose`
136
+ The build reads this call's first argument from the source. A template literal with a
137
+ value inside it only has its text when the app runs. Write one plain string.
138
+ `
139
+ },
140
+ call_arg_in_expression: {
141
+ text: (a) => prose`
142
+ ${a.call}: the first argument must be a static string literal, but it is part of a larger
143
+ expression (near '${a.near}…'). Use one plain string.
144
+ `,
145
+ details: () => prose`
146
+ The build reads this call's first argument from the source. Here the string is joined
147
+ with something else (\`'./' + dir\`, a \`.concat()\` call), which only has its value when
148
+ the app runs. Write the whole string out.
149
+ `
150
+ },
151
+ import_key_invalid: {
152
+ text: (a) => `importKeys.${a.role} must be a non-empty JS identifier (got ${a.got}).`,
153
+ details: () => prose`
154
+ \`importKeys\` renames the import attributes ogygia reads (\`wake\`, \`fetch\`,
155
+ \`render\`, \`preset\`, \`region\`). Each name is written as a key inside \`with\`, so it
156
+ has to be a JavaScript identifier.
157
+ `
158
+ },
159
+ import_keys_not_distinct: {
160
+ text: () => "importKeys.wake, importKeys.fetch, importKeys.render, importKeys.preset, and importKeys.region must be distinct.",
161
+ details: () => prose`
162
+ Two of the attribute names in \`importKeys\` are the same, so the build could not tell
163
+ which one an import means. Give each its own name.
164
+ `
165
+ },
166
+ region_value_not_raw: {
167
+ text: (a) => prose`
168
+ ${a.host}: \`${a.key}\` only takes the value 'raw' (a held region with no baked
169
+ schedule). To bake a schedule use a \`wake:\` mark, or set it at the \`region()\` call.
170
+ `,
171
+ details: () => prose`
172
+ The \`region\` import attribute marks a held region and has one value, \`'raw'\`. It
173
+ carries no schedule. To give the region one, mark the import with \`wake\` instead, or
174
+ pass \`wake\` where it is placed: \`region(C, props, opts)\`.
175
+ `
176
+ },
177
+ wake_strategy_unknown: {
178
+ text: (a) => `${a.host}: unknown \`${a.key}\` strategy '${a.value}'. Use 'load' | 'idle' | 'visible' | 'interaction' | a media query.`,
179
+ details: () => prose`
180
+ A \`wake\` mark says when an island's JavaScript runs. It takes \`'load'\`, \`'idle'\`,
181
+ \`'visible'\`, \`'interaction'\` or a media query such as \`'(min-width: 800px)'\`.
182
+ `
183
+ },
184
+ generated_module_relative_import: {
185
+ text: (a) => prose`
186
+ ${a.host}: cannot resolve the relative import '${a.specifier}' from a generated module —
187
+ it has no directory. Its real origin must be threaded (HostCtx.originOf); this is an
188
+ ogygia bug, please report it.
189
+ `,
190
+ details: () => BUG
191
+ },
192
+ region_import_invalid: {
193
+ text: (a) => `${a.host}: import { ${a.names} } — ${a.problem}`,
194
+ details: () => prose`
195
+ A marked import (one with \`wake\`, \`render\`, \`fetch\`, \`preset\` or \`region\` in
196
+ its \`with\` clause) is written in a way the build cannot turn into a region. \`problem\`
197
+ says what is wrong and what to write.
198
+ `
199
+ },
200
+ region_attribute_unknown: {
201
+ text: (a) => `${a.host}: import ${a.names} — \`${a.key}\` is not an attribute ogygia has. A component import takes ${a.known}.`,
202
+ details: () => prose`
203
+ An import of a \`.svelte\` component carries an attribute in its \`with\` clause that
204
+ ogygia does not read: a misspelling (\`wkae\`), a retired key (\`partial\`), or an option
205
+ that belongs in a preset (\`margin\`, \`maxAge\`). It is refused rather than ignored, so the
206
+ import never silently stays a plain component.
207
+
208
+ The message lists the keys a component import takes, by this app's own names when
209
+ \`ogygia({ importKeys })\` renames them. Options like \`margin\` go in
210
+ \`ogygia({ presets })\`, named with \`preset\`. Attributes on any other import
211
+ (\`with { type: 'json' }\`) are not ogygia's and are left alone.
212
+ `
213
+ },
214
+ as_region_removed: {
215
+ until: "0.15",
216
+ text: (a) => `${a.host}: import.meta.og.asRegion is gone. Mark the import itself; a named import takes the same options:\n${a.fixes}`,
217
+ details: () => prose`
218
+ \`import.meta.og.asRegion(Component, options)\` was replaced by the import it stood for. A
219
+ named import carries the mark the same way a default import does:
220
+ \`import { Search } from 'x' with { wake: 'idle' }\`, aliased with \`as\` when the region
221
+ had its own name. The message prints the line to write for each call in the file. Put it
222
+ beside the file's other imports and delete the \`const\`. If the old import is used for
223
+ nothing else, delete it too.
224
+ `
225
+ },
226
+ region_import_namespace: {
227
+ text: (a) => prose`
228
+ ${a.host}:${a.line} — \`import * as ${a.name} from '${a.spec}'\` carries a region mark. A
229
+ namespace is not a component. Name the components you place:
230
+ \`import { Card } from '${a.spec}' with { … }\`.
231
+ `,
232
+ details: () => prose`
233
+ A region mark (\`wake\`, \`render\`, \`fetch\`, \`preset\` or \`region\` in the \`with\`
234
+ clause) makes every name the import binds a region. A namespace import binds an object of
235
+ exports, not a component, so it cannot be one. Import each component by name instead.
236
+ `
237
+ },
238
+ region_import_bare: {
239
+ text: (a) => prose`
240
+ ${a.host}:${a.line} — \`import '${a.spec}'\` carries a region mark but binds no name, so
241
+ there is nothing to make a region. Bind the component:
242
+ \`import Card from '${a.spec}' with { … }\`, or drop the \`with\` clause.
243
+ `,
244
+ details: () => prose`
245
+ A side-effect import (\`import 'x'\`, or \`import {} from 'x'\`) binds no name. A region
246
+ mark only means something on a name you place as \`<Name />\` or hand to \`region()\`.
247
+ `
248
+ },
249
+ region_import_type_only: {
250
+ text: (a) => prose`
251
+ ${a.host}:${a.line} — \`${a.names}\` is imported as a type with a region mark. A type is
252
+ gone at runtime, so it cannot be a region. Import the types on their own line without
253
+ \`with\`: \`import type { ${a.names} } from '${a.spec}';\`
254
+ `,
255
+ details: () => prose`
256
+ \`import type\`, or a \`type\` specifier inside the braces, imports only a type. Types are
257
+ erased before the code runs, so a region mark on one marks nothing. Keep region marks on
258
+ value imports of components and import types on a separate line.
259
+ `
260
+ },
261
+ region_binding_not_component: {
262
+ text: (a) => prose`
263
+ ${a.host}:${a.at} — \`${a.name}\` comes from a region import, but it is ${a.use} here. A
264
+ region mark makes every name in its import a component region. If \`${a.name}\` is not a
265
+ component, import it on its own line without \`with\`: \`${a.fix}\`
266
+ `,
267
+ details: () => prose`
268
+ One \`with { … }\` clause covers every name its import binds, so each one becomes a
269
+ region: a component you place as \`<Name />\` or hand on as a value (\`region(Name)\`, a
270
+ prop, a registry). Calling it, reading a member off it, spreading it, rendering it as
271
+ text, \`typeof\`, \`{@render}\`, \`{@html}\`, an action or a transition all mean the
272
+ name is not a component. Usually a tool merged two imports of one module into one. Split
273
+ them: the components keep the \`with\` clause, the rest get a plain import line.
274
+ `
275
+ },
276
+ region_children_not_portable: {
277
+ text: (a) => prose`
278
+ ${a.host}: <${a.tag}> has host children/snippets that cannot cross the island boundary.
279
+ Under portable bindings, pass serializable props and put UI inside the island
280
+ component${a.server ? " (only the reserved `{#snippet ogygiaFallback()}` may appear at the call site)." : "."}
281
+ `,
282
+ details: () => prose`
283
+ A deferred region or a held region renders on its own, from its props alone, so markup
284
+ written between its tags has nowhere to go. Pass the data as props and put the markup
285
+ inside the component.
286
+
287
+ A deferred region may keep one snippet at the call site: \`ogygiaFallback\`, what shows
288
+ until its HTML arrives.
289
+ `
290
+ },
291
+ region_dotted_tag: {
292
+ text: (a) => prose`
293
+ ${a.host}: dotted tag \`<${a.tag}>\` is not supported for region import '${a.import}'.
294
+ Import the leaf component with \`with { hydrate|defer }\` instead.
295
+ `,
296
+ details: () => prose`
297
+ A marked import becomes one region, so the build cannot reach a component hanging off it
298
+ (\`Menu.Item\`). Import that component on its own and mark that import.
299
+ `
300
+ },
301
+ dynamic_region_import: {
302
+ text: (a) => prose`
303
+ ${a.host}: dynamic import() with { with: { ${a.keys} } } is not supported. Mark islands
304
+ with a static \`import X from '…' with { ${a.wake_key}: '…' }\` (or \`${a.render_key}\` /
305
+ \`${a.preset_key}\`) — the binding becomes a portable island component. For a
306
+ click-loaded chunk that is not an island, use plain \`await import('./Comp.svelte')\` (no
307
+ region attributes) inside a host island. To delay a real island until click, gate a static
308
+ region import with \`{#if}\`.
309
+ `,
310
+ details: () => prose`
311
+ A region needs a static import and a tag the server can render, so region attributes on
312
+ a dynamic \`import()\` do nothing (Vite drops them). Use a static marked import.
313
+
314
+ To load a plain component on click, call \`await import('./Comp.svelte')\` with no region
315
+ attributes, inside an island. To delay an island, put its tag behind an \`if\` block.
316
+ `
317
+ },
318
+ region_import_no_specifier: {
319
+ text: (a) => `${a.host}: ${a.held ? "held-region import" : "region import"} '${a.name}' needs a module specifier ($lib/…, relative, or a package specifier like 'pkg/component').`,
320
+ details: () => prose`
321
+ A marked import has no module path the build can resolve. Import the component from
322
+ \`$lib/...\`, a relative path, or a package subpath such as \`'pkg/component'\`.
323
+ `
324
+ },
325
+ snippet_reads_dollar_props: {
326
+ text: (a) => prose`
327
+ ${a.host}: {#snippet ${a.snippet}} crosses an island boundary but reads \`${a.name}\` —
328
+ the host's $$-props cannot cross. Read the value into a plain host variable outside the
329
+ snippet and use that instead.
330
+ `,
331
+ details: () => prose`
332
+ A snippet passed into an island is rendered from the values it captures. \`$$props\` and
333
+ \`$$restProps\` belong to the host component and cannot be captured. Read what the
334
+ snippet needs into a plain variable in the host, outside the snippet, and use that.
335
+ `
336
+ },
337
+ held_fetch_without_render: {
338
+ text: (a) => prose`
339
+ ${a.host}: \`${a.fetch_key}: '${a.value}'\` without \`${a.render_key}: 'deferred'\` —
340
+ \`${a.fetch_key}\` is a hole's timing. Write \`${a.render_key}: 'deferred',
341
+ ${a.fetch_key}: '${a.value}'\` for a hole, or \`${a.wake_key}: '${a.value}'\` for an
342
+ island.
343
+ `,
344
+ details: () => prose`
345
+ \`fetch\` says when a deferred region's (a hole's) HTML arrives, so it only goes with
346
+ \`render: 'deferred'\`. For a hole, write both. For an island that runs its JavaScript
347
+ at that time, write \`wake\` instead.
348
+ `
349
+ },
350
+ held_render_live: {
351
+ text: (a) => `${a.host}: \`${a.render_key}: 'live'\` is not supported on a .ts import — use it in a .svelte file.`,
352
+ details: () => prose`
353
+ A live region is placed by a Svelte component. A \`.ts\` or \`.js\` module can only hand
354
+ out held regions and holes, so mark the import in a \`.svelte\` file.
355
+ `
356
+ },
357
+ held_render_unknown: {
358
+ text: (a) => `${a.host}: unknown \`${a.render_key}\` '${a.value}'. Use 'deferred'.`,
359
+ details: () => prose`
360
+ In a \`.ts\` or \`.js\` module, \`render\` takes one value, \`'deferred'\`: a hole whose
361
+ HTML is fetched from the server.
362
+ `
363
+ },
364
+ hole_wake_removed: {
365
+ until: "0.15",
366
+ text: (a) => prose`
367
+ ${a.host}: ${a.said ?? "this import"} sets \`${a.wake_key}: '${a.wake}'\` on a
368
+ \`${a.render_key}: 'deferred'\` region. A deferred region ships no JS, so \`${a.wake_key}\`
369
+ never applies: remove it. Its timing is \`${a.fetch_key}\`, when its HTML arrives:
370
+ \`${a.render_key}: 'deferred', ${a.fetch_key}: '${a.fetch}'\`.
371
+ `,
372
+ details: () => prose`
373
+ A deferred region (a hole) was timed with \`wake\`. \`wake\` is when an island's
374
+ JavaScript runs, and a hole ships none: its timing is \`fetch\`, when its HTML arrives.
375
+ Up to 0.13 \`wake\` on a hole was read as its \`fetch\`; it is a build error now. Write
376
+ \`render: 'deferred', fetch: 'visible'\`.
377
+ `
378
+ },
379
+ held_fetch_not_timing: {
380
+ text: (a) => prose`
381
+ ${a.host}: \`${a.fetch_key}: '${a.value}'\` is not a timing. Use \`${a.fetch_key}: 'load'
382
+ | 'idle' | 'visible' | 'interaction'\` or a media query (a hole must fetch — not 'none').
383
+ `,
384
+ details: () => prose`
385
+ \`fetch\` says when a hole's HTML arrives: \`'load'\`, \`'idle'\`, \`'visible'\`,
386
+ \`'interaction'\` or a media query. A hole always fetches, so \`'none'\` is not one.
387
+ `
388
+ },
389
+ held_marker_mixed: {
390
+ text: (a) => prose`
391
+ ${a.host}: a held-region import on '${a.name}' takes ONE marker — \`${a.region_key}:
392
+ 'raw'\`, \`${a.wake_key}: '…'\`, or \`${a.render_key}: 'deferred'\` (with
393
+ \`${a.fetch_key}\` as its timing).
394
+ `,
395
+ details: () => prose`
396
+ An import in a \`.ts\` or \`.js\` module is one kind of held region: \`region: 'raw'\`
397
+ (no schedule), \`wake\` (an island) or \`render: 'deferred'\` (a hole, timed by
398
+ \`fetch\`). Keep the one you mean.
399
+ `
400
+ },
401
+ option_unknown: {
402
+ text: (a) => `\`ogygia({ ${a.option} })\`: ogygia() has no \`${a.option}\` option. Its options are ${a.known}.`,
403
+ details: () => prose`
404
+ \`ogygia()\` was passed a key it does not have: a misspelling, or an option from an
405
+ earlier version. It is refused rather than ignored, so nothing silently stops working.
406
+
407
+ Features beyond regions are Vite plugins listed beside \`ogygia()\` in vite.config:
408
+ \`content()\` from \`@ogygia/content/vite\`, \`devtools()\` from \`@ogygia/devtools/vite\`,
409
+ \`postrender()\` from \`@ogygia/postrender/vite\`. Form continuity is
410
+ \`router: { forms: false }\`. Check the key against the options the message lists.
411
+ `
412
+ },
413
+ barrels_option_removed: {
414
+ until: "0.15",
415
+ text: () => prose`
416
+ \`ogygia({ barrels })\` is gone: the barrel rewrite is a plugin now. Install
417
+ \`@ogygia/barrels\` and list \`barrels({ … })\` (from \`@ogygia/barrels\`) beside
418
+ \`ogygia()\` in vite.config \`plugins\`, \`plugins: [ogygia(), barrels(), sveltekit()]\`.
419
+ `,
420
+ details: () => prose`
421
+ The \`barrels\` option of \`ogygia()\` was passed. The pass that turns barrel imports into
422
+ leaf imports moved to its own plugin, \`barrels()\` from \`@ogygia/barrels\`, which takes
423
+ the same options. The standalone \`debarrel()\` from \`ogygia/vite\` is gone with it.
424
+
425
+ Remove the option and list \`barrels()\` beside \`ogygia()\` in vite.config
426
+ \`plugins\`.
427
+ `
428
+ },
429
+ preset_empty: {
430
+ text: (a) => `presets.${a.name} is empty — a preset with nothing is a mistake.`,
431
+ details: () => prose`
432
+ A region preset names a set of import options (\`with { preset: 'card' }\`). This one sets
433
+ none. Give it its options, or remove it.
434
+ `
435
+ },
436
+ preset_key_unknown: {
437
+ text: (a) => `presets.${a.name}: unknown key \`${a.key}\`. A preset takes ${a.allowed}.`,
438
+ details: () => prose`
439
+ A region preset holds the options a marked import takes. \`key\` is not one of them;
440
+ \`allowed\` lists those that are.
441
+ `
442
+ },
443
+ max_page_age_invalid: {
444
+ text: (a) => prose`
445
+ maxPageAge must be a number of seconds ≥ 0 (got ${a.value}). Write e.g. \`30 * 24 *
446
+ 3600\` for 30 days, or \`0\` to turn renewal off.
447
+ `,
448
+ details: () => prose`
449
+ \`maxPageAge\` is how long, in seconds, a page's expired region addresses may still be
450
+ renewed. Write a number, such as \`30 * 24 * 3600\` for 30 days, or \`0\` to never renew.
451
+ `
452
+ },
453
+ secret_in_client_chunk: {
454
+ text: (a) => prose`
455
+ the client build's ${a.file} holds ${a.what}. Browsers must never be able to sign region
456
+ addresses: the build stops.
457
+ `,
458
+ details: () => prose`
459
+ The secret that signs region addresses, or a server module that signs with it, ended up in
460
+ a file the browser downloads. Usually a universal or client module imports a server-only
461
+ module, or reads \`OGYGIA_SECRET\` and puts it in its output. Find the import that brings it
462
+ into the client and move that code to a server-only file (\`+page.server.ts\`,
463
+ \`hooks.server.ts\`, \`$lib/server\`).
464
+ `
465
+ },
466
+ secret_too_short: {
467
+ text: (a) => `OGYGIA_SECRET is too short for production builds (need ≥${a.min_bytes} UTF-8 bytes).`,
468
+ details: () => prose`
469
+ \`OGYGIA_SECRET\` signs region addresses. A short key can be guessed, so a production
470
+ build refuses it (dev accepts any). Use a long random value, such as the output of
471
+ \`openssl rand -base64 32\`.
472
+ `
473
+ },
474
+ kit_remote_src_missing: {
475
+ text: () => "could not locate Kit's client remote-functions (src). Use an @sveltejs/kit that publishes its `src/` (2.70.2 or later, or 3.x).",
476
+ details: () => prose`
477
+ ogygia reuses SvelteKit's own client code for remote functions, from the \`src/\` folder
478
+ Kit publishes. This version of \`@sveltejs/kit\` does not ship it. Upgrade to 2.70.2 or
479
+ later.
480
+ `
481
+ },
482
+ package_files_not_array: {
483
+ text: (a) => prose`
484
+ ${a.package}: \`"ogygia": { "files": […] }\` must be an array of package-relative
485
+ paths/globs (like npm's "files") — got ${a.got}.
486
+ `,
487
+ details: () => prose`
488
+ A package puts its files on ogygia's compile surface with \`ogygia.files\` in its
489
+ \`package.json\`: a list of paths or globs inside the package, like npm's \`files\`.
490
+ This one is not a list of strings.
491
+ `
492
+ },
493
+ package_files_escapes: {
494
+ text: (a) => `${a.package}: ogygia.files entry '${a.entry}' escapes the package.`,
495
+ details: () => prose`
496
+ An \`ogygia.files\` entry points outside its own package (\`../\`, or a symlink in the
497
+ package that leads out of it), which would compile code the package does not own. List
498
+ paths inside the package only.
499
+ `
500
+ },
501
+ plugin_without_ogygia: {
502
+ text: (a) => `\`${a.plugin}\` is listed in vite.config but \`ogygia()\` is not — add \`ogygia()\` from \`ogygia/vite\` to \`plugins\`.`,
503
+ details: () => prose`
504
+ An ogygia plugin runs inside \`ogygia()\`, so it does nothing alone. Import \`ogygia\`
505
+ from \`ogygia/vite\` and list \`ogygia()\` first in \`plugins\`.
506
+ `
507
+ },
508
+ plugin_needs_plugin: {
509
+ text: (a) => `\`${a.plugin}\` needs \`${a.needs}\` — add \`${a.needs}\` from \`${a.from}\` to \`plugins\` in vite.config.`,
510
+ details: () => prose`
511
+ This plugin works only beside another one, which the app does not list. Import the
512
+ plugin it names from its package and list it beside \`ogygia()\`, before
513
+ \`sveltekit()\`. \`postrender()\` needs \`dataShake()\`: without it every deferred region
514
+ looks the page up, and that renders the stored page again on each fetch.
515
+ `
516
+ },
517
+ plugin_factory_not_called: {
518
+ text: () => "a function is listed in vite.config `plugins` — call the factory: `flags()`, not `flags`.",
519
+ details: () => prose`
520
+ A plugin is listed by its factory's name without calling it. Add the parentheses:
521
+ \`flags()\`, not \`flags\`.
522
+ `
523
+ },
524
+ plugin_after_sveltekit: {
525
+ text: (a) => `\`${a.plugin}\` is listed after \`sveltekit()\` in vite.config — list \`ogygia()\` and its plugins first: \`plugins: [ogygia(), flags(), sveltekit()]\`.`,
526
+ details: () => prose`
527
+ Vite runs plugins in the order they are listed. ogygia and its plugins must see each
528
+ module before SvelteKit does, so list them first:
529
+ \`plugins: [ogygia(), flags(), sveltekit()]\`.
530
+ `
531
+ },
532
+ plugin_name_missing: {
533
+ text: () => "a plugin definition needs a `name` (its package name).",
534
+ details: () => prose`
535
+ \`definePlugin()\` was called without a \`name\`. The name is the plugin's package name:
536
+ ogygia resolves the package by it.
537
+ `
538
+ },
539
+ plugin_listed_twice: {
540
+ text: (a) => `plugin \`${a.plugin}\` is listed twice.`,
541
+ details: () => "The same ogygia plugin appears twice in `plugins`. List it once, with all its options."
542
+ },
543
+ plugin_realm_not_location: {
544
+ text: (a) => `plugin \`${a.plugin}\`: \`${a.realm}\` is a module location — \`import.meta.resolve('./${a.realm}.ts')\`.`,
545
+ details: () => prose`
546
+ A plugin's \`server\` and \`client\` name the module that runs there, as a location, not
547
+ the module itself. Resolve it next to the factory:
548
+ \`server: import.meta.resolve('./server.ts')\`.
549
+ `
550
+ },
551
+ plugin_options_not_json: {
552
+ text: (a) => `plugin \`${a.plugin}\`: \`options\` must be plain JSON (configure live objects in hooks.server.ts).`,
553
+ details: () => prose`
554
+ A plugin's \`options\` are written into the server build, so they must survive
555
+ \`JSON.stringify\`. Set up live objects (clients, functions) in \`hooks.server.ts\`
556
+ instead.
557
+ `
558
+ },
559
+ plugin_realm_not_file: {
560
+ text: (a) => `plugin \`${a.plugin}\`: its \`${a.realm}\` realm \`${a.location}\` is not a file — resolve it next to the factory: \`import.meta.resolve('./${a.realm}.ts')\`.`,
561
+ details: () => prose`
562
+ A plugin's \`server\` or \`client\` location does not point at a file. Resolve it next to
563
+ the factory, so it is the file the package ships:
564
+ \`import.meta.resolve('./server.ts')\`.
565
+ `
566
+ },
567
+ plugin_client_hooks_unread: {
568
+ text: (a) => `plugin \`${a.plugin}\`: the build cannot read the \`hooks\` its client realm \`${a.location}\` subscribes to — write them as an object literal in \`export default defineClient({ hooks: { … } })\`.`,
569
+ details: () => prose`
570
+ The build reads which runtime hooks a plugin's browser half subscribes to from its
571
+ file, so a hook nobody uses folds out of the runtime. That needs the default export to
572
+ be \`defineClient({ … })\` (any part of it may sit in a module-level \`const\`), with \`hooks\` an object literal of
573
+ plain keys: no spread, no computed key.
574
+ `
575
+ },
576
+ plugin_client_hook_unknown: {
577
+ text: (a) => `plugin \`${a.plugin}\`: its client realm subscribes to \`${a.hook}\`, which is not a runtime hook.`,
578
+ details: () => prose`
579
+ A client realm's \`hooks\` keys must name runtime hooks (\`RuntimeHooks\` from
580
+ \`ogygia/plugin/client\`). A misspelled one would never be called.
581
+ `
582
+ },
583
+ plugin_package_unresolved: {
584
+ text: (a) => `plugin \`${a.plugin}\`: no package by that name resolves from ${a.root} — its name must be its package name.`,
585
+ details: () => prose`
586
+ A plugin's \`name\` is its package name, and ogygia resolves the package by it from the
587
+ app. Nothing by that name is installed there: install the package, or fix the name.
588
+ `
589
+ },
590
+ route_config_key_invalid: {
591
+ text: (a) => `plugin \`${a.plugin}\`: route config key \`${a.key}\` must be a camelCase identifier.`,
592
+ details: () => prose`
593
+ A plugin claimed a key of a route's \`export const config\` that is not a camelCase name.
594
+ Use one such as \`postrender\`.
595
+ `
596
+ },
597
+ route_config_key_claimed: {
598
+ text: (a) => `route config key \`${a.key}\` is claimed by both \`${a.owner}\` and \`${a.plugin}\`.`,
599
+ details: () => prose`
600
+ Two plugins claimed the same key of a route's \`export const config\`, so a route could
601
+ not say which one it configures. One of them has to use another key.
602
+ `
603
+ },
604
+ plugin_macro_name_invalid: {
605
+ text: (a) => `plugin \`${a.plugin}\`: macro \`import.meta.og.${a.name}\` must be a camelCase name core does not own.`,
606
+ details: () => prose`
607
+ A plugin's macro is a camelCase name under \`import.meta.og\`. The names \`wire\`,
608
+ \`$\`, \`source\`, \`store\` and \`bake\` are ogygia's own.
609
+ `
610
+ },
611
+ plugin_macro_claimed: {
612
+ text: (a) => `macro \`import.meta.og.${a.name}\` is claimed by both \`${a.owner}\` and \`${a.plugin}\`.`,
613
+ details: () => prose`
614
+ Two plugins registered the same \`import.meta.og\` macro. One of them has to use another
615
+ name.
616
+ `
617
+ },
618
+ page_reads_claimed: {
619
+ text: (a) => `seed shaping (\`pageReads\`) is claimed by both \`${a.owner}\` and \`${a.plugin}\`.`,
620
+ details: () => prose`
621
+ Two plugins answer which \`page.data\` keys a module reads. Only one can: list one of them
622
+ (\`dataShake()\` from \`@ogygia/data-shake/vite\` is the one ogygia ships).
623
+ `
624
+ },
625
+ page_modules_not_absolute: {
626
+ text: (a) => `plugin \`${a.plugin}\`: \`pageModules({ files })\` takes absolute paths (got \`${a.file}\`).`,
627
+ details: () => prose`
628
+ \`pageModules\` was given a relative file path. Pass absolute paths, for example
629
+ resolved from the app's root.
630
+ `
631
+ },
632
+ virtual_unknown: {
633
+ text: (a) => `\`${a.id}\` is not a module ogygia serves.`,
634
+ details: () => prose`
635
+ An import names a module in ogygia's namespace (\`ogygia:…\`) that no part of ogygia
636
+ declares. Check the spelling against the modules the realm offers. If a plugin should
637
+ serve it, check that the plugin is listed beside \`ogygia()\` in vite.config.
638
+ `
639
+ },
640
+ virtual_wrong_realm: {
641
+ text: (a) => `\`${a.id}\` is a ${a.realm} module, and the ${a.leg} build imported it${a.via ? `, through ${a.via}` : ""}.`,
642
+ details: () => prose`
643
+ Each of ogygia's modules runs in one realm: \`ogygia:server\` on the server, \`ogygia:boot\`
644
+ in the browser's runtime, \`ogygia:region\` in both, \`ogygia:dev\` on the dev server only.
645
+ A server module in the browser could carry a secret into the page. Read the value on the
646
+ server and hand the browser what it needs through props or seeds.
647
+ `
648
+ },
649
+ virtual_duplicate: {
650
+ text: (a) => `\`${a.id}\` is declared twice.`,
651
+ details: () => prose`
652
+ Two declarations claim the same virtual module. Each module is declared once, by the part
653
+ of ogygia (or the plugin) that knows its value. ${BUG}
654
+ `
655
+ },
656
+ virtual_names_stale: {
657
+ text: (a) => `\`${a.id}\` exports other names than the ones generated for it.`,
658
+ details: () => prose`
659
+ A value module's export names are read off its declaration when ogygia is built, so its
660
+ realm module knows them without running it. This one now returns other names: the
661
+ generated list is stale. Run \`node packages/core/scripts/virtual-types.ts\`. ${BUG}
662
+ `
663
+ },
664
+ plugin_session_order: {
665
+ text: (a) => `The bundler called ogygia's \`${a.hook}\` hook while the plugin was ${a.state}.`,
666
+ details: () => prose`
667
+ An \`ogygia()\` plugin is made, configured (\`config\`), then resolved
668
+ (\`configResolved\`) once: its compiler is made from the resolved build. A hook that
669
+ needs the compiler runs after that, and the build is resolved only once per plugin. A
670
+ bundler or a tool that calls the hooks in another order meets this. ${BUG}
671
+ `
672
+ },
673
+ build_leg_unclear: {
674
+ text: (a) => a.leg ? `The bundler called ogygia in environment \`${a.leg}\`, which never started a build.` : `The bundler called ogygia with no environment while ${a.open} environments build.`,
675
+ details: () => prose`
676
+ Each bundler environment (\`ssr\`, \`client\`) builds its own output, and ogygia keeps what
677
+ each one emits apart. A call it cannot place in one environment would put one
678
+ environment's files in the other's output. ${BUG}
679
+ `
680
+ }
681
+ };
682
+ const WARNED = {
683
+ macro_store_returns_non_store: {
684
+ text: (a) => prose`
685
+ ${a.file}:${a.line} — this import.meta.og.store factory has a return that is provably not
686
+ a store (undefined/null/primitive). Where that branch runs, the product crosses as plain
687
+ data, unbranded. If it is an environment guard, return a store there too (e.g.
688
+ writable(seed)) and guard the side effects inside the factory instead.
689
+ `,
690
+ details: () => prose`
691
+ A store factory marked with \`import.meta.og.store\` returns something that is not a
692
+ store on one branch (\`undefined\`, \`null\`, a number). Where that branch runs, the
693
+ value reaches islands as plain data, not as the store.
694
+
695
+ If the branch guards an environment (the server), return a store there too, such as
696
+ \`writable(seed)\`, and guard the side effects inside the factory.
697
+ `
698
+ },
699
+ scoped_css_failed: {
700
+ text: (a) => `scoped CSS for ${a.file} could not be compiled (${a.reason}) — shipping its style bodies unscoped`,
701
+ details: () => prose`
702
+ ogygia compiles a component's styles on their own to ship them with its HTML, and that
703
+ compile failed (\`reason\`). The styles ship without Svelte's scoping, so its rules can
704
+ reach the rest of the page. Fix the component so it compiles.
705
+ `
706
+ },
707
+ package_marks_undeclared: {
708
+ text: (a) => prose`
709
+ ${a.file} uses ogygia marks, but its package declares no \`"ogygia": { "files": [...] }\`
710
+ — the marks are IGNORED. Add the field to that package's package.json
711
+ (npm-"files"-style paths/globs) to put it on ogygia's compile surface.
712
+ `,
713
+ details: () => prose`
714
+ A file in a dependency marks imports for ogygia (\`with { wake }\`), but ogygia only
715
+ compiles a package's files when the package asks for it. So the marks do nothing.
716
+
717
+ Add \`ogygia.files\` to that package's \`package.json\`: the paths or globs ogygia
718
+ compiles, like npm's \`files\`.
719
+ `
720
+ },
721
+ runtime_marks_late: {
722
+ text: (a) => prose`
723
+ ${a.file} placed a region that needs the runtime's ${a.features}, but the build had already
724
+ made its runtime without it: that region will not work in this build. Put the file where
725
+ the scan reads it: under \`src/\`, or in a package that declares \`"ogygia": { "files":
726
+ [...] }\`.
727
+ `,
728
+ details: () => prose`
729
+ A build picks the runtime's features once, from the regions it knows when the bundler
730
+ loads the runtime entry. This file was first reached later, while bundling, and one of
731
+ its regions needs a feature (a lake, a \`keep\`, a held region, a deferred hole, a wake
732
+ on interaction) the runtime was made without. The region then never wakes or never
733
+ fills.
734
+
735
+ ogygia reads every file under \`src/\` and every declared package file before the
736
+ bundler starts. Move the file there, or declare it in its package's \`ogygia.files\`.
737
+ `
738
+ },
739
+ relocation_unpatched: {
740
+ text: (a) => prose`
741
+ the ${a.name} in the ${a.leg} build was left unpatched: a value the build fills in at the end
742
+ never reached its chunk, so that part of the output is wrong. Please report it.
743
+ `,
744
+ details: () => prose`
745
+ Some values are known only once the bundler has transformed every module: the \`og.$\`
746
+ functions an app defines, and which server regions read \`page.data\`. The build writes a
747
+ placeholder for each and fills it in as each chunk is finished. A placeholder was left in
748
+ the output, or the module that carries it is in the output and none was filled. This is
749
+ an ogygia bug, or another plugin rewrote the chunk after ogygia filled it.
750
+ `
751
+ },
752
+ island_context_unprovided: {
753
+ text: (a) => prose`
754
+ island code ${a.file} reads getContext(${a.key}), but this app registers no ogygia
755
+ context provider and no island code sets ${a.key}. On a csr=false page a value set with
756
+ Svelte's setContext in a page/layout does NOT cross the island boundary — the island reads
757
+ undefined on the client, re-renders a different tree, and Svelte discards its
758
+ server-rendered DOM on hydration (a silent full re-render). Fix: provide ${a.key} with
759
+ setContext / <Provide> / createContext imported from 'ogygia' (in a csr=false layout); the
760
+ read stays getContext(${a.key}).
761
+ `,
762
+ details: () => prose`
763
+ An island reads a context nothing in the browser provides. On a csr=false page a layout
764
+ or page runs only on the server, so a value it sets with Svelte's \`setContext\` never
765
+ reaches the island there. The island renders a different tree and Svelte throws its
766
+ server HTML away.
767
+
768
+ Provide the value with \`setContext\`, \`<Provide>\` or \`createContext\` imported from
769
+ \`ogygia\`. The island keeps reading it with \`getContext\`. The key is a string or a
770
+ \`Symbol.for('name')\`: both cross.
771
+ `
772
+ },
773
+ region_context_key_one_off: {
774
+ text: (a) => prose`
775
+ ${a.file} sets context with ogygia's setContext under the one-off symbol ${a.key}, which
776
+ cannot cross into regions: they read undefined in the browser. Key it with a string or
777
+ Symbol.for('name'); or pass { islands: false } if no region reads it.
778
+ `,
779
+ details: () => prose`
780
+ Each region wakes as its own root in the browser, so it reads context the page carries
781
+ across. A one-off \`Symbol()\` key has no twin there: nothing in the browser can name it.
782
+ Use a string key, or \`Symbol.for('name')\`, which the browser rebuilds from its name (or
783
+ \`createContext\` from \`ogygia\`). If no region reads the key, set it with
784
+ \`setContext(key, value, { islands: false })\`.
785
+ `
786
+ },
787
+ region_host_skipped: {
788
+ text: (a) => `regions: skipped ${a.file}: ${a.reason}${a.at ? ` at ${a.at}` : ""} — its region imports stay plain imports`,
789
+ details: () => prose`
790
+ ogygia could not parse the component, so its marked imports were left as plain imports:
791
+ no island, no hole. The Svelte compiler reports the parse error itself. Fix it and the
792
+ regions come back.
793
+ `
794
+ },
795
+ snippet_store_snapshot: {
796
+ text: (a) => prose`
797
+ ${a.host}: {#snippet ${a.snippet}} crosses an island boundary and reads \`${a.store}\`
798
+ (at ${a.at}) — captured as a FROZEN snapshot of the store's value at render time; later
799
+ store updates never reach the island. To make the snapshot explicit (and silence this),
800
+ read it at host scope outside the snippet — e.g. \`const ${a.store.slice(1)}_value =
801
+ ${a.store};\` — and use that.
802
+ `,
803
+ details: () => prose`
804
+ A snippet passed into an island reads a store with \`$\`. In plain Svelte that value is
805
+ live. Across an island boundary the snippet is rendered once from the values it captured,
806
+ so the island keeps the value the store had at render time.
807
+
808
+ To say so in the code (and silence this), read the value into a host variable outside
809
+ the snippet and use that. For a value that keeps changing, share a wired class instead.
810
+ `
811
+ },
812
+ snippet_store_unverified: {
813
+ text: (a) => prose`
814
+ ${a.host}: {#snippet ${a.snippet}} reads \`${a.store}\` (at ${a.at}), but
815
+ \`${a.store.slice(1)}\` is not a host declaration or import, so ogygia cannot verify it
816
+ is a store. Its value is captured at the host anyway — if the build now errors in
817
+ ${a.host}, start there.
818
+ `,
819
+ details: () => prose`
820
+ A snippet passed into an island reads \`$name\`, but \`name\` is not declared or imported
821
+ in the host, so ogygia cannot tell it is a store. It captures the value at the host as if
822
+ it were. If the build then fails in that file, this is the place to look.
823
+ `
824
+ },
825
+ snippet_captures_store: {
826
+ text: (a) => prose`
827
+ ${a.host}: {#snippet ${a.snippet}} crosses an island boundary and captures the store
828
+ \`${a.store}\` as an OBJECT — a host-declared store cannot cross (its functions don't
829
+ serialize). Use its value (\`$${a.store}\`) inside the snippet, or share live state with a
830
+ wired class instead.
831
+ `,
832
+ details: () => prose`
833
+ A snippet passed into an island uses a store declared in the host as an object. The
834
+ snippet's captures are serialized, and a store's functions cannot be. Read its value
835
+ with \`$\` inside the snippet, or share live state with a wired class.
836
+ `
837
+ },
838
+ sass_missing: {
839
+ text: () => "a server-rendered component has `<style lang=\"scss\">` but neither `sass-embedded` nor `sass` is installed — its hole/router CSS ships unprocessed",
840
+ details: () => prose`
841
+ ogygia compiles the styles of components it serves itself (holes, router pages). One is
842
+ written in SCSS and no Sass compiler is installed, so its CSS ships as written. Install
843
+ \`sass-embedded\` or \`sass\`.
844
+ `
845
+ },
846
+ scss_compile_failed: {
847
+ text: (a) => `${a.file}: scss compile failed — ${a.reason}`,
848
+ details: () => prose`
849
+ A component's SCSS did not compile (\`reason\`), so its style block ships as written.
850
+ Fix the stylesheet.
851
+ `
852
+ },
853
+ ts_strip_failed: {
854
+ text: (a) => `${a.file}: TypeScript strip failed — ${a.reason}`,
855
+ details: () => prose`
856
+ ogygia strips the types from a component's TypeScript script to compile its styles, and
857
+ that failed (\`reason\`). The component's CSS may then ship unscoped. Fix the script.
858
+ `
859
+ },
860
+ optimize_deps_includes_ogygia: {
861
+ text: (a) => prose`
862
+ optimizeDeps.include lists ${a.specifiers}: ogygia must not be pre-bundled in dev (the
863
+ page would run two copies of its runtime, and islands with snippet props fail to
864
+ hydrate). Remove ${a.count === 1 ? "it" : "them"}.
865
+ `,
866
+ details: () => prose`
867
+ Vite's \`optimizeDeps.include\` lists part of ogygia. ogygia keeps itself out of Vite's
868
+ dependency pre-bundling, and listing it brings a second copy of its runtime into the dev
869
+ page. Remove those entries.
870
+ `
871
+ },
872
+ island_handoff_write_failed: {
873
+ text: () => "could not write the server-leg island handoff:",
874
+ details: () => prose`
875
+ The server build writes which components it transformed, so the client build emits only
876
+ the islands those pages place. Writing it failed (the error follows the message). The
877
+ build goes on and emits every island it found.
878
+ `
879
+ },
880
+ package_files_missing: {
881
+ text: (a) => `${a.package}: ogygia.files entry '${a.entry}' does not exist — skipped.`,
882
+ details: () => prose`
883
+ An \`ogygia.files\` entry in a dependency's \`package.json\` names a path that is not in
884
+ the package. It is skipped. The package should fix or remove the entry.
885
+ `
886
+ },
887
+ kit_config_unreadable: {
888
+ text: (a) => `could not read ${a.file} for kit.files.routes / kit.outDir — using the defaults (${a.routes}, ${a.out}). ${a.reason}`,
889
+ details: () => prose`
890
+ ogygia loads \`svelte.config.js\` to find the routes folder and Kit's output folder, and
891
+ loading it threw (the reason follows). It uses Kit's defaults. If the app moved either
892
+ folder, fix the config so it loads.
893
+ `
894
+ },
895
+ plugin_not_listed: {
896
+ text: (a) => `${a.file} imports ${a.package}, but its plugin \`${a.plugin}\` is not listed beside ogygia() in vite.config — its build half does not run.`,
897
+ details: () => prose`
898
+ This package has a part that runs in the build (for \`@ogygia/flags\`: the flag inventory,
899
+ \`node_modules/.ogygia/flags-manifest.json\`, and the server half that tells each request
900
+ which flags it read). That part runs only when the package's plugin is listed. Add it beside
901
+ \`ogygia()\` in vite.config \`plugins\`, before \`sveltekit()\`. Said once per build.
902
+ `
903
+ }
904
+ };
905
+ /** The build's reports: printed at info level with `line(code, args)`, never warned. */
906
+ const BUILD_REPORTS = {
907
+ island_chunks_not_emitted: {
908
+ text: (a) => `${a.count} island chunk(s) not emitted: their host modules are not in the server bundle (unreachable from this build's routes).`,
909
+ details: () => prose`
910
+ The client build found islands whose host components no route of this build renders, so
911
+ it left their chunks out. Nothing is wrong unless an island is missing from a page that
912
+ should have it: then check the route that renders its host is part of the build.
913
+ `
914
+ },
915
+ page_seed_report: {
916
+ text: (a) => `page seed: ${a.islands} island${a.islands === 1 ? "" : "s"} read page.data — ${a.pinned} pinned to ${a.keys} key${a.keys === 1 ? "" : "s"}, ${a.unpinned} ship all of it`,
917
+ details: () => prose`
918
+ An island that reads \`page.data\` gets a copy of it in the page. When the build can see
919
+ which keys it reads, the island is pinned to them and only those ship. When it cannot (the
920
+ whole object is spread, passed on, or read with a computed key), the island ships all of
921
+ \`page.data\`.
922
+
923
+ The lines below the report name the modules that made an island ship everything, with
924
+ the reason. Read the keys you need by name there, and the copy shrinks.
925
+ `
926
+ }
927
+ };
928
+ /** The warnings: `warn(code, args, ...rest)`, then the build's reports ({@link BUILD_REPORTS}). */
929
+ const BUILD_WARNINGS = {
930
+ ...WARNED,
931
+ ...BUILD_REPORTS
932
+ };
933
+ const build = define_messages(BUILD_ERRORS, BUILD_WARNINGS);
934
+ const OgygiaError = build.OgygiaError;
935
+ const warn = build.warn;
936
+ /** A code's line as a string, for a logger that takes one (Rollup's `this.warn`). */
937
+ const line = build.line;
938
+ export { BUILD_ERRORS, BUILD_REPORTS, BUILD_WARNINGS, OgygiaError, line, warn };