babel preset with typescript (#771)
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
const r = require(`./resolver`);
|
const r = require(`./resolver`)
|
||||||
|
|
||||||
function preset(context, options = {}) {
|
function preset(context, options = {}) {
|
||||||
const { debug = false, nodeVersion = `10.14.0` } = options;
|
const { debug = false, nodeVersion = `10.14.0` } = options
|
||||||
const { NODE_ENV, BABEL_ENV } = process.env;
|
const { NODE_ENV, BABEL_ENV } = process.env
|
||||||
|
|
||||||
const nodeConfig = {
|
const nodeConfig = {
|
||||||
corejs: 3,
|
corejs: 3,
|
||||||
@@ -10,10 +10,10 @@ function preset(context, options = {}) {
|
|||||||
targets: {
|
targets: {
|
||||||
node: nodeVersion,
|
node: nodeVersion,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
presets: [r(`@babel/preset-env`)],
|
presets: [r(`@babel/preset-env`), r(`@babel/preset-typescript`)],
|
||||||
plugins: [
|
plugins: [
|
||||||
r(`babel-plugin-transform-typescript-metadata`),
|
r(`babel-plugin-transform-typescript-metadata`),
|
||||||
r(`@babel/plugin-proposal-optional-chaining`),
|
r(`@babel/plugin-proposal-optional-chaining`),
|
||||||
@@ -23,7 +23,7 @@ function preset(context, options = {}) {
|
|||||||
r(`@babel/plugin-transform-instanceof`),
|
r(`@babel/plugin-transform-instanceof`),
|
||||||
r(`@babel/plugin-transform-runtime`),
|
r(`@babel/plugin-transform-runtime`),
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = preset;
|
module.exports = preset
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"@babel/plugin-transform-instanceof": "^7.12.1",
|
"@babel/plugin-transform-instanceof": "^7.12.1",
|
||||||
"@babel/plugin-transform-runtime": "^7.12.1",
|
"@babel/plugin-transform-runtime": "^7.12.1",
|
||||||
"@babel/preset-env": "^7.12.7",
|
"@babel/preset-env": "^7.12.7",
|
||||||
|
"@babel/preset-typescript": "^7.16.0",
|
||||||
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
||||||
"core-js": "^3.7.0"
|
"core-js": "^3.7.0"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user