Skip to content

Commit

Permalink
[fix] avoid manifest collisions (#5874)
Browse files Browse the repository at this point in the history
* [fix] avoid manifest collisions

* delete manifest at end of build
  • Loading branch information
benmccann authored Aug 15, 2022
1 parent f4e98ad commit c141dce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-deers-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] avoid manifest collisions
4 changes: 3 additions & 1 deletion packages/kit/src/vite/build/build_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ export async function build_server(options, client) {
const { chunks } = await create_build(merged_config);

/** @type {import('vite').Manifest} */
const vite_manifest = JSON.parse(fs.readFileSync(`${output_dir}/server/manifest.json`, 'utf-8'));
const vite_manifest = JSON.parse(
fs.readFileSync(`${output_dir}/server/${vite_config.build.manifest}`, 'utf-8')
);

mkdirp(`${output_dir}/server/nodes`);
mkdirp(`${output_dir}/server/stylesheets`);
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/vite/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export const get_default_config = function ({ config, input, ssr, outDir }) {
base: assets_base(config.kit),
build: {
cssCodeSplit: true,
manifest: true,
// don't use the default name to avoid collisions with 'static/manifest.json'
manifest: 'vite-manifest.json',
outDir,
polyfillModulePreload: false,
rollupOptions: {
Expand Down
6 changes: 5 additions & 1 deletion packages/kit/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function kit() {
function client_build_info(assets, chunks) {
/** @type {import('vite').Manifest} */
const vite_manifest = JSON.parse(
fs.readFileSync(`${paths.client_out_dir}/manifest.json`, 'utf-8')
fs.readFileSync(`${paths.client_out_dir}/${vite_config.build.manifest}`, 'utf-8')
);

const entry_id = posixify(path.relative(cwd, `${runtime_directory}/client/start.js`));
Expand Down Expand Up @@ -437,6 +437,10 @@ function kit() {
`See ${colors.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
);
}

// avoid making the manifest available to users
fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
},

/**
Expand Down

0 comments on commit c141dce

Please sign in to comment.