Build: mark polyfills pure (#18601)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-01-10 15:07:34 +08:00
1 parent 797e260d36
commit 05c6090176
8 files changed
+34 -16

No files matched your search

+13 -1
View File
@@ -503,7 +503,7 @@ const pluginFiles = [
input: "src/plugins/acorn.js",
replaceModule: [
{
module: resolveEsmModulePath("espree"),
module: getPackageFile("espree"),
process(text) {
const lines = text.split("\n");
@@ -533,6 +533,18 @@ const pluginFiles = [
return text;
},
},
{
module: getPackageFile("espree/lib/espree.js"),
process(text) {
// We are currently not using tokens
text = text.replace(
'import TokenTranslator from "./token-translator.js";',
"",
);
text = text.replaceAll("options.tokens === true", "false");
return text;
},
},
{
// We don't use value of JSXText
module: getPackageFile("acorn-jsx/xhtml.js"),
+1 -1
View File
@@ -1,4 +1,4 @@
const colors = new Proxy(String, { get: () => colors });
const colors = /* @__PURE__ */ new Proxy(String, { get: () => colors });
export default colors;
export const createColors = () => colors;
+1 -1
View File
@@ -11,7 +11,7 @@ function stringOrArrayAt(index) {
return this[index < 0 ? this.length + index : index];
}
const at = createMethodShim("at", function () {
const at = /* @__PURE__ */ createMethodShim("at", function () {
// "relative indexing" is not available in Node.js v14
// `.at` method is slower than property access on Node.js v16 and v18, see #14396
// Only checked arrays and strings, since we haven't use `TypedArray`, and the transform only works for sources
@@ -13,10 +13,13 @@ const arrayFindLastIndex =
return -1;
};
const findLastIndex = createMethodShim("findLastIndex", function () {
if (Array.isArray(this)) {
return arrayFindLastIndex;
}
});
const findLastIndex = /* @__PURE__ */ createMethodShim(
"findLastIndex",
function () {
if (Array.isArray(this)) {
return arrayFindLastIndex;
}
},
);
export default findLastIndex;
+1 -1
View File
@@ -11,7 +11,7 @@ const arrayFindLast =
}
};
const findLast = createMethodShim("findLast", function () {
const findLast = /* @__PURE__ */ createMethodShim("findLast", function () {
if (Array.isArray(this)) {
return arrayFindLast;
}
+8 -5
View File
@@ -33,10 +33,13 @@ const stringIsWellFormed =
return true;
};
const isWellFormed = createMethodShim("isWellFormed", function () {
if (typeof this === "string") {
return stringIsWellFormed;
}
});
const isWellFormed = /* @__PURE__ */ createMethodShim(
"isWellFormed",
function () {
if (typeof this === "string") {
return stringIsWellFormed;
}
},
);
export default isWellFormed;
+1 -1
View File
@@ -12,7 +12,7 @@ const stringReplaceAll =
return this.split(pattern).join(replacement);
};
const replaceAll = createMethodShim("replaceAll", function () {
const replaceAll = /* @__PURE__ */ createMethodShim("replaceAll", function () {
if (typeof this === "string") {
return stringReplaceAll;
}
+1 -1
View File
@@ -6,7 +6,7 @@ const arrayToReversed =
return [...this].reverse();
};
const toReversed = createMethodShim("toReversed", function () {
const toReversed = /* @__PURE__ */ createMethodShim("toReversed", function () {
if (Array.isArray(this)) {
return arrayToReversed;
}