Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Correctly calculate leftover css #1413

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/core/create_compilers/extract_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ export default function extract_css(
let asset_dir = `${dirs.dest}/client`;
if (process.env.SAPPER_LEGACY_BUILD) asset_dir += '/legacy';

const unclaimed = new Set(client_result.css_files.map(x => x.id));

const unclaimed = new Set<string>(client_result.css_files.map(x => x.id));
const lookup = new Map();
client_result.chunks.forEach(chunk => {
lookup.set(chunk.file, chunk);
Expand Down Expand Up @@ -168,7 +167,6 @@ export default function extract_css(
const entry_chunk = client_result.chunks.find(chunk => chunk.modules.indexOf(entry) !== -1);

const entry_chunk_dependencies: Set<Chunk> = new Set([entry_chunk]);
const entry_css_modules: string[] = [];

// recursively find the chunks this component depends on
entry_chunk_dependencies.forEach(chunk => {
Expand All @@ -181,9 +179,6 @@ export default function extract_css(
if (chunks_with_css.has(chunk)) {
chunk.modules.forEach(file => {
unclaimed.delete(file);
if (css_map.has(file)) {
entry_css_modules.push(file);
}
});
}
});
Expand Down Expand Up @@ -250,11 +245,7 @@ export default function extract_css(
fs.writeFileSync(`${asset_dir}/${file}`, replaced);
});

unclaimed.forEach(file => {
entry_css_modules.push(file);
});

const leftover = get_css_from_modules(entry_css_modules, css_map, asset_dir);
const leftover = get_css_from_modules(Array.from(unclaimed), css_map, asset_dir);
if (leftover) {
let { code, map } = leftover;

Expand Down