Skip to content

fix(oxlint-config): bundle the dependencies of @stylistic rules - #11

Merged
vovkabelov merged 1 commit into
mainfrom
fix/oxlint-config-bundle-deps
Oct 12, 2026
Merged

vovkabelov merged 1 commit into
mainfrom
fix/oxlint-config-bundle-deps

Conversation

@vovkabelov

Copy link
Copy Markdown
Collaborator

Problem

@bitrix24/oxlint-config-bitrix24@0.1.0 fails to load in a project that does not happen to have @eslint-community/eslint-utils installed:

Failed to load JS plugin: .../@bitrix24/oxlint-config-bitrix24/dist/stylistic.js
Error: Cannot find module '@eslint-community/eslint-utils'

@stylistic/eslint-plugin is built with rolldown, whose output loads the dependencies of its vendored code with a require() made by createRequire(import.meta.url). esbuild does not follow such calls, so dist/stylistic.js required @eslint-community/eslint-utils and @typescript-eslint/types at runtime. Neither is a dependency of the package. The tests passed because both packages are installed in the repository as dev dependencies. oxlint-config-bitrix24-mobile@0.1.0 is broken too, since it extends this preset.

Fix

  • The build turns those calls in @stylistic/eslint-plugin/dist into plain require() calls, which esbuild bundles.
  • The build fails if dist/ still loads a package other than a node built-in or the optional typescript (loaded by eslint-plugin-vue in try/catch).
  • Version 0.1.1. The mobile preset needs no new version: its peer range ^0.1.0 takes 0.1.1.

Tests

  • New test: dist/ is copied to a directory with no node_modules around it and every bundle is imported. It fails on 0.1.0 with the error above.
  • oxlint-config-bitrix24: 184 tests pass.
  • The packed 0.1.1 installed in an empty project with oxlint@1.87.0 and @bitrix24/oxlint-config-bitrix24-mobile@0.1.0 from npm lints with both presets: native rules, @stylistic, @bitrix24/bitrix24-rules and the mobile overrides all report.

After the merge, 0.1.1 is published through the workflow (once the trusted publisher is set up for the package), and 0.1.0 can be deprecated:

npm deprecate @bitrix24/oxlint-config-bitrix24@0.1.0 "Fails to load: use 0.1.1"

@stylistic/eslint-plugin is built with rolldown, whose output loads the
dependencies of its vendored code with a require() made by createRequire().
esbuild does not follow such calls, so dist/stylistic.js required
@eslint-community/eslint-utils and @typescript-eslint/types at runtime.
Neither is a dependency of the package: 0.1.0 fails to load in a project
that does not have them installed. The tests did not notice, since the
packages are installed in the repository as dev dependencies.

The build now turns those calls into plain require() calls, which esbuild
bundles, and fails if dist/ still loads a package other than a node
built-in or the optional typescript. A new test loads dist/ from a
directory without node_modules around it.
@vovkabelov
vovkabelov merged commit 695f199 into main Oct 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant