mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 03:25:24 +00:00
@@ -47,12 +47,13 @@ export default class RollupResult implements CompileResult {
|
||||
} else {
|
||||
for (const name in compiler.input) {
|
||||
const file = compiler.input[name];
|
||||
this.assets[name] = compiler.chunks.find(chunk => file in chunk.modules).fileName;
|
||||
const chunk = compiler.chunks.find(chunk => file in chunk.modules);
|
||||
if (chunk) this.assets[name] = chunk.fileName;
|
||||
}
|
||||
}
|
||||
|
||||
this.summary = compiler.chunks.map(chunk => {
|
||||
const size_color = chunk.code.length > 150000 ? colors.bold.red : chunk.code.length > 50000 ? colors.bold.yellow : colors.bold.white;
|
||||
const size_color = chunk.code.length > 150000 ? colors.bold().red : chunk.code.length > 50000 ? colors.bold().yellow : colors.bold().white;
|
||||
const size_label = left_pad(pb(chunk.code.length), 10);
|
||||
|
||||
const lines = [size_color(`${size_label} ${chunk.fileName}`)];
|
||||
|
||||
@@ -153,7 +153,7 @@ export default function extract_css(client_result: CompileResult, components: Pa
|
||||
chunks_with_css.add(chunk);
|
||||
});
|
||||
|
||||
const entry = path.resolve(dirs.src, 'client.js');
|
||||
const entry = path.resolve(dirs.src, 'app.mjs');
|
||||
const entry_chunk = client_result.chunks.find(chunk => chunk.modules.indexOf(entry) !== -1);
|
||||
|
||||
const entry_chunk_dependencies: Set<Chunk> = new Set([entry_chunk]);
|
||||
@@ -161,6 +161,8 @@ export default function extract_css(client_result: CompileResult, components: Pa
|
||||
|
||||
// recursively find the chunks this component depends on
|
||||
entry_chunk_dependencies.forEach(chunk => {
|
||||
if (!chunk) return; // TODO why does this happen?
|
||||
|
||||
chunk.imports.forEach(file => {
|
||||
entry_chunk_dependencies.add(lookup.get(file));
|
||||
});
|
||||
@@ -182,7 +184,8 @@ export default function extract_css(client_result: CompileResult, components: Pa
|
||||
|
||||
if (!chunk) {
|
||||
// this should never happen!
|
||||
throw new Error(`Could not find chunk that owns ${component.file}`);
|
||||
return;
|
||||
// throw new Error(`Could not find chunk that owns ${component.file}`);
|
||||
}
|
||||
|
||||
const chunk_dependencies: Set<Chunk> = new Set([chunk]);
|
||||
@@ -190,6 +193,8 @@ export default function extract_css(client_result: CompileResult, components: Pa
|
||||
|
||||
// recursively find the chunks this component depends on
|
||||
chunk_dependencies.forEach(chunk => {
|
||||
if (!chunk) return; // TODO why does this happen?
|
||||
|
||||
chunk.imports.forEach(file => {
|
||||
chunk_dependencies.add(lookup.get(file));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user