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

doc: fix explanation of package.json "type" field #27516

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@tamias
Copy link

commented May 1, 2019

Remove erroneous reference to files with .mjs extension, which are not affected by the "type" field.

Checklist
doc: fix explanation of package.json "type" field
Remove erroneous reference to files with `.mjs` extension, which are not
affected by the package.json "type" field.

@BridgeAR BridgeAR requested review from guybedford, devsnek and MylesBorins May 3, 2019

@BridgeAR

This comment has been minimized.

Copy link
Member

commented May 13, 2019

@ljharb

ljharb approved these changes May 13, 2019

@GeoffreyBooth

This comment has been minimized.

Copy link
Contributor

commented May 13, 2019

I'm not sure that this is an improvement. I think it's important for users to know that both .js and .mjs files are treated as ES modules within the module package scope. That's not as obvious if .mjs isn't mentioned, and potentially confusing if .mjs is mentioned only as being unaffected by the field.

@tamias

This comment has been minimized.

Copy link
Author

commented May 13, 2019

@GeoffreyBooth .mjs files are already mentioned earlier in the file:

Once enabled, Node.js will treat the following as ES modules when passed to
node as the initial input, or when referenced by import statements within
ES module code:

  • Files ending in .mjs.
  • Files ending in .js, or extensionless files, when the nearest parent
    package.json file contains a top-level field "type" with a value of
    "module".
  • Strings passed in as an argument to --eval or --print, or piped to
    node via STDIN, with the flag --input-type=module.

The edited paragraph documents the "type" field specifically. The original text implies that the "type" field affects how .mjs files are loaded, which contradicts the quoted text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.