Skip to content

Commit ca3c4c5

Browse files
committed
remove format option from generateManifest - closes #7798
1 parent 29c5f9d commit ca3c4c5

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

.changeset/shy-queens-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[breaking] remove `format` option from `generateManifest(...)`

packages/kit/src/core/generate_manifest/index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import { join_relative } from '../../utils/filesystem.js';
1111
* build_data: import('types').BuildData;
1212
* relative_path: string;
1313
* routes: import('types').RouteData[];
14-
* format?: 'esm' | 'cjs'
1514
* }} opts
1615
*/
17-
export function generate_manifest({ build_data, relative_path, routes, format = 'esm' }) {
16+
export function generate_manifest({ build_data, relative_path, routes }) {
1817
/**
1918
* @type {Map<any, number>} The new index of each node in the filtered nodes array
2019
*/
@@ -55,13 +54,7 @@ export function generate_manifest({ build_data, relative_path, routes, format =
5554
});
5655

5756
/** @type {(path: string) => string} */
58-
const load =
59-
format === 'esm'
60-
? (path) => `import('${path}')`
61-
: (path) => `Promise.resolve().then(() => require('${path}'))`;
62-
63-
/** @type {(path: string) => string} */
64-
const loader = (path) => `() => ${load(path)}`;
57+
const loader = (path) => `() => import('${path}')`;
6558

6659
const assets = build_data.manifest_data.assets.map((asset) => asset.file);
6760
if (build_data.service_worker) {
@@ -115,7 +108,7 @@ export function generate_manifest({ build_data, relative_path, routes, format =
115108
}).filter(Boolean).join(',\n\t\t\t\t')}
116109
],
117110
matchers: async () => {
118-
${Array.from(matchers).map(type => `const { match: ${type} } = await ${load(join_relative(relative_path, `/entries/matchers/${type}.js`))}`).join('\n\t\t\t\t')}
111+
${Array.from(matchers).map(type => `const { match: ${type} } = await import ('${(join_relative(relative_path, `/entries/matchers/${type}.js`))}')`).join('\n\t\t\t\t')}
119112
return { ${Array.from(matchers).join(', ')} };
120113
}
121114
}

packages/kit/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface Builder {
7272
*/
7373
createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise<void>;
7474

75-
generateManifest(opts: { relativePath: string; format?: 'esm' | 'cjs' }): string;
75+
generateManifest(opts: { relativePath: string }): string;
7676

7777
getBuildDirectory(name: string): string;
7878
getClientDirectory(): string;

packages/kit/types/private.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export interface AdapterEntry {
2121
* A function that is invoked once the entry has been created. This is where you
2222
* should write the function to the filesystem and generate redirect manifests.
2323
*/
24-
complete(entry: {
25-
generateManifest(opts: { relativePath: string; format?: 'esm' | 'cjs' }): string;
26-
}): MaybePromise<void>;
24+
complete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise<void>;
2725
}
2826

2927
// Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts

0 commit comments

Comments
 (0)