Skip to content

Commit

Permalink
Merge branch 'plugin-chunking'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jun 6, 2018
2 parents 4ecbdb5 + a7058a6 commit 6f973a4
Show file tree
Hide file tree
Showing 66 changed files with 1,738 additions and 839 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,11 +2,12 @@

## 0.60.0
*unreleased*
* New plugin hooks: transformChunk, buildStart, buildEnd; extended plugin context with warn, error, resolveId, isExternal, emitAsset, setAssetSource and getAssetFileName available to any hook ([#2208](https://github.com/rollup/rollup/pull/2208))
* [BREAKING] Deprecate the `legacy` option and thus IE8 support ([#2141](https://github.com/rollup/rollup/pull/2141))
* Detect more known extensions and load .mjs without extension ([#2211](https://github.com/rollup/rollup/pull/2211))
* Enable naming SystemJS modules ([#2028](https://github.com/rollup/rollup/pull/2028))
* Add compact output mode ([#2151](https://github.com/rollup/rollup/pull/2151))
* Significantly improve sourcemap generation performance ([#2228](https://github.com/rollup/rollup/pull/2228))
* Enable naming SystemJS modules ([#2028](https://github.com/rollup/rollup/pull/2028))
* Do not use alternate screen if clearScreen is set in watch mode ([#2125](https://github.com/rollup/rollup/pull/2125))
* Allow object input form for code-splitting in watch mode ([#2217](https://github.com/rollup/rollup/pull/2217))
* Track reassignments of methods of exports from outside ([#2240](https://github.com/rollup/rollup/pull/2240))
Expand Down
13 changes: 7 additions & 6 deletions bin/src/run/build.ts
Expand Up @@ -9,8 +9,9 @@ import {
InputOptions,
OutputChunk,
OutputOptions,
Bundle,
BundleSet
RollupSingleFileBuild,
RollupBuild,
OutputBundle
} from '../../../src/rollup/types';
import { BatchWarnings } from './batchWarnings';
import { printTimings } from './timings';
Expand Down Expand Up @@ -46,7 +47,7 @@ export default function build(

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

return (<Bundle>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 @@ -66,12 +67,12 @@ export default function build(
});
}

return mapSequence<OutputOptions, Promise<OutputChunk | Record<string, OutputChunk>>>(
return mapSequence<OutputOptions, Promise<OutputChunk | OutputBundle>>(
outputOptions,
output => bundle.write(output)
).then(() => bundle);
})
.then((bundle?: Bundle | BundleSet) => {
.then((bundle?: RollupSingleFileBuild | RollupBuild) => {
warnings.flush();
if (!silent)
stderr(
Expand Down
4 changes: 2 additions & 2 deletions bin/src/run/loadConfigFile.ts
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, Bundle } 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: Bundle) => {
.then((bundle: RollupSingleFileBuild) => {
if (!silent && warnings.count > 0) {
stderr(chalk.bold(`loaded ${relativeId(configFile)} with warnings`));
warnings.flush();
Expand Down
26 changes: 19 additions & 7 deletions bin/src/run/watch.ts
Expand Up @@ -11,14 +11,20 @@ import loadConfigFile from './loadConfigFile';
import relativeId from '../../../src/utils/relativeId';
import { handleError, stderr } from '../logging';
import { printTimings } from './timings';
import { RollupError, RollupWatchOptions, Bundle, BundleSet, InputOption } from '../../../src/rollup/types';
import {
RollupError,
RollupWatchOptions,
RollupSingleFileBuild,
RollupBuild,
InputOption
} from '../../../src/rollup/types';
interface WatchEvent {
code?: string;
error?: RollupError | Error;
input?: InputOption;
output?: string[];
duration?: number;
result?: Bundle | BundleSet;
result?: RollupSingleFileBuild | RollupBuild;
}

interface Watcher {
Expand Down Expand Up @@ -46,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 @@ -110,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 @@ -194,7 +206,7 @@ export default function watch(
restarting = true;

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

if (aborted) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -80,7 +80,7 @@
"istanbul": "^0.4.3",
"lint-staged": "^7.1.1",
"locate-character": "^2.0.5",
"magic-string": "^0.24.1",
"magic-string": "^0.25.0",
"minimist": "^1.2.0",
"mocha": "^5.2.0",
"prettier": "^1.12.1",
Expand All @@ -104,7 +104,8 @@
"source-map-support": "^0.5.6",
"sourcemap-codec": "^1.4.1",
"typescript": "^2.8.3",
"uglify-js": "^3.3.25"
"uglify-js": "^3.3.25",
"url-parse": "^1.4.0"
},
"files": [
"dist/rollup.browser.js",
Expand Down

0 comments on commit 6f973a4

Please sign in to comment.