GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — module: prevent `format` from being set to `null` internaly by avivkeller · Pull Request #53015 · nodejs/node

Conversation

@avivkeller

@avivkeller avivkeller commented May 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

With all the changes and backtraces my PR's have caused regarding changes similar to this, @GeoffreyBooth and I agreed that preventing format from being set to null internaly would at least be a step in the right direction.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@avivkeller
module: prevent format from being null
86299ac
@nodejs-github-bot

nodejs-github-bot commented May 15, 2024

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels May 15, 2024
avivkeller added 2 commits May 15, 2024 19:08
@avivkeller
Update formats.js
36e847e
@avivkeller
Update formats.js
78e756b
@avivkeller avivkeller changed the title module: prevent format from being null module: prevent format from being set to null internaly May 15, 2024
GeoffreyBooth
GeoffreyBooth approved these changes May 15, 2024
View reviewed changes

@GeoffreyBooth GeoffreyBooth left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The reason for this is to simplify tests. The format value might be null or it might be undefined based on arbitrary things like which code path is followed. Our internal code is careful to do loose tests like format == null to account for format being either null or undefined, but not all the tests are so loose. Eliminating null from the potential possibilities means that our tests can remain precise while not breaking as we refactor code paths. The internal conditions will remain loose so that user hooks can still set format: null.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@GeoffreyBooth

GeoffreyBooth commented May 15, 2024

Copy link
Copy Markdown
Member

https://github.com/nodejs/node/blob/main/doc/api/module.md needs updating too, the various lines like this:

  * `format` {string|null|undefined} The format optionally supplied by the
    `resolve` hook chain

To remove null from the list.

avivkeller reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@avivkeller
Update module.md
fcc5d01
aduh95
aduh95 reviewed May 16, 2024
View reviewed changes
Comment thread doc/api/module.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed May 16, 2024
View reviewed changes
Comment thread doc/api/module.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@aduh95

aduh95 commented May 16, 2024

Copy link
Copy Markdown
Contributor

IIUC, before this change, defaultResolve would set format to null when it can't find a better value (and load would still accept undefined nonetheless in case that's what a user hook returned). With this change, it will now be undefined (and load would still accept null nonetheless in case that's what a user hook returned). How does that make tests more precise? It seems to me it's just switching a value for another, that seems rather pointless.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dygabo

dygabo commented May 17, 2024

Copy link
Copy Markdown
Member

I accidentally found this PR and looked a bit into the details (might still miss something). But iiuc the goal of the module detection is to allow .js files to be either CJS or ESM as opposed to current behaviour without the --experimental-detect-module that is .js are assumed to be CJS if not otherwise specified with --experimental-default-type command line option. Is this correct?

I can have a look and open a PR if I find a solution. I agree that null or undefined have equivalent explanatory value.

cc: @aduh95, @GeoffreyBooth

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@avivkeller

avivkeller commented May 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

I accidentally found this PR and looked a bit into the details (might still miss something). But iiuc the goal of the module detection is to allow .js files to be either CJS or ESM as opposed to current behaviour without the --experimental-detect-module that is .js are assumed to be CJS if not otherwise specified with --experimental-default-type command line option. Is this correct?

#53016 has some more information, but essentially, in the end, we want it to default to CJS, but it defaults to null / undefined

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@avivkeller
Update module.md
937be1b
@dygabo dygabo mentioned this pull request May 18, 2024
module: resolve format for all situations with auto module detection on #53044
Closed
@H4ad H4ad added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Jun 8, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jun 8, 2024
@nodejs-github-bot

nodejs-github-bot commented Jun 8, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/59696/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 requested changes Jun 8, 2024
View reviewed changes

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I disagree this simplifies anything, let's not land this – it'd be a small breaking change, but still a breaking change, and we should have some justification for breaking things

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@avivkeller

avivkeller commented Jun 8, 2024

Copy link
Copy Markdown
Member Author

I was actually planning on closing this favor of another PR (I need to find it then I'll link it)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@avivkeller avivkeller closed this Jun 8, 2024
@avivkeller
avivkeller deleted the never-null-format branch June 8, 2024 10:56
@GeoffreyBooth GeoffreyBooth mentioned this pull request Jul 14, 2024
module: unflag detect-module #53619
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aduh95 aduh95 aduh95 requested changes
@GeoffreyBooth GeoffreyBooth GeoffreyBooth approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

commit-queue-squash PRs the Commit Queue should land as one squashed commit. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@avivkeller @nodejs-github-bot @GeoffreyBooth @aduh95 @dygabo @H4ad
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.