Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to a code-splitting build and update dependencies #3020

Merged
merged 2 commits into from Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -7,8 +7,6 @@ _actual.js
coverage
.commithash
.idea
bin/rollup
bin/rollup.map
test/_tmp
test/hooks/tmp
test/tmp
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/src/index.ts → cli/index.ts
@@ -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), {
Expand Down
4 changes: 2 additions & 2 deletions bin/src/logging.ts → cli/logging.ts
@@ -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);
Expand Down
4 changes: 2 additions & 2 deletions bin/src/run/batchWarnings.ts → cli/run/batchWarnings.ts
@@ -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 {
Expand Down
18 changes: 6 additions & 12 deletions bin/src/run/build.ts → cli/run/build.ts
@@ -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';
Expand Down Expand Up @@ -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];
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions bin/src/run/index.ts → cli/run/index.ts
@@ -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';
Expand Down
8 changes: 4 additions & 4 deletions bin/src/run/loadConfigFile.ts → cli/run/loadConfigFile.ts
@@ -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';

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/src/run/timings.ts → cli/run/timings.ts
@@ -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 => {
Expand Down
22 changes: 9 additions & 13 deletions bin/src/run/watch.ts → cli/run/watch.ts
@@ -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';
Expand All @@ -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[],
Expand All @@ -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 => {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -190,7 +186,7 @@ export default function watch(
restarting = true;

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

if (aborted) {
Expand Down
File renamed without changes.