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

Show the final resolved path when exports and browser field is both used #58

Closed
sapphi-red opened this issue Aug 18, 2023 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@sapphi-red
Copy link
Contributor

If both exports field and browser field is used, browser field will map the result of exports field to another path.
For example, if the following package.json and a worker condition is used, . will resolve to ./foo.browser2.js for most bundlers (except esbuild).

{
  "browser": {
    "./foo.browser.js": "./foo.browser2.js"
  },
  "exports": {
    ".": {
      "worker": "./foo.browser.js"
    }
  }
}

See https://github.com/patdx/package-exports-test.

I believe this is really confusing and it's better to avoid relying on this behavior if it's possible.
That said, I haven't come up with a rewriting procedure that can be done universally. (other than duplicating the file)

Maybe we can give a warning if browser field maps the path of exports field? But I don't know if it's possible to avoid in all cases.
So I think showing the final resolved path is a good alternative.

related: solidjs/solid-start#263, vitejs/vite#10323, Andarist/react-textarea-autosize#385

@bluwy
Copy link
Owner

bluwy commented Aug 18, 2023

Looks like a nice addition to me. If we got a couple issues at hand I think it's worth adding it.

Maybe we can give a warning if browser field maps the path of exports field? But I don't know if it's possible to avoid in all cases.

I think this should work fine. While crawling "exports", if we're within a known non-browser condition (means not node, deno, bun?), we can make sure they don't match any keys of the "browser" field.

@bluwy bluwy added the enhancement New feature or request label Aug 18, 2023
@bluwy bluwy closed this as completed in 160318f Sep 28, 2023
@sapphi-red
Copy link
Contributor Author

Awesome! It's working well.

https://publint.dev/[email protected]
https://publint.dev/[email protected]

renovate bot referenced this issue in tnez/starter-npm-pkg Oct 2, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@edge-runtime/jest-environment](https://edge-runtime.vercel.app/packages/jest-environment)
([source](https://togithub.com/vercel/edge-runtime)) | [`2.3.0` ->
`2.3.3`](https://renovatebot.com/diffs/npm/@edge-runtime%2fjest-environment/2.3.0/2.3.3)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@edge-runtime%2fjest-environment/2.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@edge-runtime%2fjest-environment/2.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@edge-runtime%2fjest-environment/2.3.0/2.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@edge-runtime%2fjest-environment/2.3.0/2.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [@edge-runtime/types](https://edge-runtime.vercel.app/packages/types)
([source](https://togithub.com/vercel/edge-runtime)) | [`2.2.0` ->
`2.2.3`](https://renovatebot.com/diffs/npm/@edge-runtime%2ftypes/2.2.0/2.2.3)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@edge-runtime%2ftypes/2.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@edge-runtime%2ftypes/2.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@edge-runtime%2ftypes/2.2.0/2.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@edge-runtime%2ftypes/2.2.0/2.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[@types/jest](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest)
([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped)) |
[`29.5.4` ->
`29.5.5`](https://renovatebot.com/diffs/npm/@types%2fjest/29.5.4/29.5.5)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fjest/29.5.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fjest/29.5.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fjest/29.5.4/29.5.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fjest/29.5.4/29.5.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node)
([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped)) |
[`20.5.9` ->
`20.8.0`](https://renovatebot.com/diffs/npm/@types%2fnode/20.5.9/20.8.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/20.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/20.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/20.5.9/20.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/20.5.9/20.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [eslint](https://eslint.org)
([source](https://togithub.com/eslint/eslint)) | [`8.48.0` ->
`8.50.0`](https://renovatebot.com/diffs/npm/eslint/8.48.0/8.50.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/eslint/8.50.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint/8.50.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint/8.48.0/8.50.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint/8.48.0/8.50.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [jest](https://jestjs.io/)
([source](https://togithub.com/jestjs/jest)) | [`29.6.4` ->
`29.7.0`](https://renovatebot.com/diffs/npm/jest/29.6.4/29.7.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/jest/29.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/jest/29.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/jest/29.6.4/29.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/jest/29.6.4/29.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [publint](https://publint.dev)
([source](https://togithub.com/bluwy/publint)) | [`0.2.2` ->
`0.2.3`](https://renovatebot.com/diffs/npm/publint/0.2.2/0.2.3) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/publint/0.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/publint/0.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/publint/0.2.2/0.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/publint/0.2.2/0.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>vercel/edge-runtime
(@&#8203;edge-runtime/jest-environment)</summary>

###
[`v2.3.3`](https://togithub.com/vercel/edge-runtime/blob/HEAD/packages/jest-environment/CHANGELOG.md#233)

[Compare
Source](https://togithub.com/vercel/edge-runtime/compare/@edge-runtime/[email protected]...@edge-runtime/[email protected])

##### Patch Changes

-   Updated dependencies \[]:
-
[@&#8203;edge-runtime/vm](https://togithub.com/edge-runtime/vm)[@&#8203;3](https://togithub.com/3).1.3

###
[`v2.3.2`](https://togithub.com/vercel/edge-runtime/blob/HEAD/packages/jest-environment/CHANGELOG.md#232)

[Compare
Source](https://togithub.com/vercel/edge-runtime/compare/@edge-runtime/[email protected]...@edge-runtime/[email protected])

##### Patch Changes

-   Updated dependencies \[]:
-
[@&#8203;edge-runtime/vm](https://togithub.com/edge-runtime/vm)[@&#8203;3](https://togithub.com/3).1.2

###
[`v2.3.1`](https://togithub.com/vercel/edge-runtime/blob/HEAD/packages/jest-environment/CHANGELOG.md#231)

[Compare
Source](https://togithub.com/vercel/edge-runtime/compare/@edge-runtime/[email protected]...@edge-runtime/[email protected])

##### Patch Changes

-   Updated dependencies \[]:
-
[@&#8203;edge-runtime/vm](https://togithub.com/edge-runtime/vm)[@&#8203;3](https://togithub.com/3).1.1

</details>

<details>
<summary>vercel/edge-runtime (@&#8203;edge-runtime/types)</summary>

###
[`v2.2.3`](https://togithub.com/vercel/edge-runtime/blob/HEAD/packages/types/CHANGELOG.md#223)

[Compare
Source](https://togithub.com/vercel/edge-runtime/compare/@edge-runtime/[email protected]...@edge-runtime/[email protected])

##### Patch Changes

- Updated dependencies
\[[`e848ee8`](https://togithub.com/vercel/edge-runtime/commit/e848ee8553bee236df6ff4fd45ed160e53f1d0f1)]:
-
[@&#8203;edge-runtime/primitives](https://togithub.com/edge-runtime/primitives)[@&#8203;4](https://togithub.com/4).0.1

###
[`v2.2.2`](https://togithub.com/vercel/edge-runtime/blob/HEAD/packages/types/CHANGELOG.md#222)

[Compare
Source](https://togithub.com/vercel/edge-runtime/compare/@edge-runtime/[email protected]...@edge-runtime/[email protected])

##### Patch Changes

- Updated dependencies
\[[`23f55e0`](https://togithub.com/vercel/edge-runtime/commit/23f55e08b5b410605724b44d876b24325c51f5f5)]:
-
[@&#8203;edge-runtime/primitives](https://togithub.com/edge-runtime/primitives)[@&#8203;4](https://togithub.com/4).0.0

###
[`v2.2.1`](https://togithub.com/vercel/edge-runtime/blob/HEAD/packages/types/CHANGELOG.md#221)

[Compare
Source](https://togithub.com/vercel/edge-runtime/compare/@edge-runtime/[email protected]...@edge-runtime/[email protected])

##### Patch Changes

- Updated dependencies
\[[`fb34f31`](https://togithub.com/vercel/edge-runtime/commit/fb34f3172cf5f32c8e70151c2dcfdc5913ac8b8c)]:
-
[@&#8203;edge-runtime/primitives](https://togithub.com/edge-runtime/primitives)[@&#8203;3](https://togithub.com/3).1.1

</details>

<details>
<summary>eslint/eslint (eslint)</summary>

### [`v8.50.0`](https://togithub.com/eslint/eslint/releases/tag/v8.50.0)

[Compare
Source](https://togithub.com/eslint/eslint/compare/v8.49.0...v8.50.0)

#### Features

-
[`27d5a9e`](https://togithub.com/eslint/eslint/commit/27d5a9e57ad347982a68fcd0e75eafee42d344f0)
feat: add suggestions to array-callback-return
([#&#8203;17590](https://togithub.com/eslint/eslint/issues/17590))
(Tanuj Kanti)
-
[`f9082ff`](https://togithub.com/eslint/eslint/commit/f9082ff3f3956a0a5a7d7659de63640a21c4de0f)
feat: flat-rule-tester make sure default config always matches
([#&#8203;17585](https://togithub.com/eslint/eslint/issues/17585)) (fnx)
-
[`83914ad`](https://togithub.com/eslint/eslint/commit/83914adbfd5fce7d11b33d095ba6d6a39be0dbbc)
feat: Implement SourceCode#applyInlineConfig()
([#&#8203;17351](https://togithub.com/eslint/eslint/issues/17351))
(Nicholas C. Zakas)
-
[`22a5582`](https://togithub.com/eslint/eslint/commit/22a558228ff98f478fa308c9ecde361acc4caf20)
feat: add rule `no-object-constructor`, deprecate `no-new-object`
([#&#8203;17576](https://togithub.com/eslint/eslint/issues/17576))
(Francesco Trotta)
-
[`85a3d9e`](https://togithub.com/eslint/eslint/commit/85a3d9e967b19cb4a0189746499d81ef2f93e14e)
feat: allowVoid option in array-callback-return
([#&#8203;17564](https://togithub.com/eslint/eslint/issues/17564))
(Tanuj Kanti)

#### Bug Fixes

-
[`cc4d26b`](https://togithub.com/eslint/eslint/commit/cc4d26b5a59d510f2c878e973fd245e8eff27c2a)
fix: Ensure deprecated context.parserServices warns
([#&#8203;17593](https://togithub.com/eslint/eslint/issues/17593))
(Nicholas C. Zakas)
-
[`1ea4cfb`](https://togithub.com/eslint/eslint/commit/1ea4cfb585dcb52ac3cb1522a32f25cfe507121b)
fix: Ensure all RuleTester tests all deprecated context methods
([#&#8203;17587](https://togithub.com/eslint/eslint/issues/17587))
(Nicholas C. Zakas)
-
[`aa1b657`](https://togithub.com/eslint/eslint/commit/aa1b657a9febcd03e9298c03ae2888762795e322)
fix: wrong suggestion and message in `no-misleading-character-class`
([#&#8203;17571](https://togithub.com/eslint/eslint/issues/17571))
(Yosuke Ota)

#### Documentation

-
[`1800537`](https://togithub.com/eslint/eslint/commit/180053759c6cf05a326c710353b4717fbf289ee0)
docs: Fix and standardize JSX code examples
([#&#8203;17591](https://togithub.com/eslint/eslint/issues/17591))
(Francesco Trotta)
-
[`48a44a7`](https://togithub.com/eslint/eslint/commit/48a44a73ac456739bdee348bbaf1840d2b1e4830)
docs: Add correct/incorrect tags to `prefer-arrow-callback`
([#&#8203;17589](https://togithub.com/eslint/eslint/issues/17589))
(Francesco Trotta)
-
[`20893d4`](https://togithub.com/eslint/eslint/commit/20893d48b9012f2b61bbbfeac8bee70d68d90e5e)
docs: fix incorrect tag's place
([#&#8203;17575](https://togithub.com/eslint/eslint/issues/17575))
(Tanuj Kanti)
-
[`bd7a71f`](https://togithub.com/eslint/eslint/commit/bd7a71fd6b7efb0445393304e2d48c5c06d46a45)
docs: Update README (GitHub Actions Bot)

#### Chores

-
[`f8a8a2d`](https://togithub.com/eslint/eslint/commit/f8a8a2d6b45c82f94a574623759b6e3d2af193f3)
chore: upgrade
[@&#8203;eslint/js](https://togithub.com/eslint/js)[@&#8203;8](https://togithub.com/8).50.0
([#&#8203;17599](https://togithub.com/eslint/eslint/issues/17599))
(Milos Djermanovic)
-
[`38ada6d`](https://togithub.com/eslint/eslint/commit/38ada6df8f4a0313b7d0739b28f0af6b4897b8ce)
chore: package.json update for
[@&#8203;eslint/js](https://togithub.com/eslint/js) release (ESLint
Jenkins)

### [`v8.49.0`](https://togithub.com/eslint/eslint/releases/tag/v8.49.0)

[Compare
Source](https://togithub.com/eslint/eslint/compare/v8.48.0...v8.49.0)

#### Features

-
[`da09f4e`](https://togithub.com/eslint/eslint/commit/da09f4e641141f585ef611c6e9d63d4331054706)
feat: Implement onUnreachableCodePathStart/End
([#&#8203;17511](https://togithub.com/eslint/eslint/issues/17511))
(Nicholas C. Zakas)
-
[`32b2327`](https://togithub.com/eslint/eslint/commit/32b2327aafdd3b911fabab69ed75c9ff97658c60)
feat: Emit deprecation warnings in RuleTester
([#&#8203;17527](https://togithub.com/eslint/eslint/issues/17527))
(Nicholas C. Zakas)
-
[`acb7df3`](https://togithub.com/eslint/eslint/commit/acb7df35b9a7485f26bc6b3e1f9083d1c585dce9)
feat: add new `enforce` option to `lines-between-class-members`
([#&#8203;17462](https://togithub.com/eslint/eslint/issues/17462))
(Nitin Kumar)

#### Documentation

-
[`ecfb54f`](https://togithub.com/eslint/eslint/commit/ecfb54ff4cdd18f28b4f9b78f0a78fb4cf80f1b8)
docs: Update README (GitHub Actions Bot)
-
[`de86b3b`](https://togithub.com/eslint/eslint/commit/de86b3b2e58edd5826200c23255d8325abe375e1)
docs: update `no-promise-executor-return` examples
([#&#8203;17529](https://togithub.com/eslint/eslint/issues/17529))
(Nitin Kumar)
-
[`032c4b1`](https://togithub.com/eslint/eslint/commit/032c4b1476a7b8cfd917a66772d2221950ea87eb)
docs: add typescript template
([#&#8203;17500](https://togithub.com/eslint/eslint/issues/17500))
(James)
-
[`cd7da5c`](https://togithub.com/eslint/eslint/commit/cd7da5cc3154f86f7ca45fb58929d27a7af359ed)
docs: Update README (GitHub Actions Bot)

#### Chores

-
[`b7621c3`](https://togithub.com/eslint/eslint/commit/b7621c3b16cf7d5539f05336a827e1b32d95e6ac)
chore: remove browser test from `npm test`
([#&#8203;17550](https://togithub.com/eslint/eslint/issues/17550))
(Milos Djermanovic)
-
[`cac45d0`](https://togithub.com/eslint/eslint/commit/cac45d04b890b0700dd8908927300608adad05fe)
chore: upgrade
[@&#8203;eslint/js](https://togithub.com/eslint/js)[@&#8203;8](https://togithub.com/8).49.0
([#&#8203;17549](https://togithub.com/eslint/eslint/issues/17549))
(Milos Djermanovic)
-
[`cd39508`](https://togithub.com/eslint/eslint/commit/cd395082bffcb4b68efa09226d7c682cef56179e)
chore: package.json update for
[@&#8203;eslint/js](https://togithub.com/eslint/js) release (ESLint
Jenkins)
-
[`203a971`](https://togithub.com/eslint/eslint/commit/203a971c0abc3a95ae02ff74104a01e569707060)
ci: bump actions/checkout from 3 to 4
([#&#8203;17530](https://togithub.com/eslint/eslint/issues/17530))
(dependabot\[bot])
-
[`a40fa50`](https://togithub.com/eslint/eslint/commit/a40fa509922b36bb986eb1be9394591f84f62d9e)
chore: use eslint-plugin-jsdoc's flat config
([#&#8203;17516](https://togithub.com/eslint/eslint/issues/17516))
(Milos Djermanovic)
-
[`926a286`](https://togithub.com/eslint/eslint/commit/926a28684282aeec37680bbc52a66973b8055f54)
test: replace Karma with Webdriver.IO
([#&#8203;17126](https://togithub.com/eslint/eslint/issues/17126))
(Christian Bromann)
-
[`f591d2c`](https://togithub.com/eslint/eslint/commit/f591d2c88bf15af72e3a207b34fa872b4b90464b)
chore: Upgrade config-array
([#&#8203;17512](https://togithub.com/eslint/eslint/issues/17512))
(Nicholas C. Zakas)

</details>

<details>
<summary>jestjs/jest (jest)</summary>

###
[`v29.7.0`](https://togithub.com/jestjs/jest/blob/HEAD/CHANGELOG.md#2970)

[Compare
Source](https://togithub.com/jestjs/jest/compare/v29.6.4...v29.7.0)

##### Features

- `[create-jest]` Add `npm init` / `yarn create` initialiser for Jest
projects ([#&#8203;14465](https://togithub.com/jestjs/jest/pull/14453))
- `[jest-validate]` Allow deprecation warnings for unknown options
([#&#8203;14499](https://togithub.com/jestjs/jest/pull/14499))

##### Fixes

- `[jest-resolver]` Replace unmatched capture groups in
`moduleNameMapper` with empty string instead of `undefined`
([#&#8203;14507](https://togithub.com/jestjs/jest/pull/14507))
- `[jest-snapshot]` Allow for strings as well as template literals in
inline snapshots
([#&#8203;14465](https://togithub.com/jestjs/jest/pull/14465))
- `[@jest/test-sequencer]` Calculate test runtime if `perStats.duration`
is missing
([#&#8203;14473](https://togithub.com/jestjs/jest/pull/14473))

##### Performance

- `[@jest/create-cache-key-function]` Cache access of `NODE_ENV` and
`BABEL_ENV`
([#&#8203;14455](https://togithub.com/jestjs/jest/pull/14455))

##### Chore & Maintenance

- `[jest-cli]` Move internal config initialisation logic to the
`create-jest` package
([#&#8203;14465](https://togithub.com/jestjs/jest/pull/14453))

</details>

<details>
<summary>bluwy/publint (publint)</summary>

### [`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
[@&#8203;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
[@&#8203;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
[@&#8203;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

</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:eyJjcmVhdGVkSW5WZXIiOiIzNi43OS4xIiwidXBkYXRlZEluVmVyIjoiMzcuMC4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
tnez referenced this issue in tnez/actions Dec 30, 2023
[![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
[@&#8203;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 [@&#8203;wooorm](https://togithub.com/wooorm)
([https://github.com/bluwy/publint/pull/82](https://togithub.com/bluwy/publint/pull/82))

##### New Contributors

- [@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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

- [@&#8203;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

- [@&#8203;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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants