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

warning with rollup-plugin-svelte #467

Closed
saiballo opened this issue Jul 4, 2022 · 4 comments
Closed

warning with rollup-plugin-svelte #467

saiballo opened this issue Jul 4, 2022 · 4 comments

Comments

@saiballo
Copy link

saiballo commented Jul 4, 2022

If I use just-debounce-it with rollup I receive this warning:

[rollup-plugin-svelte] The following packages did not export their package.json file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.

@saibotsivad
Copy link
Contributor

saibotsivad commented Aug 4, 2022

Summarized Discussions

Reading through the discussion at rollup-plugin-svelte#181, probably the most pertinent information comes from the NodeJS docs:

Warning: Introducing the "exports" field prevents consumers of a package from using any entry points that are not defined, including the package.json (e.g. require('your-package/package.json'). This will likely be a breaking change.
https://nodejs.org/api/packages.html#packages_package_entry_points

And in a discussion on a different repo PR, a comment points out:

[...] it's about the "package.json" not being accessible to the outside world. Doesn't matter who or what is trying to read the package.json file, anything outside of this module's own files can't look at the file cuz it's not defined as an export.

This is very standard & has been part of the ESM resolution algorithm and official documentation + example since very early days.

Where was it introduced in just?

So for example, in just-kebab-case the package.json has the exports property which looks like this:

  "exports": {
    ".": {
      "require": "./index.js",
      "default": "./index.mjs"
    }
  },

It looks like all these were introduced in #315 "enable esm", which was a big refactor and update.

What's the solution?

The "enable esm" change was not recorded as a breaking change, see conversation, however the NodeJS docs say

Introducing the "exports" field [...] will likely be a breaking change.

and indeed it is a breaking change for projects that want to import the package.json file, so it seems like a bug-fix patch is in order to add the package.json file to the exports.

That would look like this:

  "exports": {
    ".": {
      "require": "./index.js",
      "default": "./index.mjs"
    },
    "./package.json": "./package.json"
  },

Unfortunately, this would need to be done to all the packages.

@saibotsivad
Copy link
Contributor

@angus-c if you'd like a pull request for the above solution, I can put one together that "just" (tee-hee!) runs that diff for all appropriate package.json files.

@angus-c
Copy link
Owner

angus-c commented Aug 6, 2022

That would be great. Thanks!

@saibotsivad
Copy link
Contributor

I got you fam, see PR #484 🎉

angus-c added a commit that referenced this issue Aug 7, 2022
@angus-c angus-c closed this as completed in 64f923f Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants