X Tutup
The Wayback Machine - https://web.archive.org/web/20201023141509/https://github.com/nodejs/node/pull/35747
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

modules: runtime deprecate subpath folder mappings #35747

Open
wants to merge 8 commits into
base: master
from

Conversation

@guybedford
Copy link
Contributor

@guybedford guybedford commented Oct 22, 2020

This creates an explicit runtime deprecation warning when using the folder mappings in "exports" or "imports".

The implicit documentation deprecation was already made when the exports patterns PR was landed in #34718 and fully replaced all documentation references to this.

The warning is carefully scoped to not apply to external packages in node_modules, unless explicitly using the --pending-deprecation flag.

Tests are included for local and external, require and import, imports and exports and self-resolution cases.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
@nodejs-github-bot
Copy link

@nodejs-github-bot nodejs-github-bot commented Oct 22, 2020

Review requested:

@guybedford guybedford force-pushed the guybedford:deprecate-export-trailer branch 2 times, most recently from 2d4f98e to 6e21041 Oct 22, 2020
@guybedford guybedford force-pushed the guybedford:deprecate-export-trailer branch from 6e21041 to f258111 Oct 22, 2020
@guybedford guybedford requested a review from jkrems Oct 22, 2020
@codecov-io
Copy link

@codecov-io codecov-io commented Oct 22, 2020

Codecov Report

Merging #35747 into master will decrease coverage by 8.49%.
The diff coverage is 98.03%.

@@            Coverage Diff             @@
##           master   #35747      +/-   ##
==========================================
- Coverage   96.41%   87.91%   -8.50%     
==========================================
  Files         223      477     +254     
  Lines       73685   113133   +39448     
  Branches        0    24642   +24642     
==========================================
+ Hits        71043    99462   +28419     
- Misses       2642     7963    +5321     
- Partials        0     5708    +5708     
Impacted Files Coverage Δ
lib/internal/modules/esm/resolve.js 93.65% <98.03%> (-1.09%) ⬇️
lib/internal/idna.js 55.55% <0.00%> (-11.12%) ⬇️
lib/internal/blocklist.js 88.70% <0.00%> (-10.49%) ⬇️
lib/internal/crypto/mac.js 73.45% <0.00%> (-9.48%) ⬇️
lib/internal/modules/esm/get_format.js 84.72% <0.00%> (-8.34%) ⬇️
lib/internal/crypto/aes.js 84.21% <0.00%> (-6.44%) ⬇️
lib/internal/crypto/dsa.js 85.28% <0.00%> (-6.04%) ⬇️
lib/internal/crypto/webcrypto.js 84.60% <0.00%> (-5.40%) ⬇️
lib/internal/histogram.js 79.78% <0.00%> (-5.32%) ⬇️
lib/internal/dtrace.js 95.23% <0.00%> (-4.77%) ⬇️
... and 390 more
lib/internal/modules/esm/resolve.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/resolve.js Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

lgtm

doc/api/deprecations.md Outdated Show resolved Hide resolved
@Trott
Copy link
Member

@Trott Trott commented Oct 22, 2020

@addaleax This is a runtime deprecation on two experimental features (subpath exports and subpath imports), so maybe it's not semver-major?

@addaleax
Copy link
Member

@addaleax addaleax commented Oct 22, 2020

@Trott Yeah, no strong opinion, it felt like it’s better to err on the safe side here to me, that’s all :)

guybedford and others added 4 commits Oct 22, 2020
Co-authored-by: Jordan Harband <ljharb@gmail.com>
@guybedford
Copy link
Contributor Author

@guybedford guybedford commented Oct 22, 2020

Thinking some more about the backporting I wonder if it might actually be useful to backport this to 14.

The warnings will only show for local package usage since we have good filtering to not show for third-party packages without -pending-deprecation.

I would still suggest holding out until 16/17 for any throw-by-default behaviour though, but it could be beneficial to backport the warning actually.

I'm updating the PR description, but if anyone has any concerns let me know.

For all the modules experimental status process and changes, this is probably one of the only few removals we've done actually!

@guybedford
Copy link
Contributor Author

@guybedford guybedford commented Oct 22, 2020

@addaleax given the above, would you be ok with removing the semver major label here?

@addaleax
Copy link
Member

@addaleax addaleax commented Oct 22, 2020

@guybedford As I said, no strong opinion :) Just the fact that runtime deprecations are semver-major by default, but if everybody else is good with it then I am too

@guybedford
Copy link
Contributor Author

@guybedford guybedford commented Oct 22, 2020

Just the fact that runtime deprecations are semver-major by default, but if everybody else is good with it then I am too

Ah I was not aware of that. Ok I'm completely fine with leaving the backport then.

@MylesBorins
Copy link
Member

@MylesBorins MylesBorins commented Oct 22, 2020

I think doing this as non-semver major but not backporting is a nice "split the difference"

@GeoffreyBooth
Copy link
Member

@GeoffreyBooth GeoffreyBooth commented Oct 22, 2020

So what about the "./": "./" mapping that we’ve been advising people to add to avoid making adding "exports" a breaking change? That needs to become "./*": "./*" or something?

@ljharb
Copy link
Member

@ljharb ljharb commented Oct 22, 2020

I don’t believe those are equivalent because package/ wouldn’t work with the pattern.

@guybedford
Copy link
Contributor Author

@guybedford guybedford commented Oct 22, 2020

Certainly there is that tailing "/" difference between the two which is deprecated here.

For the use cases in the readme covered by "./": "./" we already suggest using "./*": "./*". Further docs suggestions very welcome too.

@ljharb
Copy link
Member

@ljharb ljharb commented Oct 22, 2020

(To be clear tho, removing the slash feature makes it impossible to make adding "exports" a non-breaking change - unless you could add "./": "./index.js" and that would work?)

@guybedford
Copy link
Contributor Author

@guybedford guybedford commented Oct 22, 2020

That's true, although we already advise that exports typically is a breaking change. The import 'pkg/' edge case is likely at the bottom of the list of cases users have to consider and is a very rare pattern in the wild, typically only used for package names that match Node.js builtins to get around builtin detections so I don't think it realistically affects most packages.

With this trailing separator deprecation, in theory it could allow a future implementation space to support these as individual maps in their own right.


_This feature will be removed in a future release._

Instead, use direct [subpath patterns][]:

This comment has been minimized.

@GeoffreyBooth

GeoffreyBooth Oct 22, 2020
Member

I initially read this section and thought “why are we adding a section to the docs for something we’re deprecating?” and only later realized you’re introducing the deprecated thing to then introduce what people should use instead. I worry that people might not get to the important part, which is at the end. Can we instead just introduce subpath patterns and this use case, as if the trailing slash version never existed?

This comment has been minimized.

@guybedford

guybedford Oct 22, 2020
Author Contributor

Yes I've added the feature to the docs to deprecate it :)

I could just remove the first example, would that help?

Otherwise I could leave out the section here and just have the deprecation but my concern then was users might miss that it is even deprecated if they aren't using the feature.

This comment has been minimized.

@GeoffreyBooth

GeoffreyBooth Oct 22, 2020
Member

At the very least I’d put the deprecated version last. But I think it would be better to just not include the deprecated info at all. Simply explain subpath patterns for the use case of exposing * within a folder, and why a user might want to do that, as if the deprecated feature had never existed.

This comment has been minimized.

@ljharb

ljharb Oct 22, 2020
Member

It would be nice if we could document / subpaths in the docs for older node versions tho, at least as a reference, even if we didn't include that info in docs for node versions in which it was deprecated. Is that possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
You can’t perform that action at this time.
X Tutup