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

feat: make is-bun-module as optional peer dependency #391

Merged
merged 5 commits into from
Mar 18, 2025

Conversation

JounQin
Copy link
Collaborator

@JounQin JounQin commented Mar 17, 2025

related #389 (comment)

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 w/o bun: true option

cc @SukkaW @SunsetTechuila

Copy link

changeset-bot bot commented Mar 17, 2025

🦋 Changeset detected

Latest commit: 4ddad73

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-import-resolver-typescript Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codesandbox-ci bot commented Mar 17, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

github-actions bot commented Mar 17, 2025

size-limit report 📦

Path Size
lib/index.js 1.4 KB (-6.32% 🔽)

@SunsetTechuila
Copy link
Contributor

SunsetTechuila commented Mar 17, 2025

my opinion is that this package should ignore bun modules by default, this is something i personally would expect

anyway

pros of making is-bun-module optional:

  • saves 25kb of disc space and 7.7kb of network data (if the user doesn't have semver in (sub)dependencies, which is very unlikely)

cons:

  • leads to a more complicated code
  • potentially creates hassle for the users

i'm also considering reworking my package, so you would be able to just do

if (module.isBuiltin(source) || isBunBuiltin(source)) {
  log('matched core:', source)
  return { found: true, path: null }
}

instead of all of this:

let bunVersion = process.versions.bun as Version | undefined
// don't worry about bun core modules
if (bunVersion || options.bun) {
if (
bunVersion
? module.isBuiltin(source)
: isBunModule(source, (bunVersion = 'latest')) ||
isSupportedNodeModule(source, bunVersion)
) {
log('matched bun core:', source)
return { found: true, path: null }
}
} else if (module.isBuiltin(source)) {
// don't worry about node core modules
log('matched node core:', source)
return { found: true, path: null }
}

@JounQin
Copy link
Collaborator Author

JounQin commented Mar 17, 2025

my opinion is that this package should ignore bun modules by default, this is something i personally would expect

Doesn't it?

if the user doesn't have semver in (sub)dependencies, which is very unlikely

image

Yeah, and alo multiple incompatible versions can be installed unfortunately.

i'm also considering reworking my package, so you would be able to just do

Great! I'm holding on in favor of this then.

@SunsetTechuila

This comment was marked as resolved.

@JounQin
Copy link
Collaborator Author

JounQin commented Mar 17, 2025

That's why bun?: boolean option is added? Non-bun users should not try to resolve bun modules otherwise there could be unexpected behavior.

@JounQin
Copy link
Collaborator Author

JounQin commented Mar 17, 2025

I refactor the codes a little, no process.versions.bun check needed anymore.

The refactored codes are much cleaner now, no need to waiting is-bun-module changes.

@JounQin JounQin force-pushed the feat/optional_bun branch from 01c9a53 to 3dab67d Compare March 18, 2025 02:12
@JounQin JounQin force-pushed the feat/optional_bun branch from 3dab67d to 2528b37 Compare March 18, 2025 02:12
@JounQin JounQin merged commit c8121e5 into master Mar 18, 2025
30 checks passed
@JounQin JounQin deleted the feat/optional_bun branch March 18, 2025 02:58
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request 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
@SunsetTechuila
Copy link
Contributor

SunsetTechuila commented Mar 20, 2025

isBunBuiltin(source)

@JounQin need your opinion: should this function return true for node built-in modules that are not implemented in bun? and so, should eslint-import-resolver-typescript resolve such modules?

@SunsetTechuila
Copy link
Contributor

module.isBuiltin returns true for non-implemented node modules and mdoule.builtinModules contains them

@JounQin
Copy link
Collaborator Author

JounQin commented Mar 20, 2025

module.isBuiltin returns true for non-implemented node modules and mdoule.builtinModules contains them

@SunsetTechuila I personally think it should return false, and that's why I split bun condition with node core previously. And that would help bun users avoid using non-implemented features.

But with that change, is-bun-module seems can not be optional for bun anymore? Because module.isBuiltin is incorrect in this case.

@SunsetTechuila
Copy link
Contributor

SunsetTechuila commented Mar 20, 2025

is-bun-module seems can not be optional

i think so. i would expect eslint-import-resolver-typescript to detect if i'm running it in bun and use is-bun-module for checking if given module is a built-in

@SunsetTechuila
Copy link
Contributor

SunsetTechuila commented Mar 20, 2025

i'm also considering reworking my package

this is what i have right now: SunsetTechuila/is-bun-module@66d9385

@JounQin
Copy link
Collaborator Author

JounQin commented Mar 20, 2025

i think so. i would expect eslint-import-resolver-typescript to detect if i'm running it in bun and use is-bun-module for checking if given module is a built-in

Sure it should! Let's add it back then, would you like to raise a PR for this?

@SunsetTechuila
Copy link
Contributor

would you like to raise a PR for this?

i will do so as soon as my package is ready

renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request 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 pull request 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 pull request 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
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants