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 builtin modules with node: prefix #13311

Closed
wants to merge 2 commits into from
Closed

Add builtin modules with node: prefix #13311

wants to merge 2 commits into from

Conversation

karlhorky
Copy link
Contributor

@karlhorky karlhorky commented May 5, 2021

Closes #13290

What kind of change does this PR introduce?

Support node: prefix for builtin modules

Did you add tests for your changes?

@alexander-akait what tests would you suggest here?

Does this PR introduce a breaking change?

I guess not, since this is now a feature of Node.js?

What needs to be documented once your changes are merged?

Not sure this needs to be documented, but happy to be corrected here.

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

there is already a PR for that: #12693

You can use the regex idea from that and add a test case.

@karlhorky
Copy link
Contributor Author

@sokra Ok thanks for the hint. Can you provide some guidance as to what a test case would look like? And where I would add this test case?

@alexander-akait
Copy link
Member

@karlhorky You can put this here https://github.com/webpack/webpack/tree/master/test/configCases/target and add require/import with node prefix

@webpack-bot
Copy link
Contributor

@karlhorky Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@karlhorky
Copy link
Contributor Author

karlhorky commented May 6, 2021

@alexander-akait ok I spent 10 minutes looking at the things in that folder, but I don't know what you mean. The structure of the test directory structures is hard for me to understand.

I ended up just guessing that you mean doing something like this: 12108b3 (#13311)

@@ -1,7 +1,7 @@
it("should run", function() {});

it("should name define", function() {
var fs = require("fs");
var fs = require("node:fs");
Copy link
Member

Choose a reason for hiding this comment

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

Please add new tests, don't modify exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I wrote above, I don't understand how to add new tests here - I tried :)

@webpack-bot
Copy link
Contributor

@karlhorky The most important CI builds failed. This way your PR can't be merged.

Please take a look at the CI results from azure (1 errors / 1 warnings) and appveyor (failure) and fix these issues.

@karlhorky
Copy link
Contributor Author

So this feature is about to get more usage: the node: scheme / prefix / protocol was backported to Node.js 14.13.1 / 12.20.0 🎉

https://nodejs.org/api/esm.html -> link "node: Imports" (links with anchors don't scroll properly right now)

Screen Shot 2021-05-30 at 11 04 39

@karlhorky
Copy link
Contributor Author

An alternative to the approaches in #13311 and #12693 would be to use is-core-module (which was split from resolve in browserify/resolve@7c26483), so that this list doesn't need to be maintained and tested by webpack itself.

@alexander-akait
Copy link
Member

Done here #12693, sorry for delay

@karlhorky karlhorky deleted the patch-1 branch June 21, 2021 11:22
@karlhorky
Copy link
Contributor Author

No worries, thanks for this!

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

Successfully merging this pull request may close these issues.

New node: scheme from Node 16 not handled
4 participants