Skip to content

Commit

Permalink
fix: convert compat table engine name to browserslist name when query…
Browse files Browse the repository at this point in the history
…ing ESM_SUPPORT
  • Loading branch information
JLHwung committed Jun 29, 2023
1 parent 9979d31 commit b4a87a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
25 changes: 14 additions & 11 deletions packages/babel-helper-compilation-targets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,20 @@ export default function getTargets(

if (esmodules === "intersect") {
for (const browser of Object.keys(queryBrowsers) as Target[]) {
const version = queryBrowsers[browser];
const esmSupportVersion =
// @ts-expect-error ie is not in ESM_SUPPORT
ESM_SUPPORT[browser];

if (esmSupportVersion) {
queryBrowsers[browser] = getHighestUnreleased(
version,
semverify(esmSupportVersion),
browser,
);
if (browser !== "deno" && browser !== "ie") {
const esmSupportVersion =
ESM_SUPPORT[browser === "opera_mobile" ? "op_mob" : browser];

if (esmSupportVersion) {
const version = queryBrowsers[browser];
queryBrowsers[browser] = getHighestUnreleased(
version,
semverify(esmSupportVersion),
browser,
);
} else {
delete queryBrowsers[browser];
}
} else {
delete queryBrowsers[browser];
}
Expand Down
4 changes: 1 addition & 3 deletions packages/babel-helper-compilation-targets/src/targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ export const unreleasedLabels = {
safari: "tp",
} as const;

import type { Target } from "./types";

// Map from browserslist|@mdn/browser-compat-data browser names to @kangax/compat-table browser names
export const browserNameMap: Record<string, Target> = {
export const browserNameMap = {
and_chr: "chrome",
and_ff: "firefox",
android: "android",
Expand Down

0 comments on commit b4a87a9

Please sign in to comment.