Avoid importing .json files (#12759)
* Avoid importing `.json` files * Use ESold in babel.config.json * Use `import/extensions` eslint plugin
This commit is contained in:
parent
87f264cc7b
commit
e735266dee
@ -43,7 +43,9 @@ module.exports = {
|
|||||||
"@babel/development/no-undefined-identifier": "error",
|
"@babel/development/no-undefined-identifier": "error",
|
||||||
"@babel/development/no-deprecated-clone": "error",
|
"@babel/development/no-deprecated-clone": "error",
|
||||||
"guard-for-in": "error",
|
"guard-for-in": "error",
|
||||||
|
"import/extensions": ["error", { json: "always", cjs: "always" }],
|
||||||
},
|
},
|
||||||
|
globals: { PACKAGE_JSON: "readonly" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: [
|
files: [
|
||||||
@ -63,6 +65,7 @@ module.exports = {
|
|||||||
"jest/no-standalone-expect": "off",
|
"jest/no-standalone-expect": "off",
|
||||||
"jest/no-test-callback": "off",
|
"jest/no-test-callback": "off",
|
||||||
"jest/valid-describe": "off",
|
"jest/valid-describe": "off",
|
||||||
|
"import/extensions": ["error", { json: "always", cjs: "always" }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,6 +17,7 @@ lib/third-party-libs.js.flow
|
|||||||
lib/preset-modules.js.flow
|
lib/preset-modules.js.flow
|
||||||
packages/babel-types/lib/index.js.flow
|
packages/babel-types/lib/index.js.flow
|
||||||
lib/babel-packages.js.flow
|
lib/babel-packages.js.flow
|
||||||
|
lib/package-json.js.flow
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
include_warnings=true
|
include_warnings=true
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const path = require("path");
|
const pathUtils = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
function normalize(src) {
|
function normalize(src) {
|
||||||
return src.replace(/\//, path.sep);
|
return src.replace(/\//, pathUtils.sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function (api) {
|
module.exports = function (api) {
|
||||||
@ -125,6 +126,8 @@ module.exports = function (api) {
|
|||||||
convertESM ? "@babel/proposal-export-namespace-from" : null,
|
convertESM ? "@babel/proposal-export-namespace-from" : null,
|
||||||
convertESM ? "@babel/transform-modules-commonjs" : null,
|
convertESM ? "@babel/transform-modules-commonjs" : null,
|
||||||
|
|
||||||
|
pluginPackageJsonMacro,
|
||||||
|
|
||||||
process.env.STRIP_BABEL_8_FLAG && [
|
process.env.STRIP_BABEL_8_FLAG && [
|
||||||
pluginToggleBabel8Breaking,
|
pluginToggleBabel8Breaking,
|
||||||
{ breaking: bool(process.env.BABEL_8_BREAKING) },
|
{ breaking: bool(process.env.BABEL_8_BREAKING) },
|
||||||
@ -319,3 +322,49 @@ function pluginToggleBabel8Breaking({ types: t }, { breaking }) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pluginPackageJsonMacro({ types: t }) {
|
||||||
|
const fnName = "PACKAGE_JSON";
|
||||||
|
|
||||||
|
return {
|
||||||
|
visitor: {
|
||||||
|
ReferencedIdentifier(path) {
|
||||||
|
if (path.isIdentifier({ name: fnName })) {
|
||||||
|
throw path.buildCodeFrameError(
|
||||||
|
`"${fnName}" is only supported in member expressions.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
MemberExpression(path) {
|
||||||
|
if (!path.get("object").isIdentifier({ name: fnName })) return;
|
||||||
|
|
||||||
|
if (path.node.computed) {
|
||||||
|
throw path.buildCodeFrameError(
|
||||||
|
`"${fnName}" does not support computed properties.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const field = path.node.property.name;
|
||||||
|
|
||||||
|
// TODO: When dropping old Node.js versions, use require.resolve
|
||||||
|
// instead of looping through the folders hierarchy
|
||||||
|
|
||||||
|
let pkg;
|
||||||
|
for (let dir = pathUtils.dirname(this.filename); ; ) {
|
||||||
|
try {
|
||||||
|
pkg = fs.readFileSync(pathUtils.join(dir, "package.json"), "utf8");
|
||||||
|
break;
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
const prev = dir;
|
||||||
|
dir = pathUtils.resolve(dir, "..");
|
||||||
|
|
||||||
|
// We are in the root and didn't find a package.json file
|
||||||
|
if (dir === prev) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = JSON.parse(pkg)[field];
|
||||||
|
path.replaceWith(t.valueToNode(value));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import {
|
|||||||
version as babelCoreVersion,
|
version as babelCoreVersion,
|
||||||
parseSync as babelParse,
|
parseSync as babelParse,
|
||||||
} from "@babel/core";
|
} from "@babel/core";
|
||||||
import packageJson from "../package.json";
|
|
||||||
import {
|
import {
|
||||||
normalizeBabelParseConfig,
|
normalizeBabelParseConfig,
|
||||||
normalizeESLintConfig,
|
normalizeESLintConfig,
|
||||||
@ -27,7 +26,7 @@ function baseParse(code, options) {
|
|||||||
|
|
||||||
if (!isRunningMinSupportedCoreVersion) {
|
if (!isRunningMinSupportedCoreVersion) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`@babel/eslint-parser@${packageJson.version} does not support @babel/core@${babelCoreVersion}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`,
|
`@babel/eslint-parser@${PACKAGE_JSON.version} does not support @babel/core@${babelCoreVersion}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
lib/package-json.d.ts
vendored
Normal file
8
lib/package-json.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// NOTE: This global .d.ts file can be included with
|
||||||
|
// /// <reference path="../../../lib/package-json.d.ts" />
|
||||||
|
// in .ts files using the PACKAGE_JSON macro.
|
||||||
|
|
||||||
|
declare const PACKAGE_JSON: {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
};
|
||||||
4
lib/package-json.js.flow
Normal file
4
lib/package-json.js.flow
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
declare var PACKAGE_JSON: {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
};
|
||||||
@ -6,8 +6,6 @@ import commander from "commander";
|
|||||||
import { version } from "@babel/core";
|
import { version } from "@babel/core";
|
||||||
import glob from "glob";
|
import glob from "glob";
|
||||||
|
|
||||||
import pkg from "../../package.json";
|
|
||||||
|
|
||||||
// Standard Babel input configs.
|
// Standard Babel input configs.
|
||||||
commander.option(
|
commander.option(
|
||||||
"-f, --filename [filename]",
|
"-f, --filename [filename]",
|
||||||
@ -170,7 +168,7 @@ commander.option(
|
|||||||
"Use a specific extension for the output files",
|
"Use a specific extension for the output files",
|
||||||
);
|
);
|
||||||
|
|
||||||
commander.version(pkg.version + " (@babel/core " + version + ")");
|
commander.version(PACKAGE_JSON.version + " (@babel/core " + version + ")");
|
||||||
commander.usage("[options] <files ...>");
|
commander.usage("[options] <files ...>");
|
||||||
// register an empty action handler so that commander.js can throw on
|
// register an empty action handler so that commander.js can throw on
|
||||||
// unknown options _after_ args
|
// unknown options _after_ args
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
export const version = PACKAGE_JSON.version;
|
||||||
|
|
||||||
export { default as File } from "./transformation/file/file";
|
export { default as File } from "./transformation/file/file";
|
||||||
export { default as buildExternalHelpers } from "./tools/build-external-helpers";
|
export { default as buildExternalHelpers } from "./tools/build-external-helpers";
|
||||||
export { resolvePlugin, resolvePreset } from "./config/files";
|
export { resolvePlugin, resolvePreset } from "./config/files";
|
||||||
|
|
||||||
export { version } from "../package.json";
|
|
||||||
export { getEnv } from "./config/helpers/environment";
|
export { getEnv } from "./config/helpers/environment";
|
||||||
|
|
||||||
export * as types from "@babel/types";
|
export * as types from "@babel/types";
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import {
|
|||||||
import { OptionValidator } from "@babel/helper-validator-option";
|
import { OptionValidator } from "@babel/helper-validator-option";
|
||||||
import { browserNameMap } from "./targets";
|
import { browserNameMap } from "./targets";
|
||||||
import { TargetNames } from "./options";
|
import { TargetNames } from "./options";
|
||||||
import { name as packageName } from "../package.json";
|
|
||||||
import type { Targets, InputTargets, Browsers, TargetsTuple } from "./types";
|
import type { Targets, InputTargets, Browsers, TargetsTuple } from "./types";
|
||||||
|
|
||||||
export type { Targets, InputTargets };
|
export type { Targets, InputTargets };
|
||||||
@ -23,7 +22,7 @@ export { getInclusionReasons } from "./debug";
|
|||||||
export { default as filterItems, isRequired } from "./filter-items";
|
export { default as filterItems, isRequired } from "./filter-items";
|
||||||
export { unreleasedLabels } from "./targets";
|
export { unreleasedLabels } from "./targets";
|
||||||
|
|
||||||
const v = new OptionValidator(packageName);
|
const v = new OptionValidator(PACKAGE_JSON.name);
|
||||||
const browserslistDefaults = browserslist.defaults;
|
const browserslistDefaults = browserslist.defaults;
|
||||||
|
|
||||||
function validateTargetNames(targets: Targets): TargetsTuple {
|
function validateTargetNames(targets: Targets): TargetsTuple {
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { OptionValidator } from "@babel/helper-validator-option";
|
import { OptionValidator } from "@babel/helper-validator-option";
|
||||||
import { name as packageName } from "../package.json";
|
|
||||||
import { unreleasedLabels } from "./targets";
|
import { unreleasedLabels } from "./targets";
|
||||||
import type { Target, Targets } from "./types";
|
import type { Target, Targets } from "./types";
|
||||||
|
|
||||||
const versionRegExp = /^(\d+|\d+.\d+)$/;
|
const versionRegExp = /^(\d+|\d+.\d+)$/;
|
||||||
|
|
||||||
const v = new OptionValidator(packageName);
|
const v = new OptionValidator(PACKAGE_JSON.name);
|
||||||
|
|
||||||
export function semverMin(first: ?string, second: string): string {
|
export function semverMin(first: ?string, second: string): string {
|
||||||
return first && semver.lt(first, second) ? first : second;
|
return first && semver.lt(first, second) ? first : second;
|
||||||
|
|||||||
@ -20,15 +20,15 @@ import {
|
|||||||
isLoose,
|
isLoose,
|
||||||
} from "./features";
|
} from "./features";
|
||||||
|
|
||||||
import pkg from "../package.json";
|
|
||||||
|
|
||||||
export { FEATURES, injectInitialization };
|
export { FEATURES, injectInitialization };
|
||||||
|
|
||||||
// Note: Versions are represented as an integer. e.g. 7.1.5 is represented
|
// Note: Versions are represented as an integer. e.g. 7.1.5 is represented
|
||||||
// as 70000100005. This method is easier than using a semver-parsing
|
// as 70000100005. This method is easier than using a semver-parsing
|
||||||
// package, but it breaks if we release x.y.z where x, y or z are
|
// package, but it breaks if we release x.y.z where x, y or z are
|
||||||
// greater than 99_999.
|
// greater than 99_999.
|
||||||
const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0);
|
const version = PACKAGE_JSON.version
|
||||||
|
.split(".")
|
||||||
|
.reduce((v, x) => v * 1e5 + +x, 0);
|
||||||
const versionKey = "@babel/plugin-class-features/version";
|
const versionKey = "@babel/plugin-class-features/version";
|
||||||
|
|
||||||
export function createClassFeaturePlugin({
|
export function createClassFeaturePlugin({
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import {
|
|||||||
} from "./features";
|
} from "./features";
|
||||||
import { generateRegexpuOptions } from "./util";
|
import { generateRegexpuOptions } from "./util";
|
||||||
|
|
||||||
import pkg from "../package.json";
|
|
||||||
import { types as t } from "@babel/core";
|
import { types as t } from "@babel/core";
|
||||||
import annotateAsPure from "@babel/helper-annotate-as-pure";
|
import annotateAsPure from "@babel/helper-annotate-as-pure";
|
||||||
|
|
||||||
@ -29,7 +28,9 @@ function pullFlag(node, flag: RegExpFlags): void {
|
|||||||
// as 70000100005. This method is easier than using a semver-parsing
|
// as 70000100005. This method is easier than using a semver-parsing
|
||||||
// package, but it breaks if we release x.y.z where x, y or z are
|
// package, but it breaks if we release x.y.z where x, y or z are
|
||||||
// greater than 99_999.
|
// greater than 99_999.
|
||||||
const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0);
|
const version = PACKAGE_JSON.version
|
||||||
|
.split(".")
|
||||||
|
.reduce((v, x) => v * 1e5 + +x, 0);
|
||||||
const versionKey = "@babel/plugin-regexp-features/version";
|
const versionKey = "@babel/plugin-regexp-features/version";
|
||||||
|
|
||||||
export function createRegExpFeaturePlugin({ name, feature, options = {} }) {
|
export function createRegExpFeaturePlugin({ name, feature, options = {} }) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import * as t from "@babel/types";
|
import * as t from "@babel/types";
|
||||||
import { willPathCastToBoolean } from "./util.js";
|
import { willPathCastToBoolean } from "./util";
|
||||||
|
|
||||||
class AssignmentMemoiser {
|
class AssignmentMemoiser {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { findSuggestion } from "./find-suggestion.js";
|
import { findSuggestion } from "./find-suggestion";
|
||||||
|
|
||||||
export class OptionValidator {
|
export class OptionValidator {
|
||||||
declare descriptor: string;
|
declare descriptor: string;
|
||||||
|
|||||||
@ -9,8 +9,6 @@ import "core-js/stable";
|
|||||||
import "regenerator-runtime/runtime";
|
import "regenerator-runtime/runtime";
|
||||||
import register from "@babel/register";
|
import register from "@babel/register";
|
||||||
|
|
||||||
import pkg from "../package.json";
|
|
||||||
|
|
||||||
const program = new commander.Command("babel-node");
|
const program = new commander.Command("babel-node");
|
||||||
|
|
||||||
function collect(value, previousValue): Array<string> {
|
function collect(value, previousValue): Array<string> {
|
||||||
@ -61,7 +59,7 @@ program.option(
|
|||||||
program.option("-w, --plugins [string]", "", collect);
|
program.option("-w, --plugins [string]", "", collect);
|
||||||
program.option("-b, --presets [string]", "", collect);
|
program.option("-b, --presets [string]", "", collect);
|
||||||
|
|
||||||
program.version(pkg.version);
|
program.version(PACKAGE_JSON.version);
|
||||||
program.usage("[options] [ -e script | script.js ] [arguments]");
|
program.usage("[options] [ -e script | script.js ] [arguments]");
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ type ErrorContext = {
|
|||||||
|
|
||||||
export type ParsingError = SyntaxError & ErrorContext;
|
export type ParsingError = SyntaxError & ErrorContext;
|
||||||
|
|
||||||
export { ErrorMessages as Errors } from "./error-message.js";
|
export { ErrorMessages as Errors } from "./error-message";
|
||||||
|
|
||||||
export default class ParserError extends CommentsParser {
|
export default class ParserError extends CommentsParser {
|
||||||
// Forward-declaration: defined in tokenizer/index.js
|
// Forward-declaration: defined in tokenizer/index.js
|
||||||
|
|||||||
@ -53,7 +53,7 @@ import {
|
|||||||
newArrowHeadScope,
|
newArrowHeadScope,
|
||||||
newAsyncArrowScope,
|
newAsyncArrowScope,
|
||||||
newExpressionScope,
|
newExpressionScope,
|
||||||
} from "../util/expression-scope.js";
|
} from "../util/expression-scope";
|
||||||
import { Errors } from "./error";
|
import { Errors } from "./error";
|
||||||
|
|
||||||
export default class ExpressionParser extends LValParser {
|
export default class ExpressionParser extends LValParser {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import * as babel from "@babel/core";
|
import * as babel from "@babel/core";
|
||||||
import proposalClassStaticBlock from "../lib/index.js";
|
import proposalClassStaticBlock from "..";
|
||||||
|
|
||||||
describe("plugin ordering", () => {
|
describe("plugin ordering", () => {
|
||||||
it("should throw when @babel/plugin-proposal-class-static-block is after class features plugin", () => {
|
it("should throw when @babel/plugin-proposal-class-static-block is after class features plugin", () => {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { declare } from "@babel/helper-plugin-utils";
|
import { declare } from "@babel/helper-plugin-utils";
|
||||||
import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import";
|
import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import";
|
||||||
import { version } from "../package.json";
|
|
||||||
|
|
||||||
const SUPPORTED_MODULES = ["commonjs", "amd", "systemjs"];
|
const SUPPORTED_MODULES = ["commonjs", "amd", "systemjs"];
|
||||||
|
|
||||||
@ -25,7 +24,10 @@ export default declare(api => {
|
|||||||
inherits: syntaxDynamicImport,
|
inherits: syntaxDynamicImport,
|
||||||
|
|
||||||
pre() {
|
pre() {
|
||||||
this.file.set("@babel/plugin-proposal-dynamic-import", version);
|
this.file.set(
|
||||||
|
"@babel/plugin-proposal-dynamic-import",
|
||||||
|
PACKAGE_JSON.version,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
visitor: {
|
visitor: {
|
||||||
|
|||||||
@ -5,10 +5,7 @@ import {
|
|||||||
} from "@babel/helper-skip-transparent-expression-wrappers";
|
} from "@babel/helper-skip-transparent-expression-wrappers";
|
||||||
import syntaxOptionalChaining from "@babel/plugin-syntax-optional-chaining";
|
import syntaxOptionalChaining from "@babel/plugin-syntax-optional-chaining";
|
||||||
import { types as t, template } from "@babel/core";
|
import { types as t, template } from "@babel/core";
|
||||||
import {
|
import { willPathCastToBoolean, findOutermostTransparentParent } from "./util";
|
||||||
willPathCastToBoolean,
|
|
||||||
findOutermostTransparentParent,
|
|
||||||
} from "./util.js";
|
|
||||||
|
|
||||||
const { ast } = template.expression;
|
const { ast } = template.expression;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
/* eslint-disable @babel/development/plugin-name */
|
/* eslint-disable @babel/development/plugin-name */
|
||||||
|
|
||||||
export { default } from "@babel/plugin-transform-react-jsx/lib/development.js";
|
export { default } from "@babel/plugin-transform-react-jsx/lib/development";
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import createPlugin from "./create-plugin.js";
|
import createPlugin from "./create-plugin";
|
||||||
|
|
||||||
export default createPlugin({
|
export default createPlugin({
|
||||||
name: "transform-react-jsx/development",
|
name: "transform-react-jsx/development",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @babel/development/plugin-name */
|
/* eslint-disable @babel/development/plugin-name */
|
||||||
|
|
||||||
import createPlugin from "./create-plugin.js";
|
import createPlugin from "./create-plugin";
|
||||||
|
|
||||||
export default createPlugin({
|
export default createPlugin({
|
||||||
name: "transform-react-jsx",
|
name: "transform-react-jsx",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import corejs3Polyfills from "core-js-compat/data";
|
import corejs3Polyfills from "core-js-compat/data.json";
|
||||||
import { coerce, SemVer } from "semver";
|
import { coerce, SemVer } from "semver";
|
||||||
import corejs2Polyfills from "@babel/compat-data/corejs2-built-ins";
|
import corejs2Polyfills from "@babel/compat-data/corejs2-built-ins";
|
||||||
import { plugins as pluginsList } from "./plugins-compat-data";
|
import { plugins as pluginsList } from "./plugins-compat-data";
|
||||||
@ -7,7 +7,6 @@ import moduleTransformations from "./module-transformations";
|
|||||||
import { TopLevelOptions, ModulesOption, UseBuiltInsOption } from "./options";
|
import { TopLevelOptions, ModulesOption, UseBuiltInsOption } from "./options";
|
||||||
import { OptionValidator } from "@babel/helper-validator-option";
|
import { OptionValidator } from "@babel/helper-validator-option";
|
||||||
import { defaultWebIncludes } from "./polyfills/corejs2/get-platform-specific-default";
|
import { defaultWebIncludes } from "./polyfills/corejs2/get-platform-specific-default";
|
||||||
import { name as packageName } from "../package.json";
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
BuiltInsOption,
|
BuiltInsOption,
|
||||||
@ -18,7 +17,7 @@ import type {
|
|||||||
PluginListOption,
|
PluginListOption,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
|
||||||
const v = new OptionValidator(packageName);
|
const v = new OptionValidator(PACKAGE_JSON.name);
|
||||||
|
|
||||||
const allPluginsList = Object.keys(pluginsList);
|
const allPluginsList = Object.keys(pluginsList);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import corejs3Polyfills from "core-js-compat/data";
|
import corejs3Polyfills from "core-js-compat/data.json";
|
||||||
import corejsEntries from "core-js-compat/entries";
|
import corejsEntries from "core-js-compat/entries.json";
|
||||||
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
|
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
|
||||||
import { filterItems } from "@babel/helper-compilation-targets";
|
import { filterItems } from "@babel/helper-compilation-targets";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import corejs3Polyfills from "core-js-compat/data";
|
import corejs3Polyfills from "core-js-compat/data.json";
|
||||||
import corejs3ShippedProposalsList from "@babel/compat-data/corejs3-shipped-proposals";
|
import corejs3ShippedProposalsList from "@babel/compat-data/corejs3-shipped-proposals";
|
||||||
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
|
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
|
||||||
import { filterItems } from "@babel/helper-compilation-targets";
|
import { filterItems } from "@babel/helper-compilation-targets";
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { declare } from "@babel/helper-plugin-utils";
|
import { declare } from "@babel/helper-plugin-utils";
|
||||||
import transformTypeScript from "@babel/plugin-transform-typescript";
|
import transformTypeScript from "@babel/plugin-transform-typescript";
|
||||||
import normalizeOptions from "./normalize-options.js";
|
import normalizeOptions from "./normalize-options";
|
||||||
|
|
||||||
export default declare((api, opts) => {
|
export default declare((api, opts) => {
|
||||||
api.assertVersion(7);
|
api.assertVersion(7);
|
||||||
|
|||||||
@ -88,13 +88,14 @@ export default function () {
|
|||||||
? packageJson["browser"]
|
? packageJson["browser"]
|
||||||
: packageJson["main"];
|
: packageJson["main"];
|
||||||
|
|
||||||
const asJS = path.normalize(
|
let asJS = path.normalize(
|
||||||
path.join(
|
path.join(
|
||||||
packageFolder,
|
packageFolder,
|
||||||
// replace lib with src in the package.json entry
|
// replace lib with src in the package.json entry
|
||||||
filename.replace(/^(\.\/)?lib\//, "src/")
|
filename.replace(/^(\.\/)?lib\//, "src/")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if (!/\.[a-z]+$/.test(asJS)) asJS += ".js";
|
||||||
const asTS = asJS.replace(/\.js$/, ".ts");
|
const asTS = asJS.replace(/\.js$/, ".ts");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user