Skip to content
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

Forward package exports warning to onwarn #192

Closed
wants to merge 1 commit into from

Conversation

metonym
Copy link

@metonym metonym commented Jan 13, 2022

Closes #181

This PR forwards the package exports warning to the onwarn plugin option. This enables the consumer to omit the package exports warning without modifying the existing plugin API.

Desired UX

// rollup.config.js

svelte({
  onwarn: (warning) => {
    // do not print the package exports warning
    if (/(^-\s|package.json)/.test(warning)) return;

    // print all other warnings
    console.warn(warning);
  },
}),

By default, the warning will still be emitted if no onwarn argument is passed to the rollup-plugin-svelte plugin.

@Conduitry
Copy link
Member

This makes me nervous, because it's mixing together warnings coming from the compiler and warning generated by this plugin.

The warnings being emitted by the compiler (while currently undocumented outside of the code) are something that probably should be documented at some point, and I don't think we'd want to have to worry about "these warnings are specific to just this one bundler plugin".

If we still do want to go ahead with this, the warning being passed to onwarn should be an object that looks like the other objects already getting passed to it so we don't break people's existing onwarn functions - and not a string like this is currently doing.

@metonym
Copy link
Author

metonym commented Jan 13, 2022

because it's mixing together warnings coming from the compiler and warning generated by this plugin.

Now that you mention this, I'm inclined to agree.

Would you consider a PR that adds a boolean option to disable the specific warning? I understand if that's beyond the scope of this project.

@metonym metonym closed this Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any way to move "The following packages did not export their package.json" warning to onwarn?
2 participants