Skip to content

Commit b78b862

Browse files
zkochanclaude
andcommitted
refactor: convert all packages to ESM with named exports
- Add `"type": "module"` and `"exports"` field to all package.json files - Convert all `require()`/`module.exports` to `import`/`export` - Replace all `export default` with named exports across source, types, and tests - Switch inter-workspace dependencies to `workspace:^` protocol - Remove `dependenciesMeta`/`injected` self-reference pattern (caused infinite prepublishOnly loop) - Update `pnpm-workspace.yaml` to exclude `**/node_modules_link/**` - Fix `fs-extra` import in rename-overwrite (CJS package needs default import) - Update which-pm-runs test fixtures to ESM Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8c2d2b0 commit b78b862

File tree

135 files changed

+797
-1145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+797
-1145
lines changed

better-path-resolve/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
'use strict'
2-
const path = require('path')
3-
const isWindows = require('is-windows')
1+
import path from 'node:path'
2+
import isWindows from 'is-windows'
43

5-
module.exports = isWindows() ? winResolve : path.resolve
4+
export const betterPathResolve = isWindows() ? winResolve : path.resolve
65

76
function winResolve (p) {
87
if (arguments.length === 0) return path.resolve()

better-path-resolve/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "better-path-resolve",
33
"version": "1.0.0",
44
"description": "A better path.resolve() that normalizes paths on Windows",
5+
"type": "module",
56
"main": "index.js",
7+
"exports": "./index.js",
68
"files": [
79
"index.js"
810
],

better-path-resolve/test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict'
2-
const { test } = require('node:test')
3-
const assert = require('node:assert')
4-
const betterPathResolve = require('.')
1+
import { test } from 'node:test'
2+
import assert from 'node:assert'
3+
import { betterPathResolve } from './index.js'
54

65
test('betterPathResolve()', () => {
76
assert.strictEqual(typeof betterPathResolve(), 'string')

can-link/index.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
export = canLink
2-
3-
declare function canLink (existingPath: string, newPath: string): Promise<boolean>
4-
5-
declare namespace canLink {
6-
function sync (existingPath: string, newPath: string): boolean
7-
}
1+
export function canLink (existingPath: string, newPath: string): Promise<boolean>
2+
export function canLinkSync (existingPath: string, newPath: string): boolean

can-link/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict'
2-
const defaultFS = require('fs')
1+
import defaultFS from 'node:fs'
32

4-
module.exports = async (existingPath, newPath, customFS) => {
3+
export async function canLink (existingPath, newPath, customFS) {
54
const fs = customFS || defaultFS
65
try {
76
await fs.promises.link(existingPath, newPath)
@@ -19,7 +18,7 @@ module.exports = async (existingPath, newPath, customFS) => {
1918
}
2019
}
2120

22-
module.exports.sync = (existingPath, newPath, customFS) => {
21+
export function canLinkSync (existingPath, newPath, customFS) {
2322
const fs = customFS || defaultFS
2423
try {
2524
fs.linkSync(existingPath, newPath)

can-link/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "can-link",
33
"version": "2.0.0",
44
"description": "Returns true if a link can be created",
5+
"type": "module",
56
"main": "index.js",
7+
"exports": "./index.js",
68
"typings": "index.d.ts",
79
"files": [
810
"index.js",
@@ -23,13 +25,7 @@
2325
"author": "Zoltan Kochan <z@kochan.io> (https://www.kochan.io/)",
2426
"license": "MIT",
2527
"homepage": "https://github.com/zkochan/packages/tree/main/can-link#readme",
26-
"dependenciesMeta": {
27-
"can-link": {
28-
"injected": true
29-
}
30-
},
3128
"devDependencies": {
32-
"can-link": "file:",
3329
"mos": "2.0.0-alpha.3",
3430
"mos-plugin-readme": "^1.0.4",
3531
"standard": "^16.0.4"

can-link/test.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict'
2-
const { test } = require('node:test')
3-
const assert = require('node:assert')
4-
const canLink = require('can-link')
1+
import { test } from 'node:test'
2+
import assert from 'node:assert'
3+
import { canLink, canLinkSync } from 'can-link'
54

65
const exdevErr = new Error('EXDEV: cross-device link not permitted')
76
exdevErr.code = 'EXDEV'
@@ -12,25 +11,25 @@ eaccesErr.code = 'EACCES'
1211
const epermErr = new Error('EPERM: permission denied, link')
1312
epermErr.code = 'EPERM'
1413

15-
test('canLink.sync()', () => {
16-
assert.ok(canLink.sync('package.json', 'node_modules/package.json'))
17-
assert.ok(!canLink.sync('foo', 'bar', {
14+
test('canLinkSync()', () => {
15+
assert.ok(canLinkSync('package.json', 'node_modules/package.json'))
16+
assert.ok(!canLinkSync('foo', 'bar', {
1817
linkSync: () => { throw exdevErr },
1918
unlinkSync: () => {}
2019
}))
21-
assert.ok(!canLink.sync('foo', 'bar', {
20+
assert.ok(!canLinkSync('foo', 'bar', {
2221
linkSync: () => { throw eaccesErr },
2322
unlinkSync: () => {}
2423
}))
25-
assert.ok(!canLink.sync('foo', 'bar', {
24+
assert.ok(!canLinkSync('foo', 'bar', {
2625
linkSync: () => { throw epermErr },
2726
unlinkSync: () => {}
2827
}))
2928
assert.throws(() => {
3029
const fsMock = {
3130
linkSync: () => { throw new Error('Error') }
3231
}
33-
canLink.sync('foo', 'bar', fsMock)
32+
canLinkSync('foo', 'bar', fsMock)
3433
}, /Error/)
3534
})
3635

can-write-to-dir/index.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
export = canWriteToDir
2-
3-
declare function canWriteToDir (dir: string): Promise<boolean>
4-
5-
declare namespace canWriteToDir {
6-
function sync (dir: string): boolean
7-
}
1+
export function canWriteToDir (dir: string): Promise<boolean>
2+
export function canWriteToDirSync (dir: string): boolean

can-write-to-dir/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
'use strict'
2-
const defaultFS = require('fs')
3-
const pathTemp = require('path-temp')
1+
import defaultFS from 'node:fs'
2+
import { pathTemp } from 'path-temp'
43

5-
module.exports = async (dir, customFS) => {
4+
export async function canWriteToDir (dir, customFS) {
65
const fs = customFS || defaultFS
76
const tempFile = pathTemp(dir)
87
try {
@@ -17,7 +16,7 @@ module.exports = async (dir, customFS) => {
1716
}
1817
}
1918

20-
module.exports.sync = (dir, customFS) => {
19+
export function canWriteToDirSync (dir, customFS) {
2120
const fs = customFS || defaultFS
2221
const tempFile = pathTemp(dir)
2322
try {

can-write-to-dir/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "can-write-to-dir",
33
"version": "1.1.1",
44
"description": "Returns true if the current process has permission to write to the specified directory",
5+
"type": "module",
56
"main": "index.js",
7+
"exports": "./index.js",
68
"typings": "index.d.ts",
79
"files": [
810
"index.js",
@@ -24,16 +26,10 @@
2426
"author": "Zoltan Kochan <z@kochan.io> (https://www.kochan.io/)",
2527
"license": "MIT",
2628
"homepage": "https://github.com/zkochan/packages/tree/main/can-write-to-dir#readme",
27-
"dependenciesMeta": {
28-
"can-write-to-dir": {
29-
"injected": true
30-
}
31-
},
3229
"dependencies": {
33-
"path-temp": "^2.1.0"
30+
"path-temp": "workspace:^"
3431
},
3532
"devDependencies": {
36-
"can-write-to-dir": "file:",
3733
"standard": "^16.0.4"
3834
}
3935
}

0 commit comments

Comments
 (0)