Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5d28bd

Browse files
Fix Babel 8 compat in syntax-import-attributes
1 parent 5996f97 commit e5d28bd

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

  • packages/babel-plugin-syntax-import-attributes/src

packages/babel-plugin-syntax-import-attributes/src/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ export default declare((api, { deprecatedAssertSyntax }: Options) => {
2929
deprecatedAssertSyntax = true;
3030
}
3131

32-
parserOpts.plugins.push([
33-
"importAttributes",
34-
{ deprecatedAssertSyntax: Boolean(deprecatedAssertSyntax) },
35-
]);
32+
const [major] = api.version.split(".").map(Number);
33+
if (major >= 8) {
34+
if (deprecatedAssertSyntax) {
35+
parserOpts.plugins.push("deprecatedImportAssert");
36+
}
37+
} else {
38+
parserOpts.plugins.push([
39+
"importAttributes",
40+
{ deprecatedAssertSyntax: Boolean(deprecatedAssertSyntax) },
41+
]);
42+
}
3643
},
3744
};
3845
});

0 commit comments

Comments
 (0)