Build: mark polyfills pure (#18601)
This commit is contained in:
1 parent
797e260d36
commit
05c6090176
8 files changed
+34
-16
No files matched your search
@@ -503,7 +503,7 @@ const pluginFiles = [
|
|||||||
input: "src/plugins/acorn.js",
|
input: "src/plugins/acorn.js",
|
||||||
replaceModule: [
|
replaceModule: [
|
||||||
{
|
{
|
||||||
module: resolveEsmModulePath("espree"),
|
module: getPackageFile("espree"),
|
||||||
process(text) {
|
process(text) {
|
||||||
const lines = text.split("\n");
|
const lines = text.split("\n");
|
||||||
|
|
||||||
@@ -533,6 +533,18 @@ const pluginFiles = [
|
|||||||
return text;
|
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
|
// We don't use value of JSXText
|
||||||
module: getPackageFile("acorn-jsx/xhtml.js"),
|
module: getPackageFile("acorn-jsx/xhtml.js"),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const colors = new Proxy(String, { get: () => colors });
|
const colors = /* @__PURE__ */ new Proxy(String, { get: () => colors });
|
||||||
|
|
||||||
export default colors;
|
export default colors;
|
||||||
export const createColors = () => colors;
|
export const createColors = () => colors;
|
||||||
@@ -11,7 +11,7 @@ function stringOrArrayAt(index) {
|
|||||||
return this[index < 0 ? this.length + index : 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
|
// "relative indexing" is not available in Node.js v14
|
||||||
// `.at` method is slower than property access on Node.js v16 and v18, see #14396
|
// `.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
|
// 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;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
const findLastIndex = createMethodShim("findLastIndex", function () {
|
const findLastIndex = /* @__PURE__ */ createMethodShim(
|
||||||
if (Array.isArray(this)) {
|
"findLastIndex",
|
||||||
return arrayFindLastIndex;
|
function () {
|
||||||
}
|
if (Array.isArray(this)) {
|
||||||
});
|
return arrayFindLastIndex;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export default findLastIndex;
|
export default findLastIndex;
|
||||||
@@ -11,7 +11,7 @@ const arrayFindLast =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const findLast = createMethodShim("findLast", function () {
|
const findLast = /* @__PURE__ */ createMethodShim("findLast", function () {
|
||||||
if (Array.isArray(this)) {
|
if (Array.isArray(this)) {
|
||||||
return arrayFindLast;
|
return arrayFindLast;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,13 @@ const stringIsWellFormed =
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isWellFormed = createMethodShim("isWellFormed", function () {
|
const isWellFormed = /* @__PURE__ */ createMethodShim(
|
||||||
if (typeof this === "string") {
|
"isWellFormed",
|
||||||
return stringIsWellFormed;
|
function () {
|
||||||
}
|
if (typeof this === "string") {
|
||||||
});
|
return stringIsWellFormed;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export default isWellFormed;
|
export default isWellFormed;
|
||||||
@@ -12,7 +12,7 @@ const stringReplaceAll =
|
|||||||
return this.split(pattern).join(replacement);
|
return this.split(pattern).join(replacement);
|
||||||
};
|
};
|
||||||
|
|
||||||
const replaceAll = createMethodShim("replaceAll", function () {
|
const replaceAll = /* @__PURE__ */ createMethodShim("replaceAll", function () {
|
||||||
if (typeof this === "string") {
|
if (typeof this === "string") {
|
||||||
return stringReplaceAll;
|
return stringReplaceAll;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const arrayToReversed =
|
|||||||
return [...this].reverse();
|
return [...this].reverse();
|
||||||
};
|
};
|
||||||
|
|
||||||
const toReversed = createMethodShim("toReversed", function () {
|
const toReversed = /* @__PURE__ */ createMethodShim("toReversed", function () {
|
||||||
if (Array.isArray(this)) {
|
if (Array.isArray(this)) {
|
||||||
return arrayToReversed;
|
return arrayToReversed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user