feat(utils, types): mark the exports v12 removes as @deprecated

Merged
SR
10d ago
+115-43

Seventh PR of the v11.1.0 cleanup (R10, R11): every export v12 removes is marked @deprecated, naming its replacement. Nothing changes at runtime, and no deprecated export emits a new warning.

Summary

 packages/utils/src/readFile.ts
+/** @deprecated Removed in v12. Use `readFileAsync` instead. */
 export function readFile(file: string): string;
+/** @deprecated Removed in v12. Use `readFileAsync` instead. */
 export function readFile(file: string, asBuffer: true): Buffer;
 ...                                         # every overload carries the tag
PackageDeprecated exportUse instead
utilsreadFile (every overload), writeFile, getContentFromFiles, isValidFiletheir …Async versions
utilsdeleteFilefs.promises.unlink
utilsgetSourceMapBooleanextractSourceMapOption
utilstryResolveBuiltIn, tryResolveNpmPackage, tryResolveLocalFileresolveCompressor
utilsgetKnownExportNamegetCompressorEntry(name)?.exportName, with the canonical name (it doesn't resolve aliases: "gcc" → undefined)
utilsisLocalPathnone (resolveCompressor accepts local paths)
utilsvalidateMinifyResultnone (run already validates every result)
utilsbuildArgs, toBuildArgsOptions, BuildArgsOptions, warnDeprecation, resetDeprecationWarningsnone
utilsWildcardOptions.publicFolder (the object form of wildcards options)pass the public folder as a string
utilsWildcardOptions.ignorenone
typesImageFormatnone
typesSettings.option (the CLI's raw -O string)options

wildcards itself isn't deprecated. The changeset (utils minor, types minor) carries this table, so it becomes the 11.1.0 changelog entry. The utils README and AGENTS.md list the deprecated exports, and the README example uses the async functions.

Evidence

  • Comment-only source diff: every changed line under packages/*/src is a comment. No code line changed.
  • Exports unchanged: the exported names of utils (50) and types (10) are identical to develop. The built .d.ts and .js files are byte-identical once comments are stripped.
  • Editors flag them: run on a consumer file that imports the built package, TypeScript's language service reports 'readFile' is deprecated (6385/6387) for all 4 readFile call shapes, and for ImageFormat, WildcardOptions, BuildArgsOptions and settings.option. The replacements are not flagged: readFileAsync, writeFileAsync, resolveCompressor, wildcards(x, "public") and settings.options.
  • Same behavior (AE6): sync readFile, in every variant including the missing-file and directory errors, and 10 other deprecated functions produce identical output on develop's build and this branch's. Nothing is printed to console.warn or console.error.
  • Gate: build, lint, typecheck, check-exports and both guards pass, as do 1141 of 1141 tests.

Merge Danger

Door: two-way. It's a revert away.

Blast Radius: small

  • Runtime: no change. Comments only.
  • Editors and lint: consumers see strikethrough on these imports. A consumer whose lint fails on deprecated APIs (e.g. @typescript-eslint/no-deprecated as an error) will start failing. That's the point of the notice, and it's a v12 heads-up.
  • Not flagged: a call like wildcards(x, { publicFolder }) isn't flagged in editors, only code that names WildcardOptions. Flagging the call would need a separate deprecated overload, which could break callers who pass the WildcardOptions | string union.
  • Internal callers unchanged (the next cleanup PR moves them): validateMinifyResult in cssnano, oxc and minify-html; sync isValidFile in three utils files; Settings.option in the CLI.

Summary by cubic

Marks every export that v12 removes as @deprecated in its JSDoc, so editors show them struck through with a replacement hint. Nothing changes at runtime: no output, signatures, or behavior is altered.

  • @node-minify/utils deprecates readFile, writeFile, getContentFromFiles, isValidFile, deleteFile, getSourceMapBoolean, the tryResolve* helpers, getKnownExportName, isLocalPath, validateMinifyResult, buildArgs, toBuildArgsOptions, BuildArgsOptions, warnDeprecation, resetDeprecationWarnings, and the WildcardOptions object form.
  • @node-minify/types deprecates ImageFormat and Settings.option.
  • Every readFile overload carries the tag so all call shapes are flagged.
  • WildcardOptions.publicFolder is replaced by passing the public folder as a string; WildcardOptions.ignore has no replacement. getKnownExportName's replacement takes the canonical compressor name since getCompressorEntry does not resolve aliases such as gcc.
  • README and AGENTS.md list each deprecated export with its replacement, and the README example now uses the async functions.
  • A changeset records the deprecations and becomes the 11.1.0 changelog entry. No deprecated export emits a new runtime warning, including warnDeprecation itself.

Consumers whose lint rules fail on deprecated APIs will start failing on these imports; that is the intended v12 heads-up. Internal callers still using the deprecated functions migrate in a separate cleanup.