-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Circular dependencies - console warning #5033
Comments
Ok, I deleted I forgot to mention, this only applies to I export all the types that I manually create in the project so that the user can import these types later if he needs them. I guess that's why it gives that warning, although I read somewhere in the official typescript repo that it's perfectly fine to re-export everything in types. Also, I found in the documentation onwarn option that can be used to manually silence this warning. Here is a simple example: // rollup.config.js
import { defineConfig } from 'rollup'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import pkg from './package.json' assert { type: 'json' }
const exports = {
main: pkg.exports['.']
}
const noop = () => {}
export default defineConfig([
{
input: './src/index.ts',
output: [
{ file: exports.main.import, format: 'esm' },
{ file: exports.main.require, format: 'cjs' }
],
plugins: [nodeResolve(), esbuild()]
},
{
input: './src/types/index.ts',
output: { file: exports.main.types, format: 'esm' },
plugins: [dts()],
// Silences the warning only for `circular dependency`
onwarn(warning) {
if (warning.code === 'CIRCULAR_DEPENDENCY') noop
else console.log(warning)
}
}
]) It would be great if there was an official option to deactivate individual warnings with simple {
input: './src/types/index.ts',
output: { file: exports.main.types, format: 'esm' },
plugins: [dts()],
// quick example
warnings: {
circularDependency: false
}
} |
Hmmm, Maybe we can have a config to filter logs? {
disabledLogs: [ 'CIRCULAR_DEPENDENCY', 'CIRCULAR_REEXPORT' ]
} @lukastaegert looking forward to your thoughts. |
Not yet convinced about this. It does not appear to be much shorter than writing a function, so the convenience would be limited. In any case, I am currently working on a related feature that should probably be finalised first: #5035 As I only have a phone for the next two weeks, it will take a little time to be completed, though. |
yeah, I think so too.
Oh, I'm sorry if I bothered you. |
Hmm, it seems that this is not a bug after all, and there is a solution for manually silencing the warning. So, as far as I'm concerned, you can close this as resolved. |
According to this example from Lukas, I was able to silence the warning and it works as expected. Here is a complete example if anyone is interested: // rollup.config.js
import { defineConfig } from 'rollup'
import { getLogFilter } from 'rollup/getLogFilter'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import pkg from './package.json' assert { type: 'json' }
const exports = {
main: pkg.exports['.']
}
// Filters logs
const logFilter = getLogFilter(['!code:CIRCULAR_DEPENDENCY'])
const onLog = (level, log, handler) => {
if (logFilter(log)) handler(level, log)
}
export default defineConfig([
{
input: './src/index.ts',
output: [
{ file: exports.main.import, format: 'esm' },
{ file: exports.main.require, format: 'cjs' }
],
plugins: [esbuild()]
},
{
input: './src/types/index.ts',
output: { file: exports.main.types, format: 'esm' },
plugins: [dts()],
onLog
}
// ...
]) Thanks for your time and help 👍 I'm closing this as resolved. |
Rollup Version
3.25.0
Operating System (or Browser)
mac
Node Version (if applicable)
18.12.1
Link To Reproduction
Expected Behaviour
No console warnings.
Actual Behaviour
Hi, in the latest version
3.25.0
it throws a warning in the console on build:(!) Circular dependencies ...
In the previous version
3.24.1
this is not the case.The text was updated successfully, but these errors were encountered: