@sveltejs/kit 3.0.0-next.2 → 3.0.0-next.21

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 (195) hide show
  1. package/package.json +62 -36
  2. package/src/cli.js +15 -12
  3. package/src/constants.js +6 -1
  4. package/src/core/adapt/builder.js +66 -72
  5. package/src/core/adapt/index.js +17 -6
  6. package/src/core/config/index.js +134 -80
  7. package/src/core/config/options.js +295 -273
  8. package/src/core/config/types.d.ts +1 -1
  9. package/src/core/env.js +146 -16
  10. package/src/core/generate_manifest/index.js +18 -15
  11. package/src/core/postbuild/analyse.js +8 -20
  12. package/src/core/postbuild/crawl.js +22 -6
  13. package/src/core/postbuild/entities.js +8 -2
  14. package/src/core/postbuild/fallback.js +4 -2
  15. package/src/core/postbuild/prerender.js +222 -70
  16. package/src/core/postbuild/queue.js +2 -1
  17. package/src/core/sync/create_manifest_data/conflict.js +1 -1
  18. package/src/core/sync/create_manifest_data/index.js +82 -62
  19. package/src/core/sync/sync.js +40 -31
  20. package/src/core/sync/ts.js +1 -1
  21. package/src/core/sync/utils.js +22 -2
  22. package/src/core/sync/{write_non_ambient.js → write_app_types.js} +107 -58
  23. package/src/core/sync/write_client_manifest.js +14 -29
  24. package/src/core/sync/write_env.js +7 -5
  25. package/src/core/sync/write_server.js +37 -45
  26. package/src/core/sync/write_tsconfig/index.js +274 -0
  27. package/src/core/sync/write_tsconfig/test-app/package.json +7 -0
  28. package/src/core/sync/write_tsconfig/utils.js +77 -0
  29. package/src/core/sync/write_tsconfig/validate.js +128 -0
  30. package/src/core/sync/write_types/index.js +127 -123
  31. package/src/core/utils.js +30 -5
  32. package/src/exports/env/index.js +77 -0
  33. package/src/exports/env/public.d.ts +55 -0
  34. package/src/exports/hooks/index.js +3 -9
  35. package/src/exports/hooks/public.d.ts +195 -0
  36. package/src/exports/hooks/sequence.js +9 -6
  37. package/src/exports/index.js +52 -29
  38. package/src/exports/internal/client.js +5 -0
  39. package/src/exports/internal/env.js +8 -5
  40. package/src/exports/internal/index.js +1 -90
  41. package/src/exports/internal/{event.js → server/event.js} +2 -3
  42. package/src/exports/internal/server/index.js +37 -0
  43. package/src/exports/internal/server/telemetry.js +95 -0
  44. package/src/exports/internal/shared.js +90 -0
  45. package/src/exports/node/index.js +64 -22
  46. package/src/exports/params/index.js +70 -0
  47. package/src/exports/params/public.d.ts +63 -0
  48. package/src/exports/public.d.ts +50 -1733
  49. package/src/exports/remote/index.js +11 -0
  50. package/src/exports/remote/public.d.ts +519 -0
  51. package/src/exports/url.js +86 -0
  52. package/src/exports/vite/build/build_server.js +54 -65
  53. package/src/exports/vite/build/remote.js +24 -19
  54. package/src/exports/vite/build/utils.js +0 -8
  55. package/src/exports/vite/dev/index.js +218 -146
  56. package/src/exports/vite/index.js +1590 -858
  57. package/src/exports/vite/module_ids.js +2 -2
  58. package/src/exports/vite/preview/index.js +40 -32
  59. package/src/exports/vite/public.d.ts +588 -0
  60. package/src/exports/vite/utils.js +84 -46
  61. package/src/pathname.js +55 -0
  62. package/src/runner.js +15 -0
  63. package/src/runtime/app/env/internal.js +4 -4
  64. package/src/runtime/app/env/types.d.ts +1 -1
  65. package/src/runtime/app/environment/index.js +3 -3
  66. package/src/runtime/app/{forms.js → forms/index.js} +73 -42
  67. package/src/runtime/app/forms/public.d.ts +2 -0
  68. package/src/runtime/app/forms/types.d.ts +56 -0
  69. package/src/runtime/app/internal/transport.js +53 -0
  70. package/src/runtime/app/manifest/index.js +1 -0
  71. package/src/runtime/app/{navigation.js → navigation/index.js} +2 -1
  72. package/src/runtime/app/navigation/public.d.ts +237 -0
  73. package/src/runtime/app/paths/client.js +37 -37
  74. package/src/runtime/app/paths/index.js +1 -1
  75. package/src/runtime/app/paths/internal/client.js +34 -2
  76. package/src/runtime/app/paths/internal/server.js +6 -23
  77. package/src/runtime/app/paths/internal.d.ts +3 -0
  78. package/src/runtime/app/paths/public.d.ts +1 -29
  79. package/src/runtime/app/paths/server.js +36 -17
  80. package/src/runtime/app/paths/types.d.ts +11 -19
  81. package/src/runtime/app/server/index.js +2 -2
  82. package/src/runtime/app/server/public.d.ts +201 -0
  83. package/src/runtime/app/server/remote/command.js +13 -11
  84. package/src/runtime/app/server/remote/form.js +61 -39
  85. package/src/runtime/app/server/remote/prerender.js +45 -45
  86. package/src/runtime/app/server/remote/query.js +106 -108
  87. package/src/runtime/app/server/remote/requested.js +27 -19
  88. package/src/runtime/app/server/remote/shared.js +76 -76
  89. package/src/runtime/app/service-worker/index.js +24 -0
  90. package/src/runtime/app/state/client.js +4 -2
  91. package/src/runtime/app/state/index.js +7 -5
  92. package/src/runtime/app/state/public.d.ts +72 -0
  93. package/src/runtime/app/state/server.js +3 -0
  94. package/src/runtime/app/stores.js +15 -78
  95. package/src/runtime/client/bundle.js +1 -1
  96. package/src/runtime/client/client-entry.js +3 -0
  97. package/src/runtime/client/client.js +1336 -648
  98. package/src/runtime/client/constants.js +3 -6
  99. package/src/runtime/client/entry.js +24 -3
  100. package/src/runtime/client/fetcher.js +25 -25
  101. package/src/runtime/client/ndjson.js +1 -1
  102. package/src/runtime/client/parse.js +1 -1
  103. package/src/runtime/client/payload.js +17 -0
  104. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  105. package/src/runtime/client/remote-functions/command.svelte.js +37 -61
  106. package/src/runtime/client/remote-functions/form.svelte.js +267 -178
  107. package/src/runtime/client/remote-functions/prerender.svelte.js +32 -11
  108. package/src/runtime/client/remote-functions/query/index.js +10 -17
  109. package/src/runtime/client/remote-functions/query/instance.svelte.js +64 -18
  110. package/src/runtime/client/remote-functions/query/proxy.js +5 -5
  111. package/src/runtime/client/remote-functions/query-batch.svelte.js +61 -70
  112. package/src/runtime/client/remote-functions/query-live/index.js +1 -1
  113. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +63 -21
  114. package/src/runtime/client/remote-functions/query-live/iterator.js +15 -12
  115. package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
  116. package/src/runtime/client/remote-functions/shared.svelte.js +90 -65
  117. package/src/runtime/client/snapshots.js +147 -0
  118. package/src/runtime/client/state.svelte.js +94 -55
  119. package/src/runtime/client/stream.js +3 -2
  120. package/src/runtime/client/types.d.ts +13 -9
  121. package/src/runtime/client/utils.js +22 -110
  122. package/src/runtime/components/root.svelte +56 -0
  123. package/src/runtime/env/dynamic/private.js +7 -0
  124. package/src/runtime/env/dynamic/public.js +7 -0
  125. package/src/runtime/env/static/private.js +6 -0
  126. package/src/runtime/env/static/public.js +6 -0
  127. package/src/runtime/form-utils.js +172 -61
  128. package/src/runtime/pathname.js +20 -32
  129. package/src/runtime/props.svelte.js +72 -0
  130. package/src/runtime/server/constants.js +0 -3
  131. package/src/runtime/server/cookie.js +72 -55
  132. package/src/runtime/server/csrf.js +65 -0
  133. package/src/runtime/server/data/index.js +49 -53
  134. package/src/runtime/server/dev.js +22 -0
  135. package/src/runtime/server/endpoint.js +6 -7
  136. package/src/runtime/server/env_module.js +0 -5
  137. package/src/runtime/server/errors.js +160 -0
  138. package/src/runtime/server/fetch.js +32 -39
  139. package/src/runtime/server/index.js +90 -64
  140. package/src/runtime/server/internal.js +71 -0
  141. package/src/runtime/server/page/actions.js +85 -64
  142. package/src/runtime/server/page/crypto.js +2 -2
  143. package/src/runtime/server/page/csp.js +88 -104
  144. package/src/runtime/server/page/data_serializer.js +24 -25
  145. package/src/runtime/server/page/index.js +36 -53
  146. package/src/runtime/server/page/load_data.js +50 -57
  147. package/src/runtime/server/page/render.js +173 -239
  148. package/src/runtime/server/page/respond_with_error.js +17 -31
  149. package/src/runtime/server/page/serialize_data.js +2 -13
  150. package/src/runtime/server/page/server_routing.js +85 -26
  151. package/src/runtime/server/remote-functions.js +640 -0
  152. package/src/runtime/server/respond.js +190 -131
  153. package/src/runtime/server/sourcemaps.js +183 -0
  154. package/src/runtime/server/state.js +53 -0
  155. package/src/runtime/server/utils.js +13 -155
  156. package/src/runtime/shared.js +20 -40
  157. package/src/runtime/utils.js +3 -0
  158. package/src/types/ambient-private.d.ts +11 -1
  159. package/src/types/ambient.d.ts +87 -36
  160. package/src/types/global-private.d.ts +25 -25
  161. package/src/types/internal.d.ts +163 -157
  162. package/src/types/private.d.ts +41 -1
  163. package/src/utils/error.js +28 -4
  164. package/src/utils/escape.js +9 -25
  165. package/src/utils/features.js +1 -1
  166. package/src/utils/filesystem.js +1 -23
  167. package/src/utils/fork.js +7 -2
  168. package/src/utils/hash.js +21 -0
  169. package/src/utils/http.js +8 -7
  170. package/src/utils/import.js +9 -2
  171. package/src/utils/imports.js +83 -0
  172. package/src/utils/mime.js +9 -0
  173. package/src/utils/page_nodes.js +6 -7
  174. package/src/utils/params.js +67 -0
  175. package/src/utils/regex.js +9 -0
  176. package/src/utils/routing.js +145 -73
  177. package/src/utils/shared-iterator.js +5 -0
  178. package/src/utils/streaming.js +14 -4
  179. package/src/utils/url.js +33 -2
  180. package/src/version.js +1 -1
  181. package/types/index.d.ts +2616 -2433
  182. package/types/index.d.ts.map +120 -106
  183. package/src/core/sync/write_ambient.js +0 -18
  184. package/src/core/sync/write_root.js +0 -148
  185. package/src/core/sync/write_tsconfig.js +0 -250
  186. package/src/exports/internal/server.js +0 -22
  187. package/src/exports/node/polyfills.js +0 -30
  188. package/src/runtime/server/app.js +0 -9
  189. package/src/runtime/server/remote.js +0 -457
  190. package/src/runtime/shared-server.js +0 -7
  191. package/src/runtime/telemetry/otel.js +0 -21
  192. package/src/runtime/telemetry/record_span.js +0 -65
  193. package/src/types/synthetic/$lib.md +0 -5
  194. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
  195. /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
@@ -1,7 +1,6 @@
1
- /** @import { AssetDependencies, ManifestData, SSRNode, ValidatedKitConfig } from 'types' */
1
+ /** @import { AssetDependencies, ManifestData, ValidatedConfig } from 'types' */
2
2
  /** @import { Manifest, Rolldown } from 'vite' */
3
3
  import fs from 'node:fs';
4
- import { mkdirp } from '../../../utils/filesystem.js';
5
4
  import {
6
5
  create_function_as_string,
7
6
  filter_fonts,
@@ -16,39 +15,16 @@ import { fix_css_urls } from '../../../utils/css.js';
16
15
  import { escape_for_interpolation } from '../../../utils/escape.js';
17
16
 
18
17
  /**
19
- * @overload Build without the client manifest so we can analyse the nodes.
20
18
  * @param {string} out
21
- * @param {ValidatedKitConfig} kit
19
+ * @param {ValidatedConfig} kit
22
20
  * @param {ManifestData} manifest_data
23
21
  * @param {Manifest} server_manifest
24
- * @param {null} client_manifest
25
- * @param {null} assets_path
26
- * @param {null} client_chunks
27
- * @param {string} root
28
- * @returns {void}
29
- */
30
- /**
31
- * @overload Or build with the client manifest
32
- * @param {string} out
33
- * @param {ValidatedKitConfig} kit
34
- * @param {ManifestData} manifest_data
35
- * @param {Manifest} server_manifest
36
- * @param {Manifest} client_manifest
22
+ * @param {Manifest | null} client_manifest
37
23
  * @param {string} assets_path
38
- * @param {Rolldown.RolldownOutput['output']} client_chunks
24
+ * @param {(Rolldown.OutputAsset | Rolldown.OutputChunk)[]} chunks
39
25
  * @param {string} root
40
26
  * @returns {void}
41
27
  */
42
- /**
43
- * @param {string} out
44
- * @param {ValidatedKitConfig} kit
45
- * @param {ManifestData} manifest_data
46
- * @param {Manifest} server_manifest
47
- * @param {Manifest | null} client_manifest
48
- * @param {string | null} assets_path
49
- * @param {Rolldown.RolldownOutput['output'] | null} client_chunks
50
- * @param {string} root
51
- */
52
28
  export function build_server_nodes(
53
29
  out,
54
30
  kit,
@@ -56,11 +32,11 @@ export function build_server_nodes(
56
32
  server_manifest,
57
33
  client_manifest,
58
34
  assets_path,
59
- client_chunks,
35
+ chunks,
60
36
  root
61
37
  ) {
62
- mkdirp(`${out}/server/nodes`);
63
- mkdirp(`${out}/server/stylesheets`);
38
+ fs.mkdirSync(`${out}/server/nodes`, { recursive: true });
39
+ fs.mkdirSync(`${out}/server/stylesheets`, { recursive: true });
64
40
 
65
41
  /**
66
42
  * Stylesheet names and their contents which are below the inline threshold
@@ -75,8 +51,8 @@ export function build_server_nodes(
75
51
  */
76
52
  let prepare_css_for_inlining = (css) => s(css);
77
53
 
78
- if (client_chunks && kit.inlineStyleThreshold > 0 && kit.output.bundleStrategy === 'split') {
79
- for (const chunk of client_chunks) {
54
+ if (chunks && kit.inlineStyleThreshold > 0 && kit.output.bundleStrategy === 'split') {
55
+ for (const chunk of chunks) {
80
56
  if (chunk.type !== 'asset' || !chunk.fileName.endsWith('.css')) {
81
57
  continue;
82
58
  }
@@ -132,6 +108,9 @@ export function build_server_nodes(
132
108
  }
133
109
  }
134
110
 
111
+ /** path to the `.svelte-kit` directory */
112
+ const out_dir = normalizePath(kit.outDir);
113
+
135
114
  for (let i = 0; i < manifest_data.nodes.length; i++) {
136
115
  const node = manifest_data.nodes[i];
137
116
 
@@ -139,7 +118,7 @@ export function build_server_nodes(
139
118
  const imports = [];
140
119
 
141
120
  // String representation of
142
- /** @type {SSRNode} */
121
+ /* @type {SSRNode} */
143
122
  /** @type {string[]} */
144
123
  const exports = [`export const index = ${i};`];
145
124
 
@@ -159,7 +138,7 @@ export function build_server_nodes(
159
138
  ? node.child_pages.some((child) => child.page_options?.ssr !== false)
160
139
  : node.page_options?.ssr !== false;
161
140
 
162
- if (node.component && client_manifest && uses_server_component) {
141
+ if (node.component && uses_server_component) {
163
142
  exports.push(
164
143
  'let component_cache;',
165
144
  `export const component = async () => component_cache ??= (await import('../${
@@ -169,7 +148,12 @@ export function build_server_nodes(
169
148
  }
170
149
 
171
150
  if (node.universal) {
172
- if (!!node.page_options && node.page_options.ssr === false) {
151
+ if (
152
+ (kit.router.type === 'hash' &&
153
+ node.page_options !== null &&
154
+ node.page_options?.ssr === undefined) ||
155
+ (node.page_options && node.page_options.ssr === false)
156
+ ) {
173
157
  exports.push(`export const universal = ${s(node.page_options, null, 2)};`);
174
158
  } else {
175
159
  imports.push(
@@ -189,18 +173,7 @@ export function build_server_nodes(
189
173
  exports.push(`export const server_id = ${s(node.server)};`);
190
174
  }
191
175
 
192
- if (
193
- client_manifest &&
194
- (node.universal || node.component) &&
195
- kit.output.bundleStrategy === 'split'
196
- ) {
197
- const entry_path = `${normalizePath(kit.outDir)}/generated/client-optimized/nodes/${i}.js`;
198
- const entry = find_deps(client_manifest, entry_path, true, root);
199
-
200
- // Eagerly load client stylesheets and fonts imported by the SSR-ed page to avoid FOUC.
201
- // However, if it is not used during SSR (not present in the server manifest),
202
- // then it can be lazily loaded in the browser.
203
-
176
+ if ((node.universal || node.component) && kit.output.bundleStrategy === 'split') {
204
177
  /** @type {AssetDependencies | undefined} */
205
178
  let component;
206
179
  if (node.component) {
@@ -213,25 +186,41 @@ export function build_server_nodes(
213
186
  universal = find_deps(server_manifest, node.universal, true, root);
214
187
  }
215
188
 
216
- /** @type {Set<string>} */
217
- const eager_css = new Set();
189
+ if (client_manifest) {
190
+ const entry_path = `${out_dir}/generated/client-optimized/nodes/${i}.js`;
191
+ const entry = find_deps(client_manifest, entry_path, true, root);
218
192
 
219
- entry.stylesheet_map.forEach((value, filepath) => {
220
- // pages and layouts are renamed to node indexes when optimised for the client
221
- // so we use the original filename instead to check against the server manifest
222
- if (filepath === entry_path) {
223
- filepath = node.component ?? filepath;
224
- }
193
+ // Eagerly load client stylesheets and fonts imported by the SSR-ed page to avoid FOUC.
194
+ // However, if it is not used during SSR (not present in the server manifest),
195
+ // then it can be lazily loaded in the browser.
225
196
 
226
- if (component?.stylesheet_map.has(filepath) || universal?.stylesheet_map.has(filepath)) {
227
- value.css.forEach((file) => eager_css.add(file));
228
- value.assets.forEach((file) => eager_assets.add(file));
229
- }
230
- });
197
+ /** @type {Set<string>} */
198
+ const eager_css = new Set();
231
199
 
232
- imported = entry.imports;
233
- stylesheets = Array.from(eager_css);
234
- fonts = filter_fonts(Array.from(eager_assets));
200
+ entry.stylesheet_map.forEach((value, filepath) => {
201
+ // pages and layouts are renamed to node indexes when optimised for the client
202
+ // so we use the original filename instead to check against the server manifest
203
+ if (filepath === entry_path) {
204
+ filepath = node.component ?? filepath;
205
+ }
206
+
207
+ if (component?.stylesheet_map.has(filepath) || universal?.stylesheet_map.has(filepath)) {
208
+ value.css.forEach((file) => eager_css.add(file));
209
+ value.assets.forEach((file) => eager_assets.add(file));
210
+ }
211
+ });
212
+
213
+ imported = entry.imports;
214
+ stylesheets = Array.from(eager_css);
215
+ fonts = filter_fonts(Array.from(eager_assets));
216
+ } else {
217
+ for (const entry of [component, universal]) {
218
+ if (!entry) continue;
219
+ imported.push(...entry.imports);
220
+ stylesheets.push(...entry.stylesheets);
221
+ fonts.push(...entry.fonts);
222
+ }
223
+ }
235
224
  }
236
225
 
237
226
  exports.push(
@@ -248,7 +237,7 @@ export function build_server_nodes(
248
237
 
249
238
  // Keep track of Vite asset filenames so that we avoid touching unrelated ones
250
239
  // when adjusting the inlined CSS
251
- if (stylesheets_to_inline.size && assets_path && eager_assets.size) {
240
+ if (stylesheets_to_inline.size && eager_assets.size) {
252
241
  vite_assets = new Set(
253
242
  Array.from(eager_assets).map((asset) => {
254
243
  return decodeURIComponent(asset.replace(`${assets_path}/`, ''));
@@ -11,22 +11,27 @@ import { posixify } from '../../../utils/os.js';
11
11
  * @param {typeof import('vite')} vite
12
12
  * @param {string} out
13
13
  * @param {Array<{ hash: string, file: string }>} remotes
14
+ * @param {Map<string, string>} remote_original_by_hash
14
15
  * @param {ServerMetadata} metadata
15
16
  * @param {string} cwd
16
- * @param {Rolldown.RolldownOutput} server_bundle
17
+ * @param {(Rolldown.OutputAsset | Rolldown.OutputChunk)[]} server_chunks
17
18
  * @param {NonNullable<import('vitest/config').ViteUserConfig['build']>['sourcemap']} sourcemap
18
19
  */
19
20
  export async function treeshake_prerendered_remotes(
20
21
  vite,
21
22
  out,
22
23
  remotes,
24
+ remote_original_by_hash,
23
25
  metadata,
24
26
  cwd,
25
- server_bundle,
27
+ server_chunks,
26
28
  sourcemap
27
29
  ) {
28
30
  if (remotes.length === 0) return;
29
31
 
32
+ /** @type {string[]} */
33
+ const chunk_paths = [];
34
+
30
35
  for (const remote of remotes) {
31
36
  const exports_map = metadata.remotes.get(remote.hash);
32
37
  if (!exports_map) continue;
@@ -42,11 +47,11 @@ export async function treeshake_prerendered_remotes(
42
47
 
43
48
  if (prerendered.length === 0) continue; // nothing to treeshake
44
49
 
45
- // remove file extension
46
- const remote_filename = path.basename(remote.file).split('.').slice(0, -1).join('.');
50
+ const original_id = remote_original_by_hash.get(remote.hash);
51
+ if (!original_id) continue;
47
52
 
48
- const remote_chunk = Object.values(server_bundle).find((chunk) => {
49
- return chunk.name === remote_filename;
53
+ const remote_chunk = server_chunks.find((chunk) => {
54
+ return chunk.type === 'chunk' && chunk.moduleIds.includes(original_id);
50
55
  });
51
56
 
52
57
  if (!remote_chunk) continue;
@@ -88,8 +93,13 @@ export async function treeshake_prerendered_remotes(
88
93
 
89
94
  const stubbed = modified_code.toString();
90
95
  fs.writeFileSync(chunk_path, stubbed);
96
+ chunk_paths.push(chunk_path);
97
+ }
91
98
 
92
- const bundle = /** @type {import('vite').Rolldown.RolldownOutput} */ (
99
+ if (!chunk_paths.length) return;
100
+
101
+ for (const chunk_path of chunk_paths) {
102
+ const bundle = /** @type {Rolldown.RolldownOutput} */ (
93
103
  await vite.build({
94
104
  configFile: false,
95
105
  build: {
@@ -97,7 +107,7 @@ export async function treeshake_prerendered_remotes(
97
107
  ssr: true,
98
108
  target: 'esnext',
99
109
  sourcemap,
100
- rollupOptions: {
110
+ rolldownOptions: {
101
111
  // avoid resolving imports
102
112
  external: (id) => !id.endsWith(chunk_path),
103
113
  input: {
@@ -108,17 +118,12 @@ export async function treeshake_prerendered_remotes(
108
118
  })
109
119
  );
110
120
 
111
- const chunk = bundle.output.find(
112
- (output) => output.type === 'chunk' && output.name === 'treeshaken'
113
- );
114
- if (chunk && chunk.type === 'chunk') {
115
- fs.writeFileSync(chunk_path, chunk.code);
116
-
117
- const chunk_sourcemap = bundle.output.find(
118
- (output) => output.type === 'asset' && output.fileName === chunk.fileName + '.map'
119
- );
120
- if (chunk_sourcemap && chunk_sourcemap.type === 'asset') {
121
- fs.writeFileSync(chunk_path + '.map', chunk_sourcemap.source);
121
+ // the only possible outputs are the treeshaken chunk and, with sourcemaps, its map
122
+ for (const output of bundle.output) {
123
+ if (output.type === 'chunk') {
124
+ fs.writeFileSync(chunk_path, output.code);
125
+ } else {
126
+ fs.writeFileSync(chunk_path + '.map', output.source);
122
127
  }
123
128
  }
124
129
  }
@@ -124,14 +124,6 @@ export function filter_fonts(assets) {
124
124
  return assets.filter((asset) => /\.(woff2?|ttf|otf)$/.test(asset));
125
125
  }
126
126
 
127
- /**
128
- * @param {import('types').ValidatedKitConfig} config
129
- * @returns {string}
130
- */
131
- export function assets_base(config) {
132
- return (config.paths.assets || config.paths.base || '.') + '/';
133
- }
134
-
135
127
  /**
136
128
  * Writes a function with arguments used by a template literal.
137
129
  * This helps us store strings in a module and inject values at runtime.