Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
119
my-app/node_modules/@babel/helpers/scripts/generate-helpers.js
generated
vendored
Executable file
119
my-app/node_modules/@babel/helpers/scripts/generate-helpers.js
generated
vendored
Executable file
|
@ -0,0 +1,119 @@
|
|||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import fs from "fs";
|
||||
import { join } from "path";
|
||||
import { URL, fileURLToPath } from "url";
|
||||
import { minify } from "terser";
|
||||
import { transformSync } from "@babel/core";
|
||||
import presetTypescript from "@babel/preset-typescript";
|
||||
import { gzipSync } from "zlib";
|
||||
|
||||
const HELPERS_FOLDER = new URL("../src/helpers", import.meta.url);
|
||||
const IGNORED_FILES = new Set(["package.json"]);
|
||||
|
||||
export default async function generateHelpers() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'yarn gulp generate-runtime-helpers'
|
||||
*/
|
||||
|
||||
import template from "@babel/template";
|
||||
|
||||
function helper(minVersion: string, source: string) {
|
||||
return Object.freeze({
|
||||
minVersion,
|
||||
ast: () => template.program.ast(source, { preserveComments: true }),
|
||||
})
|
||||
}
|
||||
|
||||
export default Object.freeze({
|
||||
`;
|
||||
|
||||
for (const file of (await fs.promises.readdir(HELPERS_FOLDER)).sort()) {
|
||||
if (IGNORED_FILES.has(file)) continue;
|
||||
if (file.startsWith(".")) continue; // ignore e.g. vim swap files
|
||||
|
||||
const [helperName] = file.split(".");
|
||||
|
||||
const isTs = file.endsWith(".ts");
|
||||
|
||||
const filePath = join(fileURLToPath(HELPERS_FOLDER), file);
|
||||
if (!file.endsWith(".js") && !isTs) {
|
||||
console.error("ignoring", filePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
let code = await fs.promises.readFile(filePath, "utf8");
|
||||
const minVersionMatch = code.match(
|
||||
/^\s*\/\*\s*@minVersion\s+(?<minVersion>\S+)\s*\*\/\s*$/m
|
||||
);
|
||||
if (!minVersionMatch) {
|
||||
throw new Error(`@minVersion number missing in ${filePath}`);
|
||||
}
|
||||
const { minVersion } = minVersionMatch.groups;
|
||||
|
||||
const mangleFns = code.includes("@mangleFns");
|
||||
const noMangleFns = [];
|
||||
|
||||
code = transformSync(code, {
|
||||
configFile: false,
|
||||
babelrc: false,
|
||||
filename: filePath,
|
||||
presets: [
|
||||
[
|
||||
presetTypescript,
|
||||
{
|
||||
onlyRemoveTypeImports: true,
|
||||
optimizeConstEnums: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [
|
||||
/**
|
||||
* @type {import("@babel/core").PluginObj}
|
||||
*/
|
||||
{
|
||||
visitor: {
|
||||
ImportDeclaration(path) {
|
||||
const source = path.node.source;
|
||||
source.value = source.value
|
||||
.replace(/\.ts$/, "")
|
||||
.replace(/^\.\//, "");
|
||||
},
|
||||
FunctionDeclaration(path) {
|
||||
if (
|
||||
mangleFns &&
|
||||
path.node.leadingComments?.find(c =>
|
||||
c.value.includes("@no-mangle")
|
||||
)
|
||||
) {
|
||||
const name = path.node.id.name;
|
||||
if (name) noMangleFns.push(name);
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}).code;
|
||||
code = (
|
||||
await minify(code, {
|
||||
ecma: 5,
|
||||
mangle: {
|
||||
keep_fnames: mangleFns ? new RegExp(noMangleFns.join("|")) : true,
|
||||
},
|
||||
// The _typeof helper has a custom directive that we must keep
|
||||
compress: { directives: false, passes: 10 },
|
||||
})
|
||||
).code;
|
||||
|
||||
output += `\
|
||||
// size: ${code.length}, gzip size: ${gzipSync(code).length}
|
||||
${JSON.stringify(helperName)}: helper(
|
||||
${JSON.stringify(minVersion)},
|
||||
${JSON.stringify(code)},
|
||||
),
|
||||
`;
|
||||
}
|
||||
|
||||
output += "});";
|
||||
return output;
|
||||
}
|
63
my-app/node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js
generated
vendored
Executable file
63
my-app/node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js
generated
vendored
Executable file
|
@ -0,0 +1,63 @@
|
|||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
|
||||
import fs from "fs";
|
||||
import { createRequire } from "module";
|
||||
|
||||
const [parse, generate] = await Promise.all([
|
||||
import("@babel/parser").then(ns => ns.parse),
|
||||
import("@babel/generator").then(ns => ns.default.default || ns.default),
|
||||
]).catch(error => {
|
||||
console.error(error);
|
||||
throw new Error(
|
||||
"Before running generate-helpers.js you must compile @babel/parser and @babel/generator.",
|
||||
{ cause: error }
|
||||
);
|
||||
});
|
||||
|
||||
const REGENERATOR_RUNTIME_IN_FILE = fs.readFileSync(
|
||||
createRequire(import.meta.url).resolve("regenerator-runtime"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const MIN_VERSION = "7.18.0";
|
||||
|
||||
const HEADER = `/* @minVersion ${MIN_VERSION} */
|
||||
/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate, update the regenerator-runtime dependency of
|
||||
* @babel/helpers and run 'yarn gulp generate-runtime-helpers'.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
`;
|
||||
|
||||
const COPYRIGHT = `/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */`;
|
||||
|
||||
export default function generateRegeneratorRuntimeHelper() {
|
||||
const ast = parse(REGENERATOR_RUNTIME_IN_FILE, { sourceType: "script" });
|
||||
|
||||
const factoryFunction = ast.program.body[0].declarations[0].init.callee;
|
||||
factoryFunction.type = "FunctionDeclaration";
|
||||
factoryFunction.id = { type: "Identifier", name: "_regeneratorRuntime" };
|
||||
factoryFunction.params = [];
|
||||
factoryFunction.body.body.unshift(
|
||||
...stmts(`
|
||||
${COPYRIGHT}
|
||||
_regeneratorRuntime = function () { return exports; };
|
||||
var exports = {};
|
||||
`)
|
||||
);
|
||||
|
||||
const { code } = generate({
|
||||
type: "ExportDefaultDeclaration",
|
||||
declaration: factoryFunction,
|
||||
});
|
||||
|
||||
return HEADER + code;
|
||||
}
|
||||
|
||||
function stmts(code) {
|
||||
return parse(`function _() { ${code} }`, {
|
||||
sourceType: "script",
|
||||
}).program.body[0].body.body;
|
||||
}
|
1
my-app/node_modules/@babel/helpers/scripts/package.json
generated
vendored
Executable file
1
my-app/node_modules/@babel/helpers/scripts/package.json
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{ "type": "module" }
|
Loading…
Add table
Add a link
Reference in a new issue