Make prettier.util and prettier.doc available in development cjs version on Node.js>=22 (#17030)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-01-22 10:14:57 +08:00
1 parent b64b0a88ba
commit eecb82dbc5
1 file changed
+12
+12
View File
@@ -45,6 +45,12 @@ if (process.env.NODE_ENV === "production") {
Object.defineProperties(prettier, {
util: {
get() {
try {
return require("./utils/public.js");
} catch {
// No op
}
throw new Error(
"prettier.util is not available in development CommonJS version",
);
@@ -52,6 +58,12 @@ if (process.env.NODE_ENV === "production") {
},
doc: {
get() {
try {
return require("./document/public.js");
} catch {
// No op
}
throw new Error(
"prettier.doc is not available in development CommonJS version",
);