@babel/preset-typescript
Advanced tools
Comparing version 7.22.5 to 7.23.3
@@ -11,6 +11,6 @@ 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } | ||
var transformTypeScript__default = /*#__PURE__*/_interopDefaultLegacy(transformTypeScript); | ||
var transformModulesCommonJS__default = /*#__PURE__*/_interopDefaultLegacy(transformModulesCommonJS); | ||
var transformTypeScript__default = /*#__PURE__*/_interopDefault(transformTypeScript); | ||
var transformModulesCommonJS__default = /*#__PURE__*/_interopDefault(transformModulesCommonJS); | ||
@@ -32,2 +32,3 @@ const v = new helperValidatorOption.OptionValidator("@babel/preset-typescript"); | ||
optimizeConstEnums: "optimizeConstEnums", | ||
rewriteImportExtensions: "rewriteImportExtensions", | ||
allExtensions: "allExtensions", | ||
@@ -52,2 +53,3 @@ isTSX: "isTSX" | ||
const optimizeConstEnums = v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false); | ||
const rewriteImportExtensions = v.validateBooleanOption(TopLevelOptions.rewriteImportExtensions, options.rewriteImportExtensions, false); | ||
const normalized = { | ||
@@ -60,3 +62,4 @@ ignoreExtensions, | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
optimizeConstEnums, | ||
rewriteImportExtensions | ||
}; | ||
@@ -70,2 +73,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").replace(/\.tsx$/, ".js"); | ||
} | ||
} | ||
} | ||
}; | ||
}); | ||
var index = helperPluginUtils.declarePreset((api, opts) => { | ||
@@ -82,3 +106,4 @@ api.assertVersion(7); | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
optimizeConstEnums, | ||
rewriteImportExtensions | ||
} = normalizeOptions(opts); | ||
@@ -96,3 +121,3 @@ const pluginOptions = disallowAmbiguousJSXLike => ({ | ||
{ | ||
return [[transformTypeScript__default["default"], Object.assign({ | ||
return [[transformTypeScript__default.default, Object.assign({ | ||
isTSX | ||
@@ -104,2 +129,3 @@ }, pluginOptions(disallowAmbiguousJSXLike))]]; | ||
return { | ||
plugins: rewriteImportExtensions ? [pluginRewriteTSImports] : [], | ||
overrides: disableExtensionDetect ? [{ | ||
@@ -117,5 +143,5 @@ plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) | ||
sourceType: "unambiguous", | ||
plugins: [[transformModulesCommonJS__default["default"], { | ||
plugins: [[transformModulesCommonJS__default.default, { | ||
allowTopLevelThis: true | ||
}], [transformTypeScript__default["default"], pluginOptions(true)]] | ||
}], [transformTypeScript__default.default, pluginOptions(true)]] | ||
}, { | ||
@@ -128,3 +154,3 @@ test: /\.tsx$/, | ||
exports["default"] = index; | ||
exports.default = index; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/preset-typescript", | ||
"version": "7.22.5", | ||
"version": "7.23.3", | ||
"description": "Babel preset for TypeScript.", | ||
@@ -21,6 +21,6 @@ "repository": { | ||
"@babel/helper-plugin-utils": "^7.22.5", | ||
"@babel/helper-validator-option": "^7.22.5", | ||
"@babel/plugin-syntax-jsx": "^7.22.5", | ||
"@babel/plugin-transform-modules-commonjs": "^7.22.5", | ||
"@babel/plugin-transform-typescript": "^7.22.5" | ||
"@babel/helper-validator-option": "^7.22.15", | ||
"@babel/plugin-syntax-jsx": "^7.23.3", | ||
"@babel/plugin-transform-modules-commonjs": "^7.23.3", | ||
"@babel/plugin-transform-typescript": "^7.23.3" | ||
}, | ||
@@ -31,3 +31,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "^7.22.5", | ||
"@babel/core": "^7.23.3", | ||
"@babel/helper-plugin-test-runner": "^7.22.5" | ||
@@ -34,0 +34,0 @@ }, |
@@ -5,3 +5,3 @@ # @babel/preset-typescript | ||
See our website [@babel/preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20typescript%22+is%3Aopen) associated with this package. | ||
See our website [@babel/preset-typescript](https://babeljs.io/docs/babel-preset-typescript) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20typescript%22+is%3Aopen) associated with this package. | ||
@@ -8,0 +8,0 @@ ## Install |
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
21569
5
138