Skip to content

Commit

Permalink
make manifest.mimeTypes part of the public API (#4302)
Browse files Browse the repository at this point in the history
* make manifest.mime part of the public API

* change mime to mimeTypes

* update changeset
  • Loading branch information
Rich-Harris authored Mar 14, 2022
1 parent 03c29de commit f95e5c4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-pants-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Make `manifest.mimeTypes` part of the public API
2 changes: 1 addition & 1 deletion packages/kit/src/core/dev/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export async function create_plugin(config, cwd) {
manifest = {
appDir: config.kit.appDir,
assets: new Set(manifest_data.assets.map((asset) => asset.file)),
mimeTypes: get_mime_lookup(manifest_data),
_: {
mime: get_mime_lookup(manifest_data),
entry: {
file: `/@fs${runtime}/client/start.js`,
css: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/generate_manifest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function generate_manifest({ build_data, relative_path, routes, format =
return `{
appDir: ${s(build_data.app_dir)},
assets: new Set(${s(assets)}),
mimeTypes: ${s(get_mime_lookup(build_data.manifest_data))},
_: {
mime: ${s(get_mime_lookup(build_data.manifest_data))},
entry: ${s(build_data.client.entry)},
nodes: [
${Array.from(bundled_nodes.values()).map(node => importer(node.path)).join(',\n\t\t\t\t')}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/load_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export async function load_node({

if (options.read) {
const type = is_asset
? options.manifest._.mime[filename.slice(filename.lastIndexOf('.'))]
? options.manifest.mimeTypes[filename.slice(filename.lastIndexOf('.'))]
: 'text/html';

response = new Response(options.read(file), {
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,10 @@ export class Server {
export interface SSRManifest {
appDir: string;
assets: Set<string>;
mimeTypes: Record<string, string>;

/** private fields */
_: {
mime: Record<string, string>;
entry: {
file: string;
js: string[];
Expand Down

0 comments on commit f95e5c4

Please sign in to comment.