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

addition: type field for package.json v10 #1359

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions content/cli/v10/configuring-npm/package-json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,28 @@ Both email and url are optional either way.

npm also sets a top-level "maintainers" field with your npm user info.

### type

This _optional_ field of value _string_ helps Node.js determine the module format used in the package, affecting _import_ and _export_ behavior.

By default, Node.js utilizes the [CommonJS modules](https://nodejs.org/docs/latest/api/modules.html#modules-commonjs-modules) system for files with a `.js` or `.cjs` extension regardless whether the `type` field was provided or not. To use the modern [ECMAScript modules](https://nodejs.org/docs/latest/api/esm.html) (AKA ES modules) system, a `.mjs` file extension is required.

In a package.json file, the `type` field currently accepts two values:

- `commonjs` (default): Specifies that `.js` files within the package should be treated as CommonJS modules.

- `module`: Specifies that `.js` files within the package should be treated as ES modules.

Example:

```json
// ECMAScript
{
"type": "module"
}

```

### funding

You can specify an object containing a URL that provides up-to-date information about ways to help fund development of your package, a string URL, or an array of objects and string URLs:
Expand Down
12 changes: 7 additions & 5 deletions src/components/page-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ const Contributors = ({contributors = [], latestCommit}) => {
{contributors.length} {pluralize('contributor', contributors.length)}
</Text>
{contributors.map(login => (
<Tooltip key={login} text={login}>
<Link href={`https://github.com/${login}`} sx={{lineHeight: 'condensedUltra', mr: 2}}>
<Avatar src={`https://github.com/${login}.png?size=40`} alt={login} />
</Link>
</Tooltip>
<li key={login}>
<Tooltip key={login} text={login}>
<Link href={`https://github.com/${login}`} sx={{lineHeight: 'condensedUltra', mr: 2}}>
<Avatar src={`https://github.com/${login}.png?size=40`} alt={login} />
</Link>
</Tooltip>
</li>
))}
</Box>
{latestCommit ? (
Expand Down