unbarrelify 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +30 -21
  2. package/dist/cli.js +0 -0
  3. package/package.json +34 -26
package/README.md CHANGED
@@ -16,28 +16,28 @@ export { capitalize } from "./string.ts";
16
16
 
17
17
  Barrel files are convenient, but they often come with trade-offs including:
18
18
 
19
- * Performance and memory: they artificially inflate the module graph and slow down startup times, HMR, and CI pipelines.
20
- * Tree-shaking failures: they often confuse tree-shakers, risk entire libraries to be bundled when only a single function is needed.
21
- * Circular dependencies: they frequently create "import cycles", crashing bundlers or causing confusing errors.
19
+ - Performance and memory: they artificially inflate the module graph and slow down startup times, HMR, and CI pipelines.
20
+ - Tree-shaking failures: they often confuse tree-shakers, risk entire libraries to be bundled when only a single function is needed.
21
+ - Circular dependencies: they frequently create "import cycles", crashing bundlers or causing confusing errors.
22
22
 
23
23
  ## Resources
24
24
 
25
- * [Speeding up the JavaScript ecosystem - The barrel file debacle][1] (Marvin Hagemeister, 2023-10-08)
26
- * [How we optimized package imports in Next.js][2] (Shu Ding, 2023-10-13)
27
- * [A practical guide against barrel files for library authors][3] (Pascal Schilp, 2024-06-01)
28
- * [Please Stop Using Barrel Files][4] (Dominik Dorfmeister, 2024-07-26)
25
+ - [Speeding up the JavaScript ecosystem - The barrel file debacle][1] (Marvin Hagemeister, 2023-10-08)
26
+ - [How we optimized package imports in Next.js][2] (Shu Ding, 2023-10-13)
27
+ - [A practical guide against barrel files for library authors][3] (Pascal Schilp, 2024-06-01)
28
+ - [Please Stop Using Barrel Files][4] (Dominik Dorfmeister, 2024-07-26)
29
29
 
30
30
  ## Features
31
31
 
32
- * Automated rewiring of consumers to import directly from source
33
- * Preserves path aliases
34
- * Skips barrel files that are entry points (`package.json#exports` etc.)
35
- * Auto-detects or enforces file extensions to match project style
36
- * Optional `--organize-imports` to dedupe and clean up after rewrites
37
- * Granular control with `--skip`, `--only` or add `--barrel`-like files
38
- * Use `--check` for CI to fail if barrel files are detected
39
- * Go all out with `--unsafe-namespace` to namespace imports (warning: naive)
40
- * [Verified on non-trivial repositories][5] to not break the build/tests
32
+ - Automated rewiring of consumers to import directly from source
33
+ - Preserves path aliases
34
+ - Skips barrel files that are entry points (`package.json#exports` etc.)
35
+ - Auto-detects or enforces file extensions to match project style
36
+ - Optional `--organize-imports` to dedupe and clean up after rewrites
37
+ - Granular control with `--skip`, `--only` or add `--barrel`-like files
38
+ - Use `--check` for CI to fail if barrel files are detected
39
+ - Go all out with `--unsafe-namespace` to namespace imports (warning: naive)
40
+ - [Verified on non-trivial repositories][5] to not break the build/tests
41
41
 
42
42
  ## Usage
43
43
 
@@ -139,7 +139,7 @@ interface Result {
139
139
  preserved: PreservedBarrel[];
140
140
  }
141
141
 
142
- interface PreservedBarrel {
142
+ interface PreservedBarrel {
143
143
  path: string;
144
144
  reason: "skip" | "namespace-import" | "non-ts-import" | "dynamic-import";
145
145
  consumers: string[];
@@ -174,16 +174,25 @@ import { formatDate } from "./utils/date.ts";
174
174
  import { capitalize } from "./utils/string.ts";
175
175
  ```
176
176
 
177
+ ## Preserved barrel files
178
+
179
+ This prevents barrel files from getting deleted:
180
+
181
+ - File is in `package.json` such as `main` or `exports` field.
182
+ - File is `index.*` at root level (of each workspace).
183
+ - File is in `--skip` argument.
184
+ - Dynamic import calls are not modified, so the imported barrel file is not deleted (e.g. `import("barrel.ts")`).
185
+ - Non-JS/TS files are not modified, so the imported barrel file is not deleted (e.g. `*.mdx`).
186
+ - Namespace imports are not modified, use `--unsafe-namespace` to rewrite (e.g. `import * as NS from "barrel"`).
187
+
188
+ The output in CLI prints "Preserved barrel files" with details.
189
+
177
190
  ## License
178
191
 
179
192
  ISC
180
193
 
181
194
  [1]: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/
182
-
183
195
  [2]: https://vercel.com/blog/how-we-optimized-package-imports-in-next-js
184
-
185
196
  [3]: https://dev.to/thepassle/a-practical-guide-against-barrel-files-for-library-authors-118c
186
-
187
197
  [4]: https://tkdodo.eu/blog/please-stop-using-barrel-files
188
-
189
198
  [5]: https://github.com/webpro/unbarrelify/blob/main/.github/workflows/integration.yml
package/dist/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,8 +1,31 @@
1
1
  {
2
2
  "name": "unbarrelify",
3
- "version": "1.1.0",
4
- "type": "module",
3
+ "version": "1.1.2",
5
4
  "description": "Barrel file removal tool for JavaScript & TypeScript projects (ESM-only)",
5
+ "keywords": [
6
+ "ESM",
7
+ "barrel",
8
+ "codemod",
9
+ "exports",
10
+ "files",
11
+ "imports",
12
+ "index",
13
+ "refactor",
14
+ "rewrite",
15
+ "typescript"
16
+ ],
17
+ "license": "ISC",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/webpro-nl/unbarrelify.git"
21
+ },
22
+ "bin": {
23
+ "unbarrelify": "./dist/cli.js"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "type": "module",
6
29
  "main": "./dist/index.js",
7
30
  "types": "./dist/index.d.ts",
8
31
  "exports": {
@@ -11,40 +34,25 @@
11
34
  "import": "./dist/index.js"
12
35
  }
13
36
  },
14
- "bin": {
15
- "unbarrelify": "./dist/cli.js"
16
- },
17
- "files": [
18
- "dist"
19
- ],
20
37
  "scripts": {
21
38
  "build": "tsc",
22
39
  "test": "node --test test/**/*.test.ts",
40
+ "lint": "oxlint",
41
+ "format": "oxfmt",
23
42
  "prepack": "tsc"
24
43
  },
25
44
  "dependencies": {
26
- "oxc-resolver": "^11.16.3",
27
- "tinyglobby": "^0.2.15",
28
- "typescript": "^5.9.3"
45
+ "oxc-resolver": "^11.19.1",
46
+ "tinyglobby": "^0.2.16",
47
+ "typescript": "^6.0.3"
29
48
  },
30
49
  "devDependencies": {
31
- "@types/node": "^24.10.9"
50
+ "@types/node": "^24.10.9",
51
+ "oxfmt": "^0.50.0",
52
+ "oxlint": "^1.65.0"
32
53
  },
33
54
  "engines": {
34
55
  "node": ">=20.12.0"
35
56
  },
36
- "keywords": [
37
- "barrel",
38
- "codemod",
39
- "ESM",
40
- "exports",
41
- "files",
42
- "imports",
43
- "index",
44
- "refactor",
45
- "rewrite",
46
- "typescript"
47
- ],
48
- "license": "ISC",
49
- "packageManager": "pnpm@10.28.1"
57
+ "packageManager": "pnpm@11.1.3"
50
58
  }