minor tidy up

This commit is contained in:
Rich Harris
2018-08-30 18:41:37 -04:00
parent 70fd7038b0
commit 7798f8f684
3 changed files with 10 additions and 10 deletions

View File

@@ -69,7 +69,7 @@ async function execute(emitter: EventEmitter, {
fs.writeFileSync(path.join(dest, 'build.json'), JSON.stringify({ fs.writeFileSync(path.join(dest, 'build.json'), JSON.stringify({
bundler, bundler,
shimport: bundler === 'rollup' && require('shimport/package.json').version, shimport: bundler === 'rollup' && require('shimport/package.json').version,
assets: client_result.assetsByChunkName assets: client_result.assets
})); }));
const server_stats = await server.compile(); const server_stats = await server.compile();
@@ -84,7 +84,7 @@ async function execute(emitter: EventEmitter, {
if (serviceworker) { if (serviceworker) {
create_serviceworker_manifest({ create_serviceworker_manifest({
routes: route_objects, routes: route_objects,
client_files: client_result.assets.map((file: string) => `client/${file}`) client_files: client_result.chunks.map((file: string) => `client/${file}`)
}); });
serviceworker_stats = await serviceworker.compile(); serviceworker_stats = await serviceworker.compile();

View File

@@ -280,7 +280,7 @@ class Watcher extends EventEmitter {
fs.writeFileSync(path.join(dest, 'build.json'), JSON.stringify({ fs.writeFileSync(path.join(dest, 'build.json'), JSON.stringify({
bundler: this.bundler, bundler: this.bundler,
shimport: this.bundler === 'rollup' && require('shimport/package.json').version, shimport: this.bundler === 'rollup' && require('shimport/package.json').version,
assets: result.assetsByChunkName assets: result.assets
}, null, ' ')); }, null, ' '));
const client_files = result.assets.map((file: string) => `client/${file}`); const client_files = result.assets.map((file: string) => `client/${file}`);

View File

@@ -17,8 +17,8 @@ export class CompileResult {
duration: number; duration: number;
errors: CompileError[]; errors: CompileError[];
warnings: CompileError[]; warnings: CompileError[];
assets: string[]; chunks: string[];
assetsByChunkName: Record<string, string>; assets: Record<string, string>;
} }
class RollupResult extends CompileResult { class RollupResult extends CompileResult {
@@ -32,15 +32,15 @@ class RollupResult extends CompileResult {
this.errors = compiler.errors.map(munge_rollup_warning_or_error); this.errors = compiler.errors.map(munge_rollup_warning_or_error);
this.warnings = compiler.warnings.map(munge_rollup_warning_or_error); // TODO emit this as they happen this.warnings = compiler.warnings.map(munge_rollup_warning_or_error); // TODO emit this as they happen
this.assets = compiler.chunks.map(chunk => chunk.fileName); this.chunks = compiler.chunks.map(chunk => chunk.fileName);
// TODO populate this properly. We don't have namedcompiler. chunks, as in // TODO populate this properly. We don't have namedcompiler. chunks, as in
// webpack, but we can have a route -> [chunk] map or something // webpack, but we can have a route -> [chunk] map or something
this.assetsByChunkName = {}; this.assets = {};
compiler.chunks.forEach(chunk => { compiler.chunks.forEach(chunk => {
if (compiler.input in chunk.modules) { if (compiler.input in chunk.modules) {
this.assetsByChunkName.main = chunk.fileName; this.assets.main = chunk.fileName;
} }
}); });
@@ -110,8 +110,8 @@ class WebpackResult extends CompileResult {
this.duration = info.time; this.duration = info.time;
this.assets = info.assets.map((chunk: { name: string }) => chunk.name); this.chunks = info.assets.map((chunk: { name: string }) => chunk.name);
this.assetsByChunkName = info.assetsByChunkName; this.assets = info.assetsByChunkName;
} }
print() { print() {