Skip to content

Commit

Permalink
Improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy committed Dec 8, 2021
1 parent d5eb876 commit 06f8a8e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions helpers/rollup/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
'use strict';

function handleCircularDependancyWarning(warning, rollupWarn) {
/**
* @typedef {import('rollup')} rollup
* @typedef {import('rollup').WarningHandlerWithDefault} rollup.WarningHandlerWithDefault
*/

/**
* @type {rollup.WarningHandlerWithDefault}
*/
function handleCircularDependancyWarning(warning, warningHandler) {
const packagesWithCircularDependencies = [
'util/',
'assert/',
Expand All @@ -10,12 +18,15 @@ function handleCircularDependancyWarning(warning, rollupWarn) {
if (
!(
warning.code === 'CIRCULAR_DEPENDENCY' &&
packagesWithCircularDependencies.some((modulePath) =>
warning.importer.includes(modulePath)
)
packagesWithCircularDependencies.some((modulePath) => {
if (typeof warning.importer !== 'string') {
return false;
}
return warning.importer.includes(modulePath);
})
)
) {
rollupWarn(warning);
warningHandler(warning);
}
}

Expand Down

0 comments on commit 06f8a8e

Please sign in to comment.