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 0945aac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/@ember/engine/lib/engine-parent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
@module @ember/engine
*/
import type EngineInstance from './instance';
import type EngineInstance from '../instance';

export const ENGINE_PARENT = Symbol('ENGINE_PARENT');

Expand Down
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 0945aac

Please sign in to comment.