Back to Rolldown

Plugin Context Error

packages/rolldown/src/plugin/docs/plugin-context-error.md

1.0.1379 B
Original Source

In the onLog hook, this function is an easy way to turn warnings into errors while keeping all additional properties of the warning:

js
function myPlugin() {
  return {
    name: 'my-plugin',
    onLog(level, log) {
      if (level === 'warn' && log.code === 'THIS_IS_NOT_OK') {
        return this.error(log);
      }
    },
  };
}