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 — doc: improve explanation of package.json "type" field · nodejs/node@39dbc10

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • esm.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+6-3Lines changed: 6 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ or when referenced by `import` statements within ES module code:
6262

6363
### `package.json` `"type"` field
6464

65-
Files ending with `.js` or `.mjs`, or lacking any extension,
66-
will be loaded as ES modules when the nearest parent `package.json` file
67-
contains a top-level field `"type"` with a value of `"module"`.
65+
Files ending with `.js` or lacking any extension will be loaded as ES modules
66+
when the nearest parent `package.json` file contains a top-level field `"type"`
67+
with a value of `"module"`.
6868

6969
The nearest parent `package.json` is defined as the first `package.json` found
7070
when searching in the current folder, that folder’s parent, and so on up
@@ -104,6 +104,9 @@ future-proof the package in case the default type of Node.js ever changes, and
104104
it will also make things easier for build tools and loaders to determine how the
105105
files in the package should be interpreted.
106106

107+
Regardless of the value of the `"type"` field, `.mjs` files are always treated
108+
as ES modules and `.cjs` files are always treated as CommonJS.
109+
107110
### Package Scope and File Extensions
108111

109112
A folder containing a `package.json` file, and all subfolders below that

0 commit comments

Comments
0 (0)
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.