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

Unable to resolve path to module 'bun:test' with 4.0.0 while 3.9.1 is OK #386

Closed
tomchen opened this issue Mar 17, 2025 · 12 comments · Fixed by #387 or #388
Closed

Unable to resolve path to module 'bun:test' with 4.0.0 while 3.9.1 is OK #386

tomchen opened this issue Mar 17, 2025 · 12 comments · Fixed by #387 or #388
Assignees

Comments

@tomchen
Copy link

tomchen commented Mar 17, 2025

Minimal repro:

git clone https://github.com/tomchen/eslint-import-resolver-typescript-bun-test.git

bun install

bun eslint

(or with npm, yarn, etc.)

It shows:

error Unable to resolve path to module 'bun:test' import/no-unresolved

But if you downgrade eslint-import-resolver-typescript v4.0.0 to v3.9.1, the error will disappear

P.S. @types/bun package is a shim that loads bun-types, type definitions for bun

@JounQin JounQin self-assigned this Mar 17, 2025
@JounQin
Copy link
Collaborator

JounQin commented Mar 17, 2025

Image

I do change the condition inside in v4, because I think we should not always check isBunModule for non-bun users.

And I'm not sure to understand this, process.versions.bun is unavailable when running bun eslint.

bun eslint 1.test.ts

logs:
process.versions.bun undefined [
  '/home/gitpod/.nvm/versions/node/v22.13.1/bin/node',
  '/workspace/eslint-import-resolver-typescript-bun-test/node_modules/.bin/eslint',
  '1.test.ts'
] // process.argv

Is this a bug of bun? @tomchen Can you report to them at the same time?

cc @Jarred-Sumner

@OlivierZal

This comment has been minimized.

@tomchen
Copy link
Author

tomchen commented Mar 17, 2025

@JounQin the process.versions.bun issue does not seem to be relate to the issue I reported here - you can use my repro with npm, yarn and completely without bun, and the result is the same: v3.9.1 good, v4.0.0 bad

I suspect process.versions.bun being unavailable is because bun strictly respects the shebang line #!/usr/bin/env node in ./node_modules/eslint/bin/eslint.js and use node instead bun to execute eslint (or any other similar CLI js script with shebang line)

@JounQin
Copy link
Collaborator

JounQin commented Mar 17, 2025

the process.versions.bun issue does not seem to be relate to the issue I reported here - you can use my repro with npm, yarn and completely without bun, and the result is the same: v3.9.1 good, v4.0.0 bad

As I mentioned above:

I do change the condition inside in v4, because I think we should not always check isBunModule for non-bun users.

@JounQin

This comment has been minimized.

@JounQin

This comment has been minimized.

@tomchen
Copy link
Author

tomchen commented Mar 17, 2025

For that process.versions.bun thing, indeed, https://bun.sh/docs/cli/bunx#shebangs. Even on Windows bun will use node although /usr/bin/env doesn't exist. If user wants to force using bun instead of node, they should run bunx --bun my-cli (or bun --bun eslint in our case). However I don't see changing #!/usr/bin/env node to #!/usr/bin/env bun works as stated in that bun doc page.

Anyway, not sure why there is bun checks in eslint-import-resolver-typescript, but process.versions.bun-based checks (used in eslint-import-resolver-typescript/lib/index.(c)js and by is-bun-module) within eslint will always return false without --bun flag

@OlivierZal

This comment has been minimized.

@JounQin
Copy link
Collaborator

JounQin commented Mar 17, 2025

Anyway, not sure why there is bun checks in eslint-import-resolver-typescript, but process.versions.bun-based checks (used in eslint-import-resolver-typescript/lib/index.(c)js and by is-bun-module) within eslint will always return false without --bun flag

Because the check for bun is a waste for non-bun users, I'll add a bun?: boolean option for this case then, still hope we can check whether the cli is executed by bun without userland flags.

cc @Jarred-Sumner

@OlivierZal

This comment has been minimized.

@JounQin
Copy link
Collaborator

JounQin commented Mar 17, 2025

@tomchen Please try with the new option: bun: true.

@tomchen
Copy link
Author

tomchen commented Mar 17, 2025

Yeah, looks good, thx

renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Mar 18, 2025
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.9.1 | 4.2.1 |


## [v4.2.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#421)

##### Patch Changes

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - fix: don't set empty `configFile` when no `tsconfig` found

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` to v1.2.0


## [v4.2.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#420)

##### Minor Changes

-   [#391](import-js/eslint-import-resolver-typescript#391) [`c8121e5`](import-js/eslint-import-resolver-typescript@c8121e5) Thanks [@JounQin](https://github.com/JounQin)! - feat: make `is-bun-module` as optional peer dependency

    Technically this is a BREAKING CHANGE, but considering we just raise out v4 recently and this only affects `bun` users, `bun --bun eslint` even works without this dependency, so I'd consider this as a minor change.

    So for `bun` users, there are three options:

    1.  install `is-bun-module` dependency manually and use `bun: true` option
    2.  run `eslint` with `bun --bun eslint` w/o `bun: true` option
    3.  enable `run#bun` in [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun) w/o `bun: true` option


## [v4.1.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#411)

##### Patch Changes

-   [#389](import-js/eslint-import-resolver-typescript#389) [`1b97d8a`](import-js/eslint-import-resolver-typescript@1b97d8a) Thanks [@JounQin](https://github.com/JounQin)! - fix: should prefer `module.isBuiltin` when `process.versions.bun` available


## [v4.1.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#410)

##### Minor Changes

-   [#387](import-js/eslint-import-resolver-typescript#387) [`ef5cd10`](import-js/eslint-import-resolver-typescript@ef5cd10) Thanks [@JounQin](https://github.com/JounQin)! - feat: add a new `bun?: boolean` option for `bun` users - close [#386](import-js/eslint-import-resolver-typescript#386)

    `process.versions.bun` is unavailable even with `bun eslint` due to its own design,
    but checking `bun` modules for non-bun users is incorrect behavior and just wasting time,
    so a new option is added for such case, you can still run with `bun --bun eslint` without this option enabled


## [v4.0.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#400)

##### Major Changes

-   [#368](import-js/eslint-import-resolver-typescript#368) [`2fd7c2e`](import-js/eslint-import-resolver-typescript@2fd7c2e) Thanks [@JounQin](https://github.com/JounQin)! - feat!: rewrite, speed up by using [`rspack-resolver`](https://github.com/unrs/rspack-resolver) which supports `references` natively under the hood

    BREAKING CHANGES:

    -   drop Node 14 support, Node `^16.17.0 || >=18.6` is now required
    -   `alwaysTryTypes` is enabled by default, you can set it as `false` to opt-out
    -   array type of `project` is discouraged but still supported, single `project` with `references` are encouraged for better performance, you can enable `noWarnOnMultipleProjects` option to supress the warning message
    -   root `tsconfig.json` or `jsconfig.json` will be used automatically if no `project` provided
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Mar 21, 2025
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.9.1 | 4.2.2 |


## [v4.2.2](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#422)

##### Patch Changes

-   [#397](import-js/eslint-import-resolver-typescript#397) [`14a7688`](import-js/eslint-import-resolver-typescript@14a7688) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` for better P'n'P support

    Now `rspack-resolver` resolves `pnpapi` natively.


## [v4.2.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#421)

##### Patch Changes

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - fix: don't set empty `configFile` when no `tsconfig` found

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` to v1.2.0


## [v4.2.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#420)

##### Minor Changes

-   [#391](import-js/eslint-import-resolver-typescript#391) [`c8121e5`](import-js/eslint-import-resolver-typescript@c8121e5) Thanks [@JounQin](https://github.com/JounQin)! - feat: make `is-bun-module` as optional peer dependency

    Technically this is a BREAKING CHANGE, but considering we just raise out v4 recently and this only affects `bun` users, `bun --bun eslint` even works without this dependency, so I'd consider this as a minor change.

    So for `bun` users, there are three options:

    1.  install `is-bun-module` dependency manually and use `bun: true` option
    2.  run `eslint` with `bun --bun eslint` w/o `bun: true` option
    3.  enable `run#bun` in [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun) w/o `bun: true` option


## [v4.1.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#411)

##### Patch Changes

-   [#389](import-js/eslint-import-resolver-typescript#389) [`1b97d8a`](import-js/eslint-import-resolver-typescript@1b97d8a) Thanks [@JounQin](https://github.com/JounQin)! - fix: should prefer `module.isBuiltin` when `process.versions.bun` available


## [v4.1.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#410)

##### Minor Changes

-   [#387](import-js/eslint-import-resolver-typescript#387) [`ef5cd10`](import-js/eslint-import-resolver-typescript@ef5cd10) Thanks [@JounQin](https://github.com/JounQin)! - feat: add a new `bun?: boolean` option for `bun` users - close [#386](import-js/eslint-import-resolver-typescript#386)

    `process.versions.bun` is unavailable even with `bun eslint` due to its own design,
    but checking `bun` modules for non-bun users is incorrect behavior and just wasting time,
    so a new option is added for such case, you can still run with `bun --bun eslint` without this option enabled


## [v4.0.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#400)

##### Major Changes

-   [#368](import-js/eslint-import-resolver-typescript#368) [`2fd7c2e`](import-js/eslint-import-resolver-typescript@2fd7c2e) Thanks [@JounQin](https://github.com/JounQin)! - feat!: rewrite, speed up by using [`rspack-resolver`](https://github.com/unrs/rspack-resolver) which supports `references` natively under the hood

    BREAKING CHANGES:

    -   drop Node 14 support, Node `^16.17.0 || >=18.6` is now required
    -   `alwaysTryTypes` is enabled by default, you can set it as `false` to opt-out
    -   array type of `project` is discouraged but still supported, single `project` with `references` are encouraged for better performance, you can enable `noWarnOnMultipleProjects` option to supress the warning message
    -   root `tsconfig.json` or `jsconfig.json` will be used automatically if no `project` provided
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Mar 21, 2025
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.9.1 | 4.2.2 |


## [v4.2.2](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#422)

##### Patch Changes

-   [#397](import-js/eslint-import-resolver-typescript#397) [`14a7688`](import-js/eslint-import-resolver-typescript@14a7688) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` for better P'n'P support

    Now `rspack-resolver` resolves `pnpapi` natively.


## [v4.2.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#421)

##### Patch Changes

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - fix: don't set empty `configFile` when no `tsconfig` found

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` to v1.2.0


## [v4.2.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#420)

##### Minor Changes

-   [#391](import-js/eslint-import-resolver-typescript#391) [`c8121e5`](import-js/eslint-import-resolver-typescript@c8121e5) Thanks [@JounQin](https://github.com/JounQin)! - feat: make `is-bun-module` as optional peer dependency

    Technically this is a BREAKING CHANGE, but considering we just raise out v4 recently and this only affects `bun` users, `bun --bun eslint` even works without this dependency, so I'd consider this as a minor change.

    So for `bun` users, there are three options:

    1.  install `is-bun-module` dependency manually and use `bun: true` option
    2.  run `eslint` with `bun --bun eslint` w/o `bun: true` option
    3.  enable `run#bun` in [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun) w/o `bun: true` option


## [v4.1.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#411)

##### Patch Changes

-   [#389](import-js/eslint-import-resolver-typescript#389) [`1b97d8a`](import-js/eslint-import-resolver-typescript@1b97d8a) Thanks [@JounQin](https://github.com/JounQin)! - fix: should prefer `module.isBuiltin` when `process.versions.bun` available


## [v4.1.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#410)

##### Minor Changes

-   [#387](import-js/eslint-import-resolver-typescript#387) [`ef5cd10`](import-js/eslint-import-resolver-typescript@ef5cd10) Thanks [@JounQin](https://github.com/JounQin)! - feat: add a new `bun?: boolean` option for `bun` users - close [#386](import-js/eslint-import-resolver-typescript#386)

    `process.versions.bun` is unavailable even with `bun eslint` due to its own design,
    but checking `bun` modules for non-bun users is incorrect behavior and just wasting time,
    so a new option is added for such case, you can still run with `bun --bun eslint` without this option enabled


## [v4.0.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#400)

##### Major Changes

-   [#368](import-js/eslint-import-resolver-typescript#368) [`2fd7c2e`](import-js/eslint-import-resolver-typescript@2fd7c2e) Thanks [@JounQin](https://github.com/JounQin)! - feat!: rewrite, speed up by using [`rspack-resolver`](https://github.com/unrs/rspack-resolver) which supports `references` natively under the hood

    BREAKING CHANGES:

    -   drop Node 14 support, Node `^16.17.0 || >=18.6` is now required
    -   `alwaysTryTypes` is enabled by default, you can set it as `false` to opt-out
    -   array type of `project` is discouraged but still supported, single `project` with `references` are encouraged for better performance, you can enable `noWarnOnMultipleProjects` option to supress the warning message
    -   root `tsconfig.json` or `jsconfig.json` will be used automatically if no `project` provided
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Mar 22, 2025
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.9.1 | 4.2.2 |


## [v4.2.2](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#422)

##### Patch Changes

-   [#397](import-js/eslint-import-resolver-typescript#397) [`14a7688`](import-js/eslint-import-resolver-typescript@14a7688) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` for better P'n'P support

    Now `rspack-resolver` resolves `pnpapi` natively.


## [v4.2.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#421)

##### Patch Changes

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - fix: don't set empty `configFile` when no `tsconfig` found

-   [#394](import-js/eslint-import-resolver-typescript#394) [`9f11f6b`](import-js/eslint-import-resolver-typescript@9f11f6b) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `rspack-resolver` to v1.2.0


## [v4.2.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#420)

##### Minor Changes

-   [#391](import-js/eslint-import-resolver-typescript#391) [`c8121e5`](import-js/eslint-import-resolver-typescript@c8121e5) Thanks [@JounQin](https://github.com/JounQin)! - feat: make `is-bun-module` as optional peer dependency

    Technically this is a BREAKING CHANGE, but considering we just raise out v4 recently and this only affects `bun` users, `bun --bun eslint` even works without this dependency, so I'd consider this as a minor change.

    So for `bun` users, there are three options:

    1.  install `is-bun-module` dependency manually and use `bun: true` option
    2.  run `eslint` with `bun --bun eslint` w/o `bun: true` option
    3.  enable `run#bun` in [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun) w/o `bun: true` option


## [v4.1.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#411)

##### Patch Changes

-   [#389](import-js/eslint-import-resolver-typescript#389) [`1b97d8a`](import-js/eslint-import-resolver-typescript@1b97d8a) Thanks [@JounQin](https://github.com/JounQin)! - fix: should prefer `module.isBuiltin` when `process.versions.bun` available


## [v4.1.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#410)

##### Minor Changes

-   [#387](import-js/eslint-import-resolver-typescript#387) [`ef5cd10`](import-js/eslint-import-resolver-typescript@ef5cd10) Thanks [@JounQin](https://github.com/JounQin)! - feat: add a new `bun?: boolean` option for `bun` users - close [#386](import-js/eslint-import-resolver-typescript#386)

    `process.versions.bun` is unavailable even with `bun eslint` due to its own design,
    but checking `bun` modules for non-bun users is incorrect behavior and just wasting time,
    so a new option is added for such case, you can still run with `bun --bun eslint` without this option enabled


## [v4.0.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#400)

##### Major Changes

-   [#368](import-js/eslint-import-resolver-typescript#368) [`2fd7c2e`](import-js/eslint-import-resolver-typescript@2fd7c2e) Thanks [@JounQin](https://github.com/JounQin)! - feat!: rewrite, speed up by using [`rspack-resolver`](https://github.com/unrs/rspack-resolver) which supports `references` natively under the hood

    BREAKING CHANGES:

    -   drop Node 14 support, Node `^16.17.0 || >=18.6` is now required
    -   `alwaysTryTypes` is enabled by default, you can set it as `false` to opt-out
    -   array type of `project` is discouraged but still supported, single `project` with `references` are encouraged for better performance, you can enable `noWarnOnMultipleProjects` option to supress the warning message
    -   root `tsconfig.json` or `jsconfig.json` will be used automatically if no `project` provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment