@babel/preset-typescript
Advanced tools
Comparing version 7.13.0 to 7.22.5
@@ -7,2 +7,4 @@ 'use strict'; | ||
var transformTypeScript = require('@babel/plugin-transform-typescript'); | ||
require('@babel/plugin-syntax-jsx'); | ||
var transformModulesCommonJS = require('@babel/plugin-transform-modules-commonjs'); | ||
var helperValidatorOption = require('@babel/helper-validator-option'); | ||
@@ -13,2 +15,3 @@ | ||
var transformTypeScript__default = /*#__PURE__*/_interopDefaultLegacy(transformTypeScript); | ||
var transformModulesCommonJS__default = /*#__PURE__*/_interopDefaultLegacy(transformModulesCommonJS); | ||
@@ -22,49 +25,94 @@ const v = new helperValidatorOption.OptionValidator("@babel/preset-typescript"); | ||
} = options; | ||
const jsxPragmaFrag = v.validateStringOption("jsxPragmaFrag", options.jsxPragmaFrag, "React.Fragment"); | ||
const allExtensions = v.validateBooleanOption("allExtensions", options.allExtensions, false); | ||
const isTSX = v.validateBooleanOption("isTSX", options.isTSX, false); | ||
if (isTSX) { | ||
v.invariant(allExtensions, "isTSX:true requires allExtensions:true"); | ||
const TopLevelOptions = { | ||
ignoreExtensions: "ignoreExtensions", | ||
allowNamespaces: "allowNamespaces", | ||
disallowAmbiguousJSXLike: "disallowAmbiguousJSXLike", | ||
jsxPragma: "jsxPragma", | ||
jsxPragmaFrag: "jsxPragmaFrag", | ||
onlyRemoveTypeImports: "onlyRemoveTypeImports", | ||
optimizeConstEnums: "optimizeConstEnums", | ||
allExtensions: "allExtensions", | ||
isTSX: "isTSX" | ||
}; | ||
const jsxPragmaFrag = v.validateStringOption(TopLevelOptions.jsxPragmaFrag, options.jsxPragmaFrag, "React.Fragment"); | ||
{ | ||
var allExtensions = v.validateBooleanOption(TopLevelOptions.allExtensions, options.allExtensions, false); | ||
var isTSX = v.validateBooleanOption(TopLevelOptions.isTSX, options.isTSX, false); | ||
if (isTSX) { | ||
v.invariant(allExtensions, "isTSX:true requires allExtensions:true"); | ||
} | ||
} | ||
return { | ||
allExtensions, | ||
const ignoreExtensions = v.validateBooleanOption(TopLevelOptions.ignoreExtensions, options.ignoreExtensions, false); | ||
const disallowAmbiguousJSXLike = v.validateBooleanOption(TopLevelOptions.disallowAmbiguousJSXLike, options.disallowAmbiguousJSXLike, false); | ||
if (disallowAmbiguousJSXLike) { | ||
{ | ||
v.invariant(allExtensions, "disallowAmbiguousJSXLike:true requires allExtensions:true"); | ||
} | ||
} | ||
const optimizeConstEnums = v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false); | ||
const normalized = { | ||
ignoreExtensions, | ||
allowNamespaces, | ||
isTSX, | ||
disallowAmbiguousJSXLike, | ||
jsxPragma, | ||
jsxPragmaFrag, | ||
onlyRemoveTypeImports | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
}; | ||
{ | ||
normalized.allExtensions = allExtensions; | ||
normalized.isTSX = isTSX; | ||
} | ||
return normalized; | ||
} | ||
var index = helperPluginUtils.declare((api, opts) => { | ||
var index = helperPluginUtils.declarePreset((api, opts) => { | ||
api.assertVersion(7); | ||
const { | ||
allExtensions, | ||
ignoreExtensions, | ||
allowNamespaces, | ||
disallowAmbiguousJSXLike, | ||
isTSX, | ||
jsxPragma, | ||
jsxPragmaFrag, | ||
onlyRemoveTypeImports | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
} = normalizeOptions(opts); | ||
const pluginOptions = isTSX => ({ | ||
const pluginOptions = disallowAmbiguousJSXLike => ({ | ||
allowDeclareFields: opts.allowDeclareFields, | ||
allowNamespaces, | ||
isTSX, | ||
disallowAmbiguousJSXLike, | ||
jsxPragma, | ||
jsxPragmaFrag, | ||
onlyRemoveTypeImports | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
}); | ||
const getPlugins = (isTSX, disallowAmbiguousJSXLike) => { | ||
{ | ||
return [[transformTypeScript__default["default"], Object.assign({ | ||
isTSX | ||
}, pluginOptions(disallowAmbiguousJSXLike))]]; | ||
} | ||
}; | ||
const disableExtensionDetect = allExtensions || ignoreExtensions; | ||
return { | ||
overrides: allExtensions ? [{ | ||
plugins: [[transformTypeScript__default['default'], pluginOptions(isTSX)]] | ||
overrides: disableExtensionDetect ? [{ | ||
plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) | ||
}] : [{ | ||
test: /\.ts$/, | ||
plugins: [[transformTypeScript__default['default'], pluginOptions(false)]] | ||
plugins: getPlugins(false, false) | ||
}, { | ||
test: /\.mts$/, | ||
sourceType: "module", | ||
plugins: getPlugins(false, true) | ||
}, { | ||
test: /\.cts$/, | ||
sourceType: "unambiguous", | ||
plugins: [[transformModulesCommonJS__default["default"], { | ||
allowTopLevelThis: true | ||
}], [transformTypeScript__default["default"], pluginOptions(true)]] | ||
}, { | ||
test: /\.tsx$/, | ||
plugins: [[transformTypeScript__default['default'], pluginOptions(true)]] | ||
plugins: getPlugins(true, false) | ||
}] | ||
@@ -74,3 +122,3 @@ }; | ||
exports.default = index; | ||
exports["default"] = index; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/preset-typescript", | ||
"version": "7.13.0", | ||
"version": "7.22.5", | ||
"description": "Babel preset for TypeScript.", | ||
@@ -14,3 +14,3 @@ "repository": { | ||
}, | ||
"main": "lib/index.js", | ||
"main": "./lib/index.js", | ||
"keywords": [ | ||
@@ -21,5 +21,7 @@ "babel-preset", | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^7.13.0", | ||
"@babel/helper-validator-option": "^7.12.17", | ||
"@babel/plugin-transform-typescript": "^7.13.0" | ||
"@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" | ||
}, | ||
@@ -30,7 +32,12 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "7.13.0", | ||
"@babel/helper-plugin-test-runner": "7.12.13" | ||
"@babel/core": "^7.22.5", | ||
"@babel/helper-plugin-test-runner": "^7.22.5" | ||
}, | ||
"homepage": "https://babel.dev/docs/en/next/babel-preset-typescript", | ||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20typescript%22+is%3Aopen" | ||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20typescript%22+is%3Aopen", | ||
"engines": { | ||
"node": ">=6.9.0" | ||
}, | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
"type": "commonjs" | ||
} |
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
25664
7
170
1
6
+ Added@babel/code-frame@7.26.0(transitive)
+ Added@babel/compat-data@7.26.0(transitive)
+ Added@babel/generator@7.26.0(transitive)
+ Added@babel/helper-simple-access@7.25.9(transitive)
+ Added@babel/parser@7.26.1(transitive)
+ Added@babel/plugin-syntax-jsx@7.25.9(transitive)
+ Added@babel/plugin-transform-modules-commonjs@7.25.9(transitive)
+ Addedcaniuse-lite@1.0.30001674(transitive)
+ Addedelectron-to-chromium@1.5.49(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/compat-data@7.26.2(transitive)
- Removed@babel/generator@7.26.2(transitive)
- Removed@babel/parser@7.26.2(transitive)
- Removedcaniuse-lite@1.0.30001677(transitive)
- Removedelectron-to-chromium@1.5.51(transitive)