From 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 5 Mar 2022 19:02:27 +0200 Subject: Added node_modules for the updating to work properly. --- .../@babel/core/src/config/files/index-browser.ts | 109 +++++++++++++++++++++ node_modules/@babel/core/src/config/files/index.ts | 30 ++++++ .../core/src/config/resolve-targets-browser.ts | 33 +++++++ .../@babel/core/src/config/resolve-targets.ts | 49 +++++++++ .../@babel/core/src/transform-file-browser.ts | 27 +++++ node_modules/@babel/core/src/transform-file.ts | 40 ++++++++ .../src/transformation/util/clone-deep-browser.ts | 19 ++++ .../core/src/transformation/util/clone-deep.ts | 9 ++ 8 files changed, 316 insertions(+) create mode 100644 node_modules/@babel/core/src/config/files/index-browser.ts create mode 100644 node_modules/@babel/core/src/config/files/index.ts create mode 100644 node_modules/@babel/core/src/config/resolve-targets-browser.ts create mode 100644 node_modules/@babel/core/src/config/resolve-targets.ts create mode 100644 node_modules/@babel/core/src/transform-file-browser.ts create mode 100644 node_modules/@babel/core/src/transform-file.ts create mode 100644 node_modules/@babel/core/src/transformation/util/clone-deep-browser.ts create mode 100644 node_modules/@babel/core/src/transformation/util/clone-deep.ts (limited to 'node_modules/@babel/core/src') diff --git a/node_modules/@babel/core/src/config/files/index-browser.ts b/node_modules/@babel/core/src/config/files/index-browser.ts new file mode 100644 index 0000000..ac615d9 --- /dev/null +++ b/node_modules/@babel/core/src/config/files/index-browser.ts @@ -0,0 +1,109 @@ +import type { Handler } from "gensync"; + +import type { + ConfigFile, + IgnoreFile, + RelativeConfig, + FilePackageData, +} from "./types"; + +import type { CallerMetadata } from "../validation/options"; + +export type { ConfigFile, IgnoreFile, RelativeConfig, FilePackageData }; + +export function findConfigUpwards( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + rootDir: string, +): string | null { + return null; +} + +// eslint-disable-next-line require-yield +export function* findPackageData(filepath: string): Handler { + return { + filepath, + directories: [], + pkg: null, + isPackage: false, + }; +} + +// eslint-disable-next-line require-yield +export function* findRelativeConfig( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + pkgData: FilePackageData, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + envName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + caller: CallerMetadata | void, +): Handler { + return { config: null, ignore: null }; +} + +// eslint-disable-next-line require-yield +export function* findRootConfig( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + dirname: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + envName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + caller: CallerMetadata | void, +): Handler { + return null; +} + +// eslint-disable-next-line require-yield +export function* loadConfig( + name: string, + dirname: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + envName: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + caller: CallerMetadata | void, +): Handler { + throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`); +} + +// eslint-disable-next-line require-yield +export function* resolveShowConfigPath( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + dirname: string, +): Handler { + return null; +} + +export const ROOT_CONFIG_FILENAMES = []; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function resolvePlugin(name: string, dirname: string): string | null { + return null; +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function resolvePreset(name: string, dirname: string): string | null { + return null; +} + +export function loadPlugin( + name: string, + dirname: string, +): Handler<{ + filepath: string; + value: unknown; +}> { + throw new Error( + `Cannot load plugin ${name} relative to ${dirname} in a browser`, + ); +} + +export function loadPreset( + name: string, + dirname: string, +): Handler<{ + filepath: string; + value: unknown; +}> { + throw new Error( + `Cannot load preset ${name} relative to ${dirname} in a browser`, + ); +} diff --git a/node_modules/@babel/core/src/config/files/index.ts b/node_modules/@babel/core/src/config/files/index.ts new file mode 100644 index 0000000..31e8560 --- /dev/null +++ b/node_modules/@babel/core/src/config/files/index.ts @@ -0,0 +1,30 @@ +type indexBrowserType = typeof import("./index-browser"); +type indexType = typeof import("./index"); + +// Kind of gross, but essentially asserting that the exports of this module are the same as the +// exports of index-browser, since this file may be replaced at bundle time with index-browser. +({} as any as indexBrowserType as indexType); + +export { findPackageData } from "./package"; + +export { + findConfigUpwards, + findRelativeConfig, + findRootConfig, + loadConfig, + resolveShowConfigPath, + ROOT_CONFIG_FILENAMES, +} from "./configuration"; +export type { + ConfigFile, + IgnoreFile, + RelativeConfig, + FilePackageData, +} from "./types"; +export { loadPlugin, loadPreset } from "./plugins"; + +import gensync from "gensync"; +import * as plugins from "./plugins"; + +export const resolvePlugin = gensync(plugins.resolvePlugin).sync; +export const resolvePreset = gensync(plugins.resolvePreset).sync; diff --git a/node_modules/@babel/core/src/config/resolve-targets-browser.ts b/node_modules/@babel/core/src/config/resolve-targets-browser.ts new file mode 100644 index 0000000..2d91c92 --- /dev/null +++ b/node_modules/@babel/core/src/config/resolve-targets-browser.ts @@ -0,0 +1,33 @@ +import type { ValidatedOptions } from "./validation/options"; +import getTargets from "@babel/helper-compilation-targets"; + +import type { Targets } from "@babel/helper-compilation-targets"; + +export function resolveBrowserslistConfigFile( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + browserslistConfigFile: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + configFilePath: string, +): string | void { + return undefined; +} + +export function resolveTargets( + options: ValidatedOptions, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + root: string, +): Targets { + // todo(flow->ts) remove any and refactor to not assign different types into same variable + let targets: any = options.targets; + if (typeof targets === "string" || Array.isArray(targets)) { + targets = { browsers: targets }; + } + if (targets && targets.esmodules) { + targets = { ...targets, esmodules: "intersect" }; + } + + return getTargets(targets, { + ignoreBrowserslistConfig: true, + browserslistEnv: options.browserslistEnv, + }); +} diff --git a/node_modules/@babel/core/src/config/resolve-targets.ts b/node_modules/@babel/core/src/config/resolve-targets.ts new file mode 100644 index 0000000..90a443e --- /dev/null +++ b/node_modules/@babel/core/src/config/resolve-targets.ts @@ -0,0 +1,49 @@ +type browserType = typeof import("./resolve-targets-browser"); +type nodeType = typeof import("./resolve-targets"); + +// Kind of gross, but essentially asserting that the exports of this module are the same as the +// exports of index-browser, since this file may be replaced at bundle time with index-browser. +({} as any as browserType as nodeType); + +import type { ValidatedOptions } from "./validation/options"; +import path from "path"; +import getTargets from "@babel/helper-compilation-targets"; + +import type { Targets } from "@babel/helper-compilation-targets"; + +export function resolveBrowserslistConfigFile( + browserslistConfigFile: string, + configFileDir: string, +): string | undefined { + return path.resolve(configFileDir, browserslistConfigFile); +} + +export function resolveTargets( + options: ValidatedOptions, + root: string, +): Targets { + // todo(flow->ts) remove any and refactor to not assign different types into same variable + let targets: any = options.targets; + if (typeof targets === "string" || Array.isArray(targets)) { + targets = { browsers: targets }; + } + if (targets && targets.esmodules) { + targets = { ...targets, esmodules: "intersect" }; + } + + const { browserslistConfigFile } = options; + let configFile; + let ignoreBrowserslistConfig = false; + if (typeof browserslistConfigFile === "string") { + configFile = browserslistConfigFile; + } else { + ignoreBrowserslistConfig = browserslistConfigFile === false; + } + + return getTargets(targets, { + ignoreBrowserslistConfig, + configFile, + configPath: root, + browserslistEnv: options.browserslistEnv, + }); +} diff --git a/node_modules/@babel/core/src/transform-file-browser.ts b/node_modules/@babel/core/src/transform-file-browser.ts new file mode 100644 index 0000000..1adbcd6 --- /dev/null +++ b/node_modules/@babel/core/src/transform-file-browser.ts @@ -0,0 +1,27 @@ +// duplicated from transform-file so we do not have to import anything here +type TransformFile = { + (filename: string, callback: Function): void; + (filename: string, opts: any, callback: Function): void; +}; + +export const transformFile: TransformFile = function transformFile( + filename, + opts, + callback?, +) { + if (typeof opts === "function") { + callback = opts; + } + + callback(new Error("Transforming files is not supported in browsers"), null); +}; + +export function transformFileSync(): never { + throw new Error("Transforming files is not supported in browsers"); +} + +export function transformFileAsync() { + return Promise.reject( + new Error("Transforming files is not supported in browsers"), + ); +} diff --git a/node_modules/@babel/core/src/transform-file.ts b/node_modules/@babel/core/src/transform-file.ts new file mode 100644 index 0000000..4be0e16 --- /dev/null +++ b/node_modules/@babel/core/src/transform-file.ts @@ -0,0 +1,40 @@ +import gensync from "gensync"; + +import loadConfig from "./config"; +import type { InputOptions, ResolvedConfig } from "./config"; +import { run } from "./transformation"; +import type { FileResult, FileResultCallback } from "./transformation"; +import * as fs from "./gensync-utils/fs"; + +type transformFileBrowserType = typeof import("./transform-file-browser"); +type transformFileType = typeof import("./transform-file"); + +// Kind of gross, but essentially asserting that the exports of this module are the same as the +// exports of transform-file-browser, since this file may be replaced at bundle time with +// transform-file-browser. +({} as any as transformFileBrowserType as transformFileType); + +type TransformFile = { + (filename: string, callback: FileResultCallback): void; + ( + filename: string, + opts: InputOptions | undefined | null, + callback: FileResultCallback, + ): void; +}; + +const transformFileRunner = gensync< + (filename: string, opts?: InputOptions) => FileResult | null +>(function* (filename, opts: InputOptions) { + const options = { ...opts, filename }; + + const config: ResolvedConfig | null = yield* loadConfig(options); + if (config === null) return null; + + const code = yield* fs.readFile(filename, "utf8"); + return yield* run(config, code); +}); + +export const transformFile = transformFileRunner.errback as TransformFile; +export const transformFileSync = transformFileRunner.sync; +export const transformFileAsync = transformFileRunner.async; diff --git a/node_modules/@babel/core/src/transformation/util/clone-deep-browser.ts b/node_modules/@babel/core/src/transformation/util/clone-deep-browser.ts new file mode 100644 index 0000000..78ae53e --- /dev/null +++ b/node_modules/@babel/core/src/transformation/util/clone-deep-browser.ts @@ -0,0 +1,19 @@ +const serialized = "$$ babel internal serialized type" + Math.random(); + +function serialize(key, value) { + if (typeof value !== "bigint") return value; + return { + [serialized]: "BigInt", + value: value.toString(), + }; +} + +function revive(key, value) { + if (!value || typeof value !== "object") return value; + if (value[serialized] !== "BigInt") return value; + return BigInt(value.value); +} + +export default function (value) { + return JSON.parse(JSON.stringify(value, serialize), revive); +} diff --git a/node_modules/@babel/core/src/transformation/util/clone-deep.ts b/node_modules/@babel/core/src/transformation/util/clone-deep.ts new file mode 100644 index 0000000..cc077ce --- /dev/null +++ b/node_modules/@babel/core/src/transformation/util/clone-deep.ts @@ -0,0 +1,9 @@ +import v8 from "v8"; +import cloneDeep from "./clone-deep-browser"; + +export default function (value) { + if (v8.deserialize && v8.serialize) { + return v8.deserialize(v8.serialize(value)); + } + return cloneDeep(value); +} -- cgit v1.2.3