@babel/preset-typescript
Advanced tools
Comparing version 7.21.0 to 7.21.4-esm
@@ -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); | ||
@@ -23,27 +26,32 @@ const v = new helperValidatorOption.OptionValidator("@babel/preset-typescript"); | ||
const TopLevelOptions = { | ||
allExtensions: "allExtensions", | ||
ignoreExtensions: "ignoreExtensions", | ||
allowNamespaces: "allowNamespaces", | ||
disallowAmbiguousJSXLike: "disallowAmbiguousJSXLike", | ||
isTSX: "isTSX", | ||
jsxPragma: "jsxPragma", | ||
jsxPragmaFrag: "jsxPragmaFrag", | ||
onlyRemoveTypeImports: "onlyRemoveTypeImports", | ||
optimizeConstEnums: "optimizeConstEnums" | ||
optimizeConstEnums: "optimizeConstEnums", | ||
allExtensions: "allExtensions", | ||
isTSX: "isTSX" | ||
}; | ||
const jsxPragmaFrag = v.validateStringOption(TopLevelOptions.jsxPragmaFrag, options.jsxPragmaFrag, "React.Fragment"); | ||
const allExtensions = v.validateBooleanOption(TopLevelOptions.allExtensions, options.allExtensions, false); | ||
const isTSX = v.validateBooleanOption(TopLevelOptions.isTSX, options.isTSX, false); | ||
if (isTSX) { | ||
v.invariant(allExtensions, "isTSX:true requires allExtensions:true"); | ||
{ | ||
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"); | ||
} | ||
} | ||
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"); | ||
{ | ||
v.invariant(allExtensions, "disallowAmbiguousJSXLike:true requires allExtensions:true"); | ||
} | ||
} | ||
const optimizeConstEnums = v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false); | ||
return { | ||
allExtensions, | ||
const normalized = { | ||
ignoreExtensions, | ||
allowNamespaces, | ||
disallowAmbiguousJSXLike, | ||
isTSX, | ||
jsxPragma, | ||
@@ -54,2 +62,7 @@ jsxPragmaFrag, | ||
}; | ||
{ | ||
normalized.allExtensions = allExtensions; | ||
normalized.isTSX = isTSX; | ||
} | ||
return normalized; | ||
} | ||
@@ -69,7 +82,6 @@ | ||
} = normalizeOptions(opts); | ||
const pluginOptions = (isTSX, disallowAmbiguousJSXLike) => ({ | ||
const pluginOptions = disallowAmbiguousJSXLike => ({ | ||
allowDeclareFields: opts.allowDeclareFields, | ||
allowNamespaces, | ||
disallowAmbiguousJSXLike, | ||
isTSX, | ||
jsxPragma, | ||
@@ -80,19 +92,28 @@ jsxPragmaFrag, | ||
}); | ||
const getPlugins = (isTSX, disallowAmbiguousJSXLike) => { | ||
{ | ||
return [[transformTypeScript__default["default"], Object.assign({ | ||
isTSX | ||
}, pluginOptions(disallowAmbiguousJSXLike))]]; | ||
} | ||
}; | ||
return { | ||
overrides: allExtensions ? [{ | ||
plugins: [[transformTypeScript__default["default"], pluginOptions(isTSX, disallowAmbiguousJSXLike)]] | ||
plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) | ||
}] : [{ | ||
test: /\.ts$/, | ||
plugins: [[transformTypeScript__default["default"], pluginOptions(false, false)]] | ||
plugins: getPlugins(false, false) | ||
}, { | ||
test: /\.mts$/, | ||
sourceType: "module", | ||
plugins: [[transformTypeScript__default["default"], pluginOptions(false, true)]] | ||
plugins: getPlugins(false, true) | ||
}, { | ||
test: /\.cts$/, | ||
sourceType: "script", | ||
plugins: [[transformTypeScript__default["default"], pluginOptions(false, true)]] | ||
sourceType: "unambiguous", | ||
plugins: [[transformModulesCommonJS__default["default"], { | ||
allowTopLevelThis: true | ||
}], [transformTypeScript__default["default"], pluginOptions(true)]] | ||
}, { | ||
test: /\.tsx$/, | ||
plugins: [[transformTypeScript__default["default"], pluginOptions(true, false)]] | ||
plugins: getPlugins(true, false) | ||
}] | ||
@@ -99,0 +120,0 @@ }; |
{ | ||
"name": "@babel/preset-typescript", | ||
"version": "7.21.0", | ||
"version": "7.21.4-esm", | ||
"description": "Babel preset for TypeScript.", | ||
@@ -20,12 +20,14 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^7.20.2", | ||
"@babel/helper-validator-option": "^7.21.0", | ||
"@babel/plugin-transform-typescript": "^7.21.0" | ||
"@babel/helper-plugin-utils": "^7.21.4-esm", | ||
"@babel/helper-validator-option": "^7.21.4-esm", | ||
"@babel/plugin-syntax-jsx": "^7.21.4-esm", | ||
"@babel/plugin-transform-modules-commonjs": "^7.21.4-esm", | ||
"@babel/plugin-transform-typescript": "^7.21.4-esm" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.0.0-0" | ||
"@babel/core": "^7.0.0-0 || 7.21.4-esm" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.21.0", | ||
"@babel/helper-plugin-test-runner": "^7.18.6" | ||
"@babel/core": "^7.21.4-esm", | ||
"@babel/helper-plugin-test-runner": "^7.21.4-esm" | ||
}, | ||
@@ -32,0 +34,0 @@ "homepage": "https://babel.dev/docs/en/next/babel-preset-typescript", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
17557
6
111
6
2
+ Added@babel/plugin-syntax-jsx@7.24.1(transitive)
+ Added@babel/plugin-transform-modules-commonjs@7.24.1(transitive)
+ Addedelectron-to-chromium@1.4.750(transitive)
- Removedelectron-to-chromium@1.4.746(transitive)