Skip to content

Commit b203c68

Browse files
akamecoclaude
andcommitted
Modernize dependencies by replacing with Node.js built-in APIs
- Replace pify with util.promisify() (Node.js built-in) - Replace mkdirp with fs.mkdirSync({ recursive: true }) (Node.js v10.12+) - Remove @types/pify and @types/mkdirp as no longer needed - Fix TypeScript type errors from promisify transformation - Add ESLint suppressions for necessary any types in Babel integration - Maintain backward compatibility while reducing external dependencies - All tests passing and build successful This reduces the package size and leverages modern Node.js APIs since the minimum required version is Node.js 20. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1f71e7d commit b203c68

File tree

4 files changed

+14
-53
lines changed

4 files changed

+14
-53
lines changed

package-lock.json

Lines changed: 2 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
"load-json-file": "^6.2.0",
5454
"lodash.merge": "^4.6.2",
5555
"meow": "13.2.0",
56-
"mkdirp": "^1.0.4",
57-
"pify": "^5.0.0",
5856
"read-babelrc-up": "^1.1.0",
5957
"sort-keys": "^4.2.0",
6058
"write-json-file": "^4.3.0"
@@ -72,12 +70,9 @@
7270
"@types/js-yaml": "^3.12.10",
7371
"@types/load-json-file": "^2.0.7",
7472
"@types/lodash.merge": "^4.6.9",
75-
"@types/mkdirp": "^1.0.2",
7673
"@types/node": "^24.3.0",
77-
"@types/pify": "^3.0.2",
7874
"@types/temp-write": "^4.0.0",
7975
"@types/write-json-file": "^2.2.1",
80-
"babel-core": "7.0.0-bridge.0",
8176
"babel-plugin-react-intl-auto": "^3.3.0",
8277
"eslint": "^9.34.0",
8378
"husky": "9.1.7",

src/extract-react-intl/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
22
import { glob } from 'glob'
3-
import pify from 'pify'
3+
import { promisify } from 'util'
44
import merge from 'lodash.merge'
55
import deepmerge from 'deepmerge'
66
import {
@@ -149,7 +149,13 @@ export default async (
149149
presets: resolvePresets(presets, babelrcDir),
150150
plugins: resolvePlugins(plugins, babelrcDir)
151151
}
152-
const { metadata } = await pify(transformFile)(file, babelOpts)
152+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
153+
const transformResult = await promisify(transformFile as any)(
154+
file,
155+
babelOpts
156+
)
157+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
158+
const { metadata } = transformResult as { metadata: any }
153159
const localeObj = localeMap(locales)
154160
const result = metadata['react-intl'].messages as Message[]
155161
for (const { id, defaultMessage, description } of result) {

src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import path from 'path'
22
import fs from 'fs'
3-
import mkdirp from 'mkdirp'
43
import yaml from 'js-yaml'
5-
import pify from 'pify'
4+
import { promisify } from 'util'
65
import { flatten, unflatten } from 'flat'
76
import loadJsonFile from 'load-json-file'
87
import writeJsonFile from 'write-json-file'
@@ -14,7 +13,7 @@ const writeJson = (outputPath: string, obj: object, indent: number) => {
1413
}
1514

1615
const writeYaml = (outputPath: string, obj: object, indent: number) => {
17-
return pify(fs.writeFile)(
16+
return promisify(fs.writeFile)(
1817
`${outputPath}.yml`,
1918
yaml.dump(obj, { indent }),
2019
'utf8'
@@ -27,7 +26,7 @@ function loadLocaleFiles(locales: string[], buildDir: string, ext: string) {
2726
const oldLocaleMaps: Record<string, Record<string, object>> = {}
2827

2928
try {
30-
mkdirp.sync(buildDir)
29+
fs.mkdirSync(buildDir, { recursive: true })
3130
} catch {
3231
// Directory already exists or other error, continue
3332
}
@@ -56,7 +55,7 @@ function loadLocaleFiles(locales: string[], buildDir: string, ext: string) {
5655
if (message && typeof message === 'string' && message !== '') {
5756
oldLocaleMaps[locale][messageKey] = (
5857
messages as Record<string, unknown>
59-
)[messageKey]
58+
)[messageKey] as object
6059
}
6160
}
6261
}
@@ -73,7 +72,6 @@ type Opts = {
7372
indent?: number
7473
}
7574

76-
7775
const extractMessage = async (
7876
locales: string[],
7977
pattern: string,

0 commit comments

Comments
 (0)