Skip to content
← Back to rules

oxc/no-barrel-file Restriction

무엇을 하나요

Disallow the use of barrel files where the file contains export * statements, and the total number of modules exceed a threshold.

The default threshold is 100.

왜 문제인가요?

Barrel files that re-export many modules can significantly slow down applications and bundlers. When a barrel file exports a large number of modules, importing from it forces the runtime or bundler to process all the exported modules, even if only a few are actually used. This leads to slower startup times and larger bundle sizes.

References:

예시

Invalid:

javascript
export * from "foo"; // where `foo` loads a subtree of 100 modules
import * as ns from "foo"; // where `foo` loads a subtree of 100 modules

Valid:

javascript
export { foo } from "foo";

설정

이 규칙은 다음 속성을 갖는 설정 객체를 허용합니다.

threshold

type: integer

default: 100

The maximum number of modules that can be re-exported via export * before the rule is triggered.

사용 방법

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "oxc/no-barrel-file": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "oxc/no-barrel-file": "error",
  },
});
bash
oxlint --deny oxc/no-barrel-file

버전

이 규칙은 v0.3.0에 추가되었습니다.

참고