@babel/preset-typescript
Advanced tools
Comparing version 8.0.0-alpha.2 to 8.0.0-alpha.3
@@ -1,2 +0,2 @@ | ||
import { declarePreset } from '@babel/helper-plugin-utils'; | ||
import { declare, declarePreset } from '@babel/helper-plugin-utils'; | ||
import transformTypeScript from '@babel/plugin-transform-typescript'; | ||
@@ -22,2 +22,3 @@ import syntaxJSX from '@babel/plugin-syntax-jsx'; | ||
optimizeConstEnums: "optimizeConstEnums", | ||
rewriteImportExtensions: "rewriteImportExtensions", | ||
allExtensions: "allExtensions", | ||
@@ -43,2 +44,3 @@ isTSX: "isTSX" | ||
const optimizeConstEnums = v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false); | ||
const rewriteImportExtensions = v.validateBooleanOption(TopLevelOptions.rewriteImportExtensions, options.rewriteImportExtensions, false); | ||
const normalized = { | ||
@@ -51,3 +53,4 @@ ignoreExtensions, | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
optimizeConstEnums, | ||
rewriteImportExtensions | ||
}; | ||
@@ -57,2 +60,23 @@ return normalized; | ||
var pluginRewriteTSImports = 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 = declarePreset((api, opts) => { | ||
@@ -69,3 +93,4 @@ api.assertVersion(7); | ||
onlyRemoveTypeImports, | ||
optimizeConstEnums | ||
optimizeConstEnums, | ||
rewriteImportExtensions | ||
} = normalizeOptions(opts); | ||
@@ -88,2 +113,3 @@ const pluginOptions = disallowAmbiguousJSXLike => ({ | ||
return { | ||
plugins: rewriteImportExtensions ? [pluginRewriteTSImports] : [], | ||
overrides: disableExtensionDetect ? [{ | ||
@@ -90,0 +116,0 @@ plugins: getPlugins(isTSX, disallowAmbiguousJSXLike) |
{ | ||
"name": "@babel/preset-typescript", | ||
"version": "8.0.0-alpha.2", | ||
"version": "8.0.0-alpha.3", | ||
"description": "Babel preset for TypeScript.", | ||
@@ -20,14 +20,14 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.2", | ||
"@babel/helper-validator-option": "^8.0.0-alpha.2", | ||
"@babel/plugin-syntax-jsx": "^8.0.0-alpha.2", | ||
"@babel/plugin-transform-modules-commonjs": "^8.0.0-alpha.2", | ||
"@babel/plugin-transform-typescript": "^8.0.0-alpha.2" | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.3", | ||
"@babel/helper-validator-option": "^8.0.0-alpha.3", | ||
"@babel/plugin-syntax-jsx": "^8.0.0-alpha.3", | ||
"@babel/plugin-transform-modules-commonjs": "^8.0.0-alpha.3", | ||
"@babel/plugin-transform-typescript": "^8.0.0-alpha.3" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^8.0.0-alpha.2" | ||
"@babel/core": "^8.0.0-alpha.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^8.0.0-alpha.2", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.2" | ||
"@babel/core": "^8.0.0-alpha.3", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "homepage": "https://babel.dev/docs/en/next/babel-preset-typescript", |
Sorry, the diff of this file is not supported yet
22090
5
129