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 exports field to package.json #7307

Merged
merged 8 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-insects-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": major
---

Changed: `.js` extension to `.mjs` and `.cjs`
5 changes: 5 additions & 0 deletions .changeset/weak-crews-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": major
---

Added: `exports` field to `package.json` for Conditional Exports (ESM/CJS)
26 changes: 26 additions & 0 deletions docs/migration-guide/to-16.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This release contains breaking changes. We've:

- removed deprecated stylistic rules
- removed support for Node.js less than 18.12.0
- changed `.js` extension to `.mjs` and `.cjs`
- changed Node.js API returned resolved object
- changed CLI to print problems to stderr
- changed CLI exit code for flag errors
Expand All @@ -20,6 +21,31 @@ Node.js 14 and 16 have reached end-of-life. We've removed support for them so th

You should use the 18.12.0 or higher versions of Node.js.

## Changed `.js` extensions to `.mjs` and `.cjs`

We've changed the file extension `.js` to `.mjs` and `.cjs` to support ESM and CJS.

You should modify your code if using `.js` for `import` or `require`. For example:

ESM:

```diff js
-import('stylelint/lib/utils/typeGuards.js');
+import('stylelint/lib/utils/typeGuards.mjs');
```

CJS:

```diff js
-require('stylelint/lib/utils/typeGuards.js');
+require('stylelint/lib/utils/typeGuards.cjs');
```

> [!WARNING]
> We've strongly recommended copying the internal utilities to your project instead of importing them.
> You can unsafely continue to `import` or `require` the files, but we will disallow access to them in the next major release.
> See also [`stylelint.utils`](../developer-guide/plugins.md#stylelintutils) in the developer guide.

## Changed Node.js API returned resolved object

We've changed the resolved object of the Promise returned by `stylelint.lint()` so that:
Expand Down
8 changes: 8 additions & 0 deletions package.json
Mouvedia marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
},
"license": "MIT",
"author": "stylelint",
"exports": {
".": {
"import": "./lib/index.mjs",
"require": "./lib/index.cjs"
},
"./package.json": "./package.json",
"./lib/utils/*": "./lib/utils/*"
ybiquitous marked this conversation as resolved.
Show resolved Hide resolved
},
"main": "lib/index.cjs",
Mouvedia marked this conversation as resolved.
Show resolved Hide resolved
"types": "types/stylelint/index.d.ts",
"bin": {
Expand Down