rollup/rollup

onLog documentation is lacking something

faniell opened this issue · 2 comments

Documentation is

  • Missing
  • Needed
  • Confusing
  • Not sure?

Please Explain in Detail...

I am trying to use onLog with Rollup v3.23.0 and I use the example from the wiki:

// rollup.config.js
export default {
	//...
	onLog(level, log, handler) {
		if (log.code === 'CIRCULAR_DEPENDENCY') {
			return; // Ignore circular dependency warnings
		}
		if (level === 'warn') {
			handler('error', log); // turn other warnings into errors
		} else {
			handler(level, log); // otherwise, just print the log
		}
	}
};

This has no effect.

I also have tried to use it like this. Something I found going through the code for Rollup on Github:

// rollup.config.js
export default {
	input: "file.js",
	onLog: (level, log) => {
		if (log.code === 'CIRCULAR_DEPENDENCY') {
             		return; // Ignore circular dependency warnings
        	}
	},
	output: {...},
	plugins: [...]
}

Did not have success using onLog through a custom made plugin either.

Your Proposal for Changes

I might be misunderstanding or something is missing from the onLog documentation. Can there be made changes to the documentation to clarify onLog and how to use it in more detail. I was not able to find any other uses of onLog while Googling.

onLog was introduced in v3.25.0. I just wonder why you do not get a warning about an unknown option with v3.23.0

@lukastaegert It worked updating to v3.25.0, thank you very much. I did get an unknown option warning, but did not think much of it as I had gotten it a lot while passing custom arguments through the CLI. I'll have version in mind for the future.

Could it be a good thing to have a field in the documentation saying at which version the functionality it was introduced?