Skip to content

Commit

Permalink
RollupFileBuild -> RollupSingleFileBuild
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 27, 2018
1 parent 3dec7b8 commit 1dcec6d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
8 changes: 4 additions & 4 deletions bin/src/run/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
InputOptions,
OutputChunk,
OutputOptions,
RollupFileBuild,
RollupSingleFileBuild,
RollupBuild,
OutputBundle
} from '../../../src/rollup/types';
Expand Down Expand Up @@ -47,7 +47,7 @@ export default function build(

return rollup
.rollup(inputOptions)
.then((bundle: RollupFileBuild | RollupBuild) => {
.then((bundle: RollupSingleFileBuild | RollupBuild) => {
if (useStdout) {
const output = outputOptions[0];
if (output.sourcemap && output.sourcemap !== 'inline') {
Expand All @@ -57,7 +57,7 @@ export default function build(
});
}

return (<RollupFileBuild>bundle).generate(output).then(({ code, map }) => {
return (<RollupSingleFileBuild>bundle).generate(output).then(({ code, map }) => {
if (!code) return;
if (output.sourcemap === 'inline') {
code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}\n`;
Expand All @@ -72,7 +72,7 @@ export default function build(
output => bundle.write(output)
).then(() => bundle);
})
.then((bundle?: RollupFileBuild | RollupBuild) => {
.then((bundle?: RollupSingleFileBuild | RollupBuild) => {
warnings.flush();
if (!silent)
stderr(
Expand Down
4 changes: 2 additions & 2 deletions bin/src/run/loadConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import rollup from 'rollup';
import batchWarnings from './batchWarnings';
import relativeId from '../../../src/utils/relativeId';
import { handleError, stderr } from '../logging';
import { InputOptions, RollupFileBuild } from '../../../src/rollup/types';
import { InputOptions, RollupSingleFileBuild } from '../../../src/rollup/types';

interface NodeModuleWithCompile extends NodeModule {
_compile(code: string, filename: string): any;
Expand All @@ -25,7 +25,7 @@ export default function loadConfigFile(
},
onwarn: warnings.add
})
.then((bundle: RollupFileBuild) => {
.then((bundle: RollupSingleFileBuild) => {
if (!silent && warnings.count > 0) {
stderr(chalk.bold(`loaded ${relativeId(configFile)} with warnings`));
warnings.flush();
Expand Down
20 changes: 13 additions & 7 deletions bin/src/run/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { printTimings } from './timings';
import {
RollupError,
RollupWatchOptions,
RollupFileBuild,
RollupSingleFileBuild,
RollupBuild,
InputOption
} from '../../../src/rollup/types';
Expand All @@ -24,7 +24,7 @@ interface WatchEvent {
input?: InputOption;
output?: string[];
duration?: number;
result?: RollupFileBuild | RollupBuild;
result?: RollupSingleFileBuild | RollupBuild;
}

interface Watcher {
Expand Down Expand Up @@ -52,7 +52,7 @@ export default function watch(
let watcher: Watcher;
let configWatcher: Watcher;

let processConfigsErr;
let processConfigsErr: any;

function processConfigs(configs: RollupWatchOptions[]): RollupWatchOptions[] {
return configs.map(options => {
Expand Down Expand Up @@ -116,12 +116,18 @@ export default function watch(
case 'BUNDLE_START':
if (!silent) {
let input = event.input;
if ( typeof input !== 'string' ) {
input = Array.isArray(input) ? input.join(', ') : Object.values(input).join(', ')
if (typeof input !== 'string') {
input = Array.isArray(input)
? input.join(', ')
: Object.keys(input)
.map(key => (<Record<string, string>>input)[key])
.join(', ');
}
stderr(
chalk.cyan(
`bundles ${chalk.bold(input)}${chalk.bold(event.output.map(relativeId).join(', '))}...`
`bundles ${chalk.bold(input)}${chalk.bold(
event.output.map(relativeId).join(', ')
)}...`
)
);
}
Expand Down Expand Up @@ -200,7 +206,7 @@ export default function watch(
restarting = true;

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

if (aborted) {
Expand Down
6 changes: 3 additions & 3 deletions src/rollup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OutputChunk,
OutputBundle,
OutputFile,
RollupFileBuild,
RollupSingleFileBuild,
RollupBuild,
ChunkDefinition
} from './types';
Expand Down Expand Up @@ -103,7 +103,7 @@ function getInputOptions(rawInputOptions: GenericConfigObject): any {

export default function rollup(
rawInputOptions: GenericConfigObject
): Promise<RollupFileBuild | RollupBuild> {
): Promise<RollupSingleFileBuild | RollupBuild> {
try {
const inputOptions = getInputOptions(rawInputOptions);
initialiseTimers(inputOptions);
Expand Down Expand Up @@ -366,7 +366,7 @@ export default function rollup(
}

const cache = graph.getCache();
const result: RollupFileBuild | RollupBuild = {
const result: RollupSingleFileBuild | RollupBuild = {
cache,
generate: <any>((rawOutputOptions: GenericConfigObject) => {
const promise = generate(rawOutputOptions, false).then(
Expand Down
4 changes: 2 additions & 2 deletions src/rollup/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export interface RollupCache {
modules: ModuleJSON[];
}

export interface RollupFileBuild {
export interface RollupSingleFileBuild {
// TODO: consider deprecating to match code splitting
imports: string[];
exports: { name: string; originalName: string; moduleId: string }[];
Expand Down Expand Up @@ -358,7 +358,7 @@ export interface RollupDirOptions extends InputOptions {
output?: OutputOptionsDir;
}

export function rollup(options: RollupFileOptions): Promise<RollupFileBuild>;
export function rollup(options: RollupFileOptions): Promise<RollupSingleFileBuild>;
export function rollup(options: RollupDirOptions): Promise<RollupBuild>;

export interface Watcher extends EventEmitter {}
Expand Down
4 changes: 2 additions & 2 deletions src/watch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import rollup from '../rollup/index';
import {
InputOptions,
OutputOptions,
RollupFileBuild,
RollupSingleFileBuild,
RollupBuild,
OutputChunk,
ModuleJSON,
Expand Down Expand Up @@ -209,7 +209,7 @@ export class Task {
})
).then(() => result);
})
.then((result: RollupFileBuild | RollupBuild) => {
.then((result: RollupSingleFileBuild | RollupBuild) => {
this.watcher.emit('event', {
code: 'BUNDLE_END',
input: this.inputOptions.input,
Expand Down

0 comments on commit 1dcec6d

Please sign in to comment.