-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Suggest adding "type"
field to all packages
#83
Comments
I think that makes sense 👍 It might be safer to wait till node v22 to see if they're settled on it before implementing it here. It's going to suggest that for a lot of packages. I'll add this as an enhancement for now, and when v22 lands (around April/May 2024) we can implement it. |
Hi @bluwy , just letting you know this was also just added to Node v20.10.0 - I've updated the post above to link to the new release notes. |
Ah neat. If it's already in node 20 (LTS), then it seems like there's a good reason to push towards it now. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`20.10.4` -> `20.10.5`](https://renovatebot.com/diffs/npm/@types%2fnode/20.10.4/20.10.5) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/20.10.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/20.10.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/20.10.4/20.10.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/20.10.4/20.10.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [eslint](https://eslint.org) ([source](https://togithub.com/eslint/eslint)) | [`8.55.0` -> `8.56.0`](https://renovatebot.com/diffs/npm/eslint/8.55.0/8.56.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/eslint/8.56.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint/8.56.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint/8.55.0/8.56.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint/8.55.0/8.56.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [publint](https://publint.dev) ([source](https://togithub.com/bluwy/publint/tree/HEAD/pkg)) | [`0.2.6` -> `0.2.7`](https://renovatebot.com/diffs/npm/publint/0.2.6/0.2.7) | [![age](https://developer.mend.io/api/mc/badges/age/npm/publint/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/publint/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/publint/0.2.6/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/publint/0.2.6/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>eslint/eslint (eslint)</summary> ### [`v8.56.0`](https://togithub.com/eslint/eslint/releases/tag/v8.56.0) [Compare Source](https://togithub.com/eslint/eslint/compare/v8.55.0...v8.56.0) ##### Features - [`0dd9704`](https://togithub.com/eslint/eslint/commit/0dd9704c4751e1cd02039f7d6485fee09bbccbf6) feat: Support custom severity when reporting unused disable directives ([#​17212](https://togithub.com/eslint/eslint/issues/17212)) (Bryan Mishkin) - [`31a7e3f`](https://togithub.com/eslint/eslint/commit/31a7e3fde491e36496b54e8905c766b31162d776) feat: fix no-restricted-properties false negatives with unknown objects ([#​17818](https://togithub.com/eslint/eslint/issues/17818)) (Arka Pratim Chaudhuri) ##### Bug Fixes - [`7d5e5f6`](https://togithub.com/eslint/eslint/commit/7d5e5f68849ae80caec0fc96ecceebccd348deec) fix: `TypeError: fs.exists is not a function` on read-only file system ([#​17846](https://togithub.com/eslint/eslint/issues/17846)) (Francesco Trotta) - [`74739c8`](https://togithub.com/eslint/eslint/commit/74739c849bbb6547b0e555ed8bb2ba1cbe0fdce4) fix: suggestion with invalid syntax in no-promise-executor-return rule ([#​17812](https://togithub.com/eslint/eslint/issues/17812)) (Bryan Mishkin) ##### Documentation - [`9007719`](https://togithub.com/eslint/eslint/commit/90077199fe519953f9af8664bf947db4e4958514) docs: update link in ways-to-extend.md ([#​17839](https://togithub.com/eslint/eslint/issues/17839)) (Amel SELMANE) - [`3a22236`](https://togithub.com/eslint/eslint/commit/3a22236f8d10af8a5bcafe56092651d3d681c99d) docs: Update README (GitHub Actions Bot) - [`54c3ca6`](https://togithub.com/eslint/eslint/commit/54c3ca6f2dcd2a7afd53f42fc32055a25587259e) docs: fix migration-guide example ([#​17829](https://togithub.com/eslint/eslint/issues/17829)) (Tanuj Kanti) - [`4391b71`](https://togithub.com/eslint/eslint/commit/4391b71e62b15e54b0493f0dce1ea053ebbc0689) docs: check config comments in rule examples ([#​17815](https://togithub.com/eslint/eslint/issues/17815)) (Francesco Trotta) - [`fd28363`](https://togithub.com/eslint/eslint/commit/fd2836342c2be4751b05fe0ba7cece17d1edecc8) docs: remove mention about ESLint stylistic rules in readme ([#​17810](https://togithub.com/eslint/eslint/issues/17810)) (Zwyx) - [`48ed5a6`](https://togithub.com/eslint/eslint/commit/48ed5a6dad478a14d3e823f137455c523f373e0b) docs: Update README (GitHub Actions Bot) ##### Chores - [`ba6af85`](https://togithub.com/eslint/eslint/commit/ba6af85c7d8ba55d37f8663aee949d148e441c1a) chore: upgrade [@​eslint/js](https://togithub.com/eslint/js)[@​8](https://togithub.com/8).56.0 ([#​17864](https://togithub.com/eslint/eslint/issues/17864)) (Milos Djermanovic) - [`60a531a`](https://togithub.com/eslint/eslint/commit/60a531a9c0811ddf718e26b9136e133f580b6c36) chore: package.json update for [@​eslint/js](https://togithub.com/eslint/js) release (Jenkins) - [`ba87a06`](https://togithub.com/eslint/eslint/commit/ba87a0651a65b52c3ac442b512dd9f4c2b4c5f57) chore: update dependency markdownlint to ^0.32.0 ([#​17783](https://togithub.com/eslint/eslint/issues/17783)) (renovate\[bot]) - [`9271d10`](https://togithub.com/eslint/eslint/commit/9271d10d9eabeafb0129a090f29191bfd14273c0) chore: add GitHub issue template for docs issues ([#​17845](https://togithub.com/eslint/eslint/issues/17845)) (Josh Goldberg ✨) - [`70a686b`](https://togithub.com/eslint/eslint/commit/70a686b3c1feac5eca98bbff9bd67175f550d5db) chore: Convert rule tests to FlatRuleTester ([#​17819](https://togithub.com/eslint/eslint/issues/17819)) (Nicholas C. Zakas) - [`f3a599d`](https://togithub.com/eslint/eslint/commit/f3a599d34c7080fc0b2c9a60b5e54dc98c22867c) chore: upgrade eslint-plugin-unicorn to v49.0.0 ([#​17837](https://togithub.com/eslint/eslint/issues/17837)) (唯然) - [`905d4b7`](https://togithub.com/eslint/eslint/commit/905d4b75ab2df42aba30622cee0f66b511397e2c) chore: upgrade eslint-plugin-eslint-plugin v5.2.1 ([#​17838](https://togithub.com/eslint/eslint/issues/17838)) (唯然) - [`4d7c3ce`](https://togithub.com/eslint/eslint/commit/4d7c3ce246e6b499f472342ef59496a47cc033d6) chore: update eslint-plugin-n v16.4.0 ([#​17836](https://togithub.com/eslint/eslint/issues/17836)) (唯然) - [`fd0c60c`](https://togithub.com/eslint/eslint/commit/fd0c60c3be1f213e5a6d69d8a3248e963619e155) ci: unpin Node.js 21.2.0 ([#​17821](https://togithub.com/eslint/eslint/issues/17821)) (Francesco Trotta) </details> <details> <summary>bluwy/publint (publint)</summary> ### [`v0.2.7`](https://togithub.com/bluwy/publint/releases/tag/v0.2.7) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.6...v0.2.7) ##### Features - If the library exports from both `"main"`/`"module"` and `"exports"` fields, but the `"exports"` field doesn't export the root entrypoint, warn about the inconsistency. When `"exports"` is defined, it takes the highest priority, so all the library's entrypoint (root and deep) needs to be specified here. ([https://github.com/bluwy/publint/issues/88](https://togithub.com/bluwy/publint/issues/88)) - Suggest using the `"type"` field. In [Node.js v20.10.0](https://nodejs.org/en/blog/release/v20.10.0), it introduces a new `--experimental-default-type` flag to flip the default module system from "CJS-as-default" to "ESM-as-default". It's recommended for libraries to specify the `"type"` field explicitly to prevent CJS files from being incorrectly interpreted as ESM. This suggestion helps push towards a better ESM experience in the future. ([https://github.com/bluwy/publint/issues/83](https://togithub.com/bluwy/publint/issues/83)) **Full Changelog**: bluwy/publint@v0.2.6...v0.2.7 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - "before 4am on Monday" (UTC). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tnez/starter-npm-pkg). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy45My4xIiwidXBkYXRlZEluVmVyIjoiMzcuMTAzLjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [publint](https://publint.dev) ([source](https://togithub.com/bluwy/publint/tree/HEAD/pkg)) | [`0.1.16` -> `0.2.7`](https://renovatebot.com/diffs/npm/publint/0.1.16/0.2.7) | [![age](https://developer.mend.io/api/mc/badges/age/npm/publint/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/publint/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/publint/0.1.16/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/publint/0.1.16/0.2.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>bluwy/publint (publint)</summary> ### [`v0.2.7`](https://togithub.com/bluwy/publint/releases/tag/v0.2.7) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.6...v0.2.7) ##### Features - If the library exports from both `"main"`/`"module"` and `"exports"` fields, but the `"exports"` field doesn't export the root entrypoint, warn about the inconsistency. When `"exports"` is defined, it takes the highest priority, so all the library's entrypoint (root and deep) needs to be specified here. ([https://github.com/bluwy/publint/issues/88](https://togithub.com/bluwy/publint/issues/88)) - Suggest using the `"type"` field. In [Node.js v20.10.0](https://nodejs.org/en/blog/release/v20.10.0), it introduces a new `--experimental-default-type` flag to flip the default module system from "CJS-as-default" to "ESM-as-default". It's recommended for libraries to specify the `"type"` field explicitly to prevent CJS files from being incorrectly interpreted as ESM. This suggestion helps push towards a better ESM experience in the future. ([https://github.com/bluwy/publint/issues/83](https://togithub.com/bluwy/publint/issues/83)) **Full Changelog**: bluwy/publint@v0.2.6...v0.2.7 ### [`v0.2.6`](https://togithub.com/bluwy/publint/releases/tag/v0.2.6) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.5...v0.2.6) ##### Features - Warn if the deprecated `jsnext:main` or `jsnext` fields are used by [@​sapphi-red](https://togithub.com/sapphi-red) ([https://github.com/bluwy/publint/pull/85](https://togithub.com/bluwy/publint/pull/85)) ##### Site - Fix command on site by [@​wooorm](https://togithub.com/wooorm) ([https://github.com/bluwy/publint/pull/82](https://togithub.com/bluwy/publint/pull/82)) ##### New Contributors - [@​wooorm](https://togithub.com/wooorm) made their first contribution in [https://github.com/bluwy/publint/pull/82](https://togithub.com/bluwy/publint/pull/82) **Full Changelog**: bluwy/publint@v0.2.5...v0.2.6 ### [`v0.2.5`](https://togithub.com/bluwy/publint/releases/tag/v0.2.5) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.4...v0.2.5) ##### Bug fixes - Fix missing published files check when resolving a path with fallback extensions ([https://github.com/bluwy/publint/issues/79](https://togithub.com/bluwy/publint/issues/79)) **Full Changelog**: bluwy/publint@v0.2.4...v0.2.5 ### [`v0.2.4`](https://togithub.com/bluwy/publint/releases/tag/v0.2.4) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.3...v0.2.4) ##### Bug fixes - Check for packed files locally before providing the `"files"` suggestion. An incorrect suggestion was given when you're using `.npmignore` or `.gitignore` to limit publishing certain files. ##### Site - Fix rules page mobile responsiveness **Full Changelog**: bluwy/publint@v0.2.3...v0.2.4 ### [`v0.2.3`](https://togithub.com/bluwy/publint/releases/tag/v0.2.3) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.2...v0.2.3) ##### Features - Error if `package.json` has fields with invalid string, boolean, object, etc type ([https://github.com/bluwy/publint/issues/73](https://togithub.com/bluwy/publint/issues/73)) - Suggest using the `"files"` field if detected test or config files are published ([https://github.com/bluwy/publint/issues/77](https://togithub.com/bluwy/publint/issues/77)) - Warn on `"exports"` and `"browser"` object conflict for browser-ish environments ([https://github.com/bluwy/publint/issues/58](https://togithub.com/bluwy/publint/issues/58)) For example, given this setup: ```json { "browser": { "./lib.server.js": "./lib.browser.js" }, "exports": { ".": { "worker": "./lib.server.js", "browser": "./lib.browser.js", "default": "./lib.server.js" } } } ``` When matching the `"worker"` condition, it will resolve to `"./lib.server.js"` which is intended to work in a worker environment. However, the `"browser"` field also has a matching mapping for `"./lib.server.js"`, causing the final resolved path to be `"./lib.browser.js"`. This is usually not intended and causes the wrong file to be loaded. - Error on invalid JSX extensions, such as `.cjsx`, `.mjsx`, `.ctsx`, and `.mtsx` ([https://github.com/bluwy/publint/issues/76](https://togithub.com/bluwy/publint/issues/76)) These extensions are usually mistaken as ESM and CJS variants of JSX, which is not valid. Instead they should be written in ESM with the `.jsx` extension instead. ##### Bug fixes - Skip file format checks only for globbed files - Fix `"main"` field with ESM content detection ([https://github.com/bluwy/publint/issues/75](https://togithub.com/bluwy/publint/issues/75)) ##### Site - Add sidebar menu to rules page by [@​btea](https://togithub.com/btea) ([https://github.com/bluwy/publint/pull/65](https://togithub.com/bluwy/publint/pull/65)) - Quickly scroll to the prompt information location by [@​btea](https://togithub.com/btea) ([https://github.com/bluwy/publint/pull/68](https://togithub.com/bluwy/publint/pull/68)) - Fix version switch title not updated by [@​btea](https://togithub.com/btea) ([https://github.com/bluwy/publint/pull/72](https://togithub.com/bluwy/publint/pull/72)) - Improve documentation for `"types"` format - Fix message border styles - Fix docs list missing dot **Full Changelog**: bluwy/publint@v0.2.2...v0.2.3 ### [`v0.2.2`](https://togithub.com/bluwy/publint/releases/tag/v0.2.2) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.1...v0.2.2) ##### Features - Lint `"typings"` field file existence ([https://github.com/bluwy/publint/pull/60](https://togithub.com/bluwy/publint/pull/60)) - Check packed files when globbing exports locally ([https://github.com/bluwy/publint/issues/61](https://togithub.com/bluwy/publint/issues/61)) - Improve `"browser"` field suggestion for using `"imports"` and `"exports"` fields instead ([https://github.com/bluwy/publint/pull/59](https://togithub.com/bluwy/publint/pull/59)) ##### Bug fixes - Lower deprecated trailing slash glob syntax as `suggestion` instead of a `warning` when it's used for backwards compatibility only ([https://github.com/bluwy/publint/issues/62](https://togithub.com/bluwy/publint/issues/62)) - Suppress invalid globbed file format if has correct adjacent file - Fix extension replacement in messages - Improve invalid types format message and docs ##### Site - Fix invalid package name not found message - Highlight code blocks in rules page ##### New Contributors - [@​btea](https://togithub.com/btea) made their first contribution in [https://github.com/bluwy/publint/pull/64](https://togithub.com/bluwy/publint/pull/64) **Full Changelog**: bluwy/publint@v0.2.1...v0.2.2 ### [`v0.2.1`](https://togithub.com/bluwy/publint/releases/tag/v0.2.1) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.2.0...v0.2.1) ##### Bug fixes - Fix `"types"` condition check with `"exports"` array format - Disable packed files search when a `vfs` is passed - Fix `"browser"` field file existence extensions check - Fix file existence check with trailing slash ##### Site - Site-wide design touch-up - New "Popular packages" section - New package version select switcher ([https://github.com/bluwy/publint/issues/56](https://togithub.com/bluwy/publint/issues/56)) - New navigation header design - Update bottom documentation for clarity - Improve repo URL parsing ##### New Contributors - [@​lachlancollins](https://togithub.com/lachlancollins) made their first contribution in [https://github.com/bluwy/publint/pull/53](https://togithub.com/bluwy/publint/pull/53) **Full Changelog**: bluwy/publint@v0.2.0...v0.2.1 ### [`v0.2.0`](https://togithub.com/bluwy/publint/releases/tag/v0.2.0) [Compare Source](https://togithub.com/bluwy/publint/compare/v0.1.16...v0.2.0) ##### Breaking changes **Note:** If you're using `publint` from the CLI, these breaking changes should not affect you. - `publint()` now returns an object with `messages` instead of the `messages` array directly. This makes way for future APIs where `publint` will return more information than just `messages`. ```diff - const messages = await publint() + const { messages } = await publint() ``` - Rename `printMessage` API to `formatMessage` to better reflect it's intent. ([https://github.com/bluwy/publint/issues/43](https://togithub.com/bluwy/publint/issues/43)) ```diff - import { printMessage } from "publint/utils" + import { formatMessage } from "publint/utils" const { messages } = await publint() for (const message of messages) { - console.log(printMessage(message)) + console.log(formatMessage(message)) } ``` - Remove `filePath` `arg` for the `FILE_DOES_NOT_EXIST` message. ```diff import type { Message } from "publint" import { getPkgPathValue } from "publint/utils" function messageToString(message: Message, pkg: Record<string, any>) { switch (message.code) { case "FILE_DOES_NOT_EXIST": - return `The file "${message.args.filePath}" does not exist.` + return `The file "${getPkgPathValue(pkg, message.path)}" does not exist.` } } ``` - Remove the `import` condition for the `publint` package. This provides a better error message if you call `require("publint")`. ##### Features - Improve warnings when the exported `"types"` condition has an invalid format in ESM or CJS. This ensures your library's types will work in both environments when dual publishing. ([https://github.com/bluwy/publint/issues/46](https://togithub.com/bluwy/publint/issues/46)) It affects packages commonly packaged like: ```json { "exports": { ".": { "types": "./index.d.ts", <-- only works in CJS "import": "./index.mjs", "require": "./index.js", } } } ``` For more information, visit the [rules documentation](https://publint.dev/rules#export_types_invalid_format). This feature is inspired by https://arethetypeswrong.github.io. ##### Bug fixes - Suppress warnings when exported JS files using the `"exports"` field have adjacent `.d.ts` files and no `"types"` condition. This follows TypeScript's resolution algorithm. For more information, visit the [rules documentation](https://publint.dev/rules#types_not_exported). ([https://github.com/bluwy/publint/issues/46](https://togithub.com/bluwy/publint/issues/46)) **Full Changelog**: bluwy/publint@v0.1.16...v0.2.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tnez/actions). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzcuMTAzLjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Hi there, I was reading through the Node v20.10.0 release notes and noticed the following regarding experimental CJS/ESM detection:
I'm wondering if it would be a good idea for publint to recommend that all packages have a
"type"
field, since it seems Node will shift away from"commonjs"
as the default. I'd imagine this would be a suggestion rather than a warning.The text was updated successfully, but these errors were encountered: