@babel/preset-typescript
Advanced tools
Comparing version 7.22.15 to 7.23.0
@@ -31,2 +31,3 @@ 'use strict'; | ||
optimizeConstEnums: "optimizeConstEnums", | ||
rewriteImportExtensions: "rewriteImportExtensions", | ||
allExtensions: "allExtensions", | ||
@@ -51,2 +52,3 @@ isTSX: "isTSX" | ||
const optimizeConstEnums = v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false); | ||
const rewriteImportExtensions = v.validateBooleanOption(TopLevelOptions.rewriteImportExtensions, options.rewriteImportExtensions, false); | ||
const normalized = { | ||
@@ -59,3 +61,4 @@ ignoreExtensions, | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
optimizeConstEnums, | ||
rewriteImportExtensions | ||
}; | ||
@@ -69,2 +72,23 @@ { | ||
var pluginRewriteTSImports = helperPluginUtils.declare(function ({ | ||
types: t | ||
}) { | ||
return { | ||
name: "preset-typescript/plugin-rewrite-ts-imports", | ||
visitor: { | ||
"ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration"({ | ||
node | ||
}) { | ||
const { | ||
source | ||
} = node; | ||
const kind = t.isImportDeclaration(node) ? node.importKind : node.exportKind; | ||
if (kind === "value" && source && /[\\/]/.test(source.value)) { | ||
source.value = source.value.replace(/(\.[mc]?)ts$/, "$1js"); | ||
} | ||
} | ||
} | ||
}; | ||
}); | ||
var index = helperPluginUtils.declarePreset((api, opts) => { | ||
@@ -81,3 +105,4 @@ api.assertVersion(7); | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
optimizeConstEnums, | ||
rewriteImportExtensions | ||
} = normalizeOptions(opts); | ||
@@ -102,2 +127,3 @@ const pluginOptions = disallowAmbiguousJSXLike => ({ | ||
return { | ||
plugins: rewriteImportExtensions ? [pluginRewriteTSImports] : [], | ||
overrides: disableExtensionDetect ? [{ | ||
@@ -104,0 +130,0 @@ plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) |
{ | ||
"name": "@babel/preset-typescript", | ||
"version": "7.22.15", | ||
"version": "7.23.0", | ||
"description": "Babel preset for TypeScript.", | ||
@@ -23,3 +23,3 @@ "repository": { | ||
"@babel/plugin-syntax-jsx": "^7.22.5", | ||
"@babel/plugin-transform-modules-commonjs": "^7.22.15", | ||
"@babel/plugin-transform-modules-commonjs": "^7.23.0", | ||
"@babel/plugin-transform-typescript": "^7.22.15" | ||
@@ -31,3 +31,3 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.22.15", | ||
"@babel/core": "^7.23.0", | ||
"@babel/helper-plugin-test-runner": "^7.22.5" | ||
@@ -34,0 +34,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21346
138
16