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

Replace deprecated folder export with pattern export #3896

Merged
merged 1 commit into from Dec 3, 2020

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
Resolves #3890

Description

This follows official Node (14) guidance to prefer a pattern export over a folder export.

@rollup-bot
Copy link
Collaborator

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#improve-package-exports

or load it into the REPL:
https://rollupjs.org/repl/?circleci=13766

@codecov
Copy link

codecov bot commented Dec 3, 2020

Codecov Report

Merging #3896 (9569e5f) into master (11315fd) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3896   +/-   ##
=======================================
  Coverage   97.07%   97.07%           
=======================================
  Files         187      187           
  Lines        6538     6538           
  Branches     1901     1901           
=======================================
  Hits         6347     6347           
  Misses        101      101           
  Partials       90       90           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11315fd...9569e5f. Read the comment docs.

@lukastaegert lukastaegert merged commit bbfdedd into master Dec 3, 2020
@lukastaegert lukastaegert deleted the improve-package-exports branch December 3, 2020 06:03
@Crenshinibon
Copy link

Hi. I just figured out, that this change broke the possibility to require "rollup/dist/loadConfigFile", that 'others' (in my case "cy-rollup") are using ... don't know if this warants an issue here or over there. But you can't even require loadConfigFile from the plain node repl ...

@guybedford
Copy link
Contributor

@Crenshinibon if you use the explicit .js extension it should work correctly then.

@Crenshinibon
Copy link

Crenshinibon commented Dec 5, 2020

Yes, probably. But I'm only using 'cy-rollup' which then requires 'loadConfigFile'.

Check out the docs regarding subpath patterns:
https://nodejs.org/api/packages.html#packages_subpath_patterns

I think you need to export: "./dist/*": "./dist/*.js"

Changing this locally brings everything back to normal for me.

@lukastaegert
Copy link
Member Author

I guess I did not realize this would be a breaking change. I will revert this for now because as I see it, there is no way to allow requires both with and without extension to work with a pattern export.

@lukastaegert lukastaegert mentioned this pull request Dec 6, 2020
9 tasks
@robertknight
Copy link

I guess I did not realize this would be a breaking change. I will revert this for now because as I see it, there is no way to allow requires both with and without extension to work with a pattern export.

I found a pattern that enables both styles of import (with and without extension) as long as you can assume that all files that will be imported from dist/ have a .js extension:

"exports": {
  ...,
  "./dist/*.js": "./dist/*.js",
  "./dist/*": "./dist/*.js"
}
$ node
Welcome to Node.js v16.11.1.
Type ".help" for more information.
> require('rollup/dist/loadConfigFile')
[AsyncFunction: loadAndParseConfigFile]
> require('rollup/dist/loadConfigFile.js')
[AsyncFunction: loadAndParseConfigFile]

Would this be an acceptable solution? This won't allow requiring of non-JS files in the dist/ directory, but the only documented module in this folder I can see is rollup/dist/loadConfigFile.

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.

Warning [DEP0148] DeprecationWarning
5 participants