mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-13 12:40:18 -05:00
refactor: remove experimentalCompileTsWithBabel
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
module.exports = (api, {
|
||||
classComponent,
|
||||
tsLint,
|
||||
lintOn = [],
|
||||
experimentalCompileTsWithBabel
|
||||
lintOn = []
|
||||
}) => {
|
||||
if (typeof lintOn === 'string') {
|
||||
lintOn = lintOn.split(',')
|
||||
@@ -17,35 +16,6 @@ module.exports = (api, {
|
||||
})
|
||||
}
|
||||
|
||||
if (experimentalCompileTsWithBabel) {
|
||||
api.extendPackage({
|
||||
devDependencies: {
|
||||
'@babel/preset-typescript': '7 || ^7.0.0-beta || ^7.0.0-rc'
|
||||
},
|
||||
vue: {
|
||||
experimentalCompileTsWithBabel: true
|
||||
},
|
||||
babel: {
|
||||
presets: ['@babel/typescript', '@vue/app']
|
||||
}
|
||||
})
|
||||
|
||||
if (classComponent) {
|
||||
api.extendPackage({
|
||||
devDependencies: {
|
||||
'@babel/plugin-proposal-decorators': '7 || ^7.0.0-beta || ^7.0.0-rc',
|
||||
'@babel/plugin-proposal-class-properties': '7 || ^7.0.0-beta || ^7.0.0-rc'
|
||||
},
|
||||
babel: {
|
||||
plugins: [
|
||||
'@babel/proposal-decorators',
|
||||
['@babel/proposal-class-properties', { 'loose': true }]
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (tsLint) {
|
||||
api.extendPackage({
|
||||
scripts: {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module.exports = (api, {
|
||||
parallel,
|
||||
lintOnSave,
|
||||
experimentalCompileTsWithBabel
|
||||
lintOnSave
|
||||
}) => {
|
||||
const fs = require('fs')
|
||||
const useThreads = process.env.NODE_ENV === 'production' && parallel
|
||||
@@ -35,35 +34,26 @@ module.exports = (api, {
|
||||
})
|
||||
}
|
||||
|
||||
if (!experimentalCompileTsWithBabel) {
|
||||
if (api.hasPlugin('babel')) {
|
||||
addLoader({
|
||||
loader: 'babel-loader'
|
||||
})
|
||||
}
|
||||
addLoader({
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
appendTsSuffixTo: [/\.vue$/],
|
||||
// https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
|
||||
happyPackMode: useThreads
|
||||
}
|
||||
})
|
||||
// make sure to append TSX suffix
|
||||
tsxRule.use('ts-loader').loader('ts-loader').tap(options => {
|
||||
delete options.appendTsSuffixTo
|
||||
options.appendTsxSuffixTo = [/\.vue$/]
|
||||
return options
|
||||
})
|
||||
} else {
|
||||
// Experimental: compile TS with babel so that it can leverage
|
||||
// preset-env for auto-detected polyfills based on browserslists config.
|
||||
// this is pending on the readiness of @babel/preset-typescript.
|
||||
if (api.hasPlugin('babel')) {
|
||||
addLoader({
|
||||
loader: 'babel-loader'
|
||||
})
|
||||
}
|
||||
addLoader({
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
appendTsSuffixTo: [/\.vue$/],
|
||||
// https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
|
||||
happyPackMode: useThreads
|
||||
}
|
||||
})
|
||||
// make sure to append TSX suffix
|
||||
tsxRule.use('ts-loader').loader('ts-loader').tap(options => {
|
||||
delete options.appendTsSuffixTo
|
||||
options.appendTsxSuffixTo = [/\.vue$/]
|
||||
return options
|
||||
})
|
||||
|
||||
config
|
||||
.plugin('fork-ts-checker')
|
||||
|
||||
@@ -10,11 +10,7 @@ module.exports = [
|
||||
type: `confirm`,
|
||||
message: `Use class-style component syntax?`
|
||||
},
|
||||
process.env.VUE_CLI_EXPERIMENTAL ? {
|
||||
name: `experimentalCompileTsWithBabel`,
|
||||
type: `confirm`,
|
||||
message: `Compile TS with babel? ${chalk.yellow(`(experimental)`)}`
|
||||
} : {
|
||||
{
|
||||
name: `useTsWithBabel`,
|
||||
type: `confirm`,
|
||||
message: `Use Babel alongside TypeScript for auto-detected polyfills?`
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = cli => {
|
||||
|
||||
cli.onPromptComplete((answers, options) => {
|
||||
if (answers.features.includes('ts')) {
|
||||
if (!answers.useTsWithBabel && !answers.experimentalCompileTsWithBabel) {
|
||||
if (!answers.useTsWithBabel) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const chalk = require('chalk')
|
||||
|
||||
module.exports = cli => {
|
||||
cli.injectFeature({
|
||||
name: 'TypeScript',
|
||||
@@ -14,22 +12,13 @@ module.exports = cli => {
|
||||
message: 'Use class-style component syntax?'
|
||||
})
|
||||
|
||||
if (process.env.VUE_CLI_EXPERIMENTAL) {
|
||||
cli.injectPrompt({
|
||||
name: 'compileTsWithBabel',
|
||||
when: answers => answers.features.includes('ts'),
|
||||
type: 'confirm',
|
||||
message: `Compile TS with babel? ${chalk.yellow(`(experimental)`)}`
|
||||
})
|
||||
} else {
|
||||
cli.injectPrompt({
|
||||
name: 'useTsWithBabel',
|
||||
when: answers => answers.features.includes('ts'),
|
||||
type: 'confirm',
|
||||
message: 'Use Babel alongside TypeScript for auto-detected polyfills?',
|
||||
default: answers => answers.features.includes('babel')
|
||||
})
|
||||
}
|
||||
cli.injectPrompt({
|
||||
name: 'useTsWithBabel',
|
||||
when: answers => answers.features.includes('ts'),
|
||||
type: 'confirm',
|
||||
message: 'Use Babel alongside TypeScript for auto-detected polyfills?',
|
||||
default: answers => answers.features.includes('babel')
|
||||
})
|
||||
|
||||
cli.onPromptComplete((answers, options) => {
|
||||
if (answers.features.includes('ts')) {
|
||||
@@ -42,8 +31,6 @@ module.exports = cli => {
|
||||
}
|
||||
if (answers.useTsWithBabel) {
|
||||
tsOptions.useTsWithBabel = true
|
||||
} else if (answers.compileTsWithBabel) {
|
||||
tsOptions.experimentalCompileTsWithBabel = true
|
||||
}
|
||||
options.plugins['@vue/cli-plugin-typescript'] = tsOptions
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user