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

Build and plugin hooks refactoring for code splitting and asset emission workflows #2208

Merged
merged 42 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a329517
plugin api ajustments
guybedford Apr 14, 2018
9e8bbf7
unified plugin interface, pluginContext
guybedford Apr 16, 2018
555259c
typing fixes
guybedford Apr 16, 2018
b00204a
add onbuildstart and onbuildend hooks
guybedford Apr 17, 2018
f49dd00
sync-only onbuildstart, onbuildend
guybedford Apr 17, 2018
3aace48
onbuilderror hook
guybedford Apr 17, 2018
62a263f
update onbuildend hook to take error argument
guybedford Apr 17, 2018
05878ce
update transformChunk return type
guybedford Apr 17, 2018
279df73
ensure name on OutputChunk and remove repeated type declarations
guybedford Apr 17, 2018
13afe1f
transformChunk argument
guybedford Apr 17, 2018
dd48b73
handle process detection, remove unused types
guybedford Apr 18, 2018
fd5bd24
update transformChunk return value types
guybedford Apr 18, 2018
3f1bc22
feedback wip
guybedford Apr 23, 2018
6223d40
asset emission API, unify code-splitting, single-file codepath
guybedford Apr 29, 2018
6c6ca51
complete asset emission API
guybedford Apr 30, 2018
807b43e
experimentalCodeSplitting to always return files object, inlineDynami…
guybedford Apr 30, 2018
cf4bc3f
generate assets first to enable inlining
guybedford Apr 30, 2018
95dd5b7
api refactoring, very simple asset handling
guybedford May 18, 2018
0211a03
amd and cjs browser import meta cases
guybedford May 22, 2018
cc13455
meta property
guybedford May 22, 2018
24c33ac
rework asset handling
guybedford May 22, 2018
1bfe6b6
test wip
guybedford May 22, 2018
bfa844f
complete asset plugins tests
guybedford May 22, 2018
cc4a6bd
fix up meta url tests with compact support
guybedford May 22, 2018
0421369
add require to meta url test context
guybedford May 22, 2018
3aadd5e
fix up url test
guybedford May 22, 2018
e0959c4
fix url tests for node 4
guybedford May 22, 2018
0933943
clean up typing, revert entry point moves
guybedford May 22, 2018
6b49257
RollupFileBuild -> RollupSingleFileBuild
guybedford May 26, 2018
0b59405
support unique bundle-time asset emission
guybedford May 28, 2018
bd166ae
expand hooks tests
guybedford May 28, 2018
d110564
pr feedback, asset url output and mechanism tests
guybedford May 30, 2018
4d4ec4c
unflag experimentalDynamicImport
guybedford May 30, 2018
de83598
remove processChunks hook for generateBundle, include tree-shaking in…
guybedford May 30, 2018
55ac656
use MagicString.length()
guybedford May 30, 2018
7232bec
singleInputChunk tweaks
guybedford May 31, 2018
ee53a31
update magic-string
guybedford May 31, 2018
994bd6e
add url parse dependency
guybedford Jun 1, 2018
2a634c7
provide bundle on output property
guybedford Jun 1, 2018
b9f085a
use native URL in tests if possible
guybedford Jun 4, 2018
649a046
tweak dir / file error message cases
guybedford Jun 4, 2018
a7058a6
fix inlineDynamicImports entry misrecognition bug
guybedford Jun 4, 2018
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
13 changes: 7 additions & 6 deletions bin/src/run/build.ts
Original file line number Diff line number Diff line change
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
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, 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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