Skip to content
Permalink
Browse files
Switch to a code-splitting build and update dependencies (#3020)
* Switch to a code-splitting build and update dependencies

* Fix case where default exports were not properly deconflicted against
chunk names
  • Loading branch information
lukastaegert committed Aug 5, 2019
1 parent 2443783 commit 871bfa06b8818f94efd9dcae3f34b0b7e3ee73de
Show file tree
Hide file tree
Showing 35 changed files with 579 additions and 293 deletions.
@@ -7,8 +7,6 @@ _actual.js
coverage
.commithash
.idea
bin/rollup
bin/rollup.map
test/_tmp
test/hooks/tmp
test/tmp
File renamed without changes.
@@ -1,7 +1,7 @@
import help from 'help.md';
import minimist from 'minimist';
import { version } from 'package.json';
import { commandAliases } from '../../src/utils/mergeOptions';
import { commandAliases } from '../src/utils/mergeOptions';
import run from './run/index';

const command = minimist(process.argv.slice(2), {
@@ -1,6 +1,6 @@
import tc from 'turbocolor';
import { RollupError } from '../../src/rollup/types';
import relativeId from '../../src/utils/relativeId';
import { RollupError } from '../src/rollup/types';
import relativeId from '../src/utils/relativeId';

// log to stderr to keep `rollup main.js > bundle.js` from breaking
export const stderr = console.error.bind(console);
@@ -1,6 +1,6 @@
import tc from 'turbocolor';
import { RollupWarning } from '../../../src/rollup/types';
import relativeId from '../../../src/utils/relativeId';
import { RollupWarning } from '../../src/rollup/types';
import relativeId from '../../src/utils/relativeId';
import { stderr } from '../logging';

export interface BatchWarnings {
@@ -1,15 +1,8 @@
import ms from 'pretty-ms';
import * as rollup from 'rollup';
import tc from 'turbocolor';
import {
InputOptions,
OutputAsset,
OutputChunk,
OutputOptions,
RollupBuild,
SourceMap
} from '../../../src/rollup/types';
import relativeId from '../../../src/utils/relativeId';
import * as rollup from '../../src/node-entry';
import { InputOptions, OutputAsset, OutputChunk, OutputOptions, RollupBuild, SourceMap } from '../../src/rollup/types';
import relativeId from '../../src/utils/relativeId';
import { handleError, stderr } from '../logging';
import SOURCEMAPPING_URL from '../sourceMappingUrl';
import { BatchWarnings } from './batchWarnings';
@@ -42,7 +35,7 @@ export default function build(
}

return rollup
.rollup(inputOptions)
.rollup(inputOptions as any)
.then((bundle: RollupBuild) => {
if (useStdout) {
const output = outputOptions[0];
@@ -69,14 +62,15 @@ export default function build(
process.stdout.write('\n' + tc.cyan(tc.bold('//→ ' + file.fileName + ':')) + '\n');
process.stdout.write(source);
}
return null
});
}

return Promise.all(outputOptions.map(output => bundle.write(output) as Promise<any>)).then(
() => bundle
);
})
.then((bundle?: RollupBuild) => {
.then((bundle: RollupBuild | null) => {
if (!silent) {
warnings.flush();
stderr(
@@ -1,8 +1,8 @@
import { realpathSync } from 'fs';
import relative from 'require-relative';
import { WarningHandler } from '../../../src/rollup/types';
import mergeOptions, { GenericConfigObject } from '../../../src/utils/mergeOptions';
import { getAliasName } from '../../../src/utils/relativeId';
import { WarningHandler } from '../../src/rollup/types';
import mergeOptions, { GenericConfigObject } from '../../src/utils/mergeOptions';
import { getAliasName } from '../../src/utils/relativeId';
import { handleError } from '../logging';
import batchWarnings from './batchWarnings';
import build from './build';
@@ -1,9 +1,9 @@
import path from 'path';
import rollup from 'rollup';
import tc from 'turbocolor';
import { RollupBuild, RollupOutput } from '../../../src/rollup/types';
import { GenericConfigObject } from '../../../src/utils/mergeOptions';
import relativeId from '../../../src/utils/relativeId';
import * as rollup from '../../src/node-entry';
import { RollupBuild, RollupOutput } from '../../src/rollup/types';
import { GenericConfigObject } from '../../src/utils/mergeOptions';
import relativeId from '../../src/utils/relativeId';
import { handleError, stderr } from '../logging';
import batchWarnings from './batchWarnings';

File renamed without changes.
@@ -1,6 +1,6 @@
import prettyBytes from 'pretty-bytes';
import tc from 'turbocolor';
import { SerializedTimings } from '../../../src/rollup/types';
import { SerializedTimings } from '../../src/rollup/types';

export function printTimings(timings: SerializedTimings) {
Object.keys(timings).forEach(label => {
@@ -1,19 +1,20 @@
import dateTime from 'date-time';
import fs from 'fs';
import ms from 'pretty-ms';
import * as rollup from 'rollup';
import onExit from 'signal-exit';
import tc from 'turbocolor';
import * as rollup from '../../src/node-entry';
import {
InputOption,
RollupBuild,
RollupError,
RollupWatcher,
RollupWatchOptions,
WarningHandler,
WatcherOptions
} from '../../../src/rollup/types';
import mergeOptions, { GenericConfigObject } from '../../../src/utils/mergeOptions';
import relativeId from '../../../src/utils/relativeId';
} from '../../src/rollup/types';
import mergeOptions, { GenericConfigObject } from '../../src/utils/mergeOptions';
import relativeId from '../../src/utils/relativeId';
import { handleError, stderr } from '../logging';
import batchWarnings from './batchWarnings';
import loadConfigFile from './loadConfigFile';
@@ -29,11 +30,6 @@ interface WatchEvent {
result?: RollupBuild;
}

interface Watcher {
close: () => void;
on: (event: string, fn: (event: WatchEvent) => void) => void;
}

export default function watch(
configFile: string,
configs: GenericConfigObject[],
@@ -48,8 +44,8 @@ export default function watch(
);

const resetScreen = getResetScreen(isTTY && clearScreen);
let watcher: Watcher;
let configWatcher: Watcher;
let watcher: RollupWatcher;
let configWatcher: RollupWatcher;

function processConfigs(configs: GenericConfigObject[]): RollupWatchOptions[] {
return configs.map(options => {
@@ -77,7 +73,7 @@ export default function watch(
}

function start(configs: RollupWatchOptions[]) {
watcher = rollup.watch(configs);
watcher = rollup.watch(configs as any);

watcher.on('event', (event: WatchEvent) => {
switch (event.code) {
@@ -190,7 +186,7 @@ export default function watch(
restarting = true;

loadConfigFile(configFile, command)
.then((_configs: RollupWatchOptions[]) => {
.then(() => {
restarting = false;

if (aborted) {
File renamed without changes.

0 comments on commit 871bfa0

Please sign in to comment.