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

Add option to ignore warnings #198

Merged
merged 7 commits into from Feb 9, 2023
Merged

Add option to ignore warnings #198

merged 7 commits into from Feb 9, 2023

Conversation

traed
Copy link
Contributor

@traed traed commented Apr 1, 2022

This PR adds an option in rollup.config.js to ignore warnings about package.json not being exported. See discussion in #181.

@bluwy
Copy link
Member

bluwy commented Apr 1, 2022

We had discussed about the warning a while ago and agreed to remove it altogether, so another option here is not needed. vite-plugin-svelte had already done so at sveltejs/vite-plugin-svelte#272.

This is also in my todo list for rollup-plugin-svelte but never got to it. Feel free to tackle it if you like. Besides removing the warning, we also need to manually read the package.json like in vite-plugin-svelte. The refactoring required is a bit large.

@traed
Copy link
Contributor Author

traed commented Apr 1, 2022

Ok. I'm not super confident in the inner workings of this, but I've made a few changes now to port the recursive check from vite-plugin-svelte. Perhaps that will ease the workload for you?

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small requests, but overall this looks great to me. cc @dominikg

README.md Outdated
Comment on lines 59 to 62
// Ignore warnings regarding packages not exporting their package.json file
// by adding the package name to this array.
ignoreExportsWarn: [];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed now

index.d.ts Outdated
Comment on lines 41 to 45

/** Ignore warnings regarding packages not exporting their package.json file
* by adding the package name to this array.
*/
ignoreExportsWarn: string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this too

index.js Outdated
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') return {pkg: null, dir};
if (err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
dir = path.dirname(relative.resolve(name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dir = path.dirname(relative.resolve(name));
dir = path.dirname(relative.resolve(name, path.dirname(importer));

I think we need to specify the importer too. Perhaps we can abstract this as a function since it's used in the try block too.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. One more thing I forgot to mention, all variables and function names has to be in snake_case if they are not public API, e.g. parse_pkg, find_pkg, get_dir, etc

@dominikg
Copy link
Member

dominikg commented Apr 3, 2022

this looks ok for me, would be great to validate that it works as expected on windows.

The logic of resolving the "svelte" field in package.json isn't really bundler dependant so i wonder if this was something that could/should live in it's own package to be reusable? (out of scope for this PR)

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.

None yet

4 participants