Skip to content

Commit

Permalink
share rollup onLog across all builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Aug 27, 2024
1 parent 6232f4a commit 457d235
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,7 @@ function esmConfig() {
];

return {
onLog(level, log, handler) {
switch (log.code) {
case 'CIRCULAR_DEPENDENCY':
if (log.ids.some((id) => id.includes('node_modules/rsvp/lib/rsvp'))) {
// rsvp has some internal cycles but they don't bother us
return;
}
process.stderr.write(
`Circular dependency:\n${log.ids.map((id) => ' ' + id).join('\n')}\n`
);
throw new Error(`Circular dependencies are forbidden`);
case 'EMPTY_BUNDLE':
// Some of our entrypoints are type-only and result in empty bundles.
// We prune the actual empty files elsewhere in this config (see
// pruneEmptyBundles). This silences the warning from rollup about
// them.
return;
default:
handler(level, log);
}
},
onLog: handleRollupWarnings,
input: {
...renameEntrypoints(exposedDependencies(), (name) => join('packages', name, 'index')),
...renameEntrypoints(packages(), (name) => join('packages', name)),
Expand Down Expand Up @@ -126,6 +106,7 @@ function legacyBundleConfig(input, output, { isDeveloping, isExternal }) {

interop: 'esModule',
},
onLog: handleRollupWarnings,
plugins: [
amdDefineSupport(),
...(isDeveloping ? [concatenateAMDEntrypoints()] : []),
Expand Down Expand Up @@ -516,3 +497,25 @@ function pruneEmptyBundles() {
},
};
}

function handleRollupWarnings(level, log, handler) {
switch (log.code) {
case 'CIRCULAR_DEPENDENCY':
if (log.ids.some((id) => id.includes('node_modules/rsvp/lib/rsvp'))) {
// rsvp has some internal cycles but they don't bother us
return;
}
process.stderr.write(
`Circular dependency:\n${log.ids.map((id) => ' ' + id).join('\n')}\n`
);
throw new Error(`Circular dependencies are forbidden`);
case 'EMPTY_BUNDLE':
// Some of our entrypoints are type-only and result in empty bundles.
// We prune the actual empty files elsewhere in this config (see
// pruneEmptyBundles). This silences the warning from rollup about
// them.
return;
default:
handler(level, log);
}
}

0 comments on commit 457d235

Please sign in to comment.