feat(nuxt-ts): typescript support improvements (#4750)

This commit is contained in:
Kevin Marrec 2019-01-12 21:21:21 +01:00 committed by Pooya Parsa
parent 8c915887f4
commit dfaffc0183
5 changed files with 19 additions and 16 deletions

View File

@ -1,9 +1,9 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "esnext",
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"lib": ["es2015", "dom"], "lib": ["esnext", "esnext.asynciterable", "dom"],
"esModuleInterop": true, "esModuleInterop": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"allowJs": true, "allowJs": true,

View File

@ -1,9 +1,9 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "esnext",
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"lib": ["es2015", "dom"], "lib": ["esnext", "esnext.asynciterable", "dom"],
"esModuleInterop": true, "esModuleInterop": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"allowJs": true, "allowJs": true,

View File

@ -9,7 +9,7 @@ import chalk from 'chalk'
import prettyBytes from 'pretty-bytes' import prettyBytes from 'pretty-bytes'
import env from 'std-env' import env from 'std-env'
export const requireModule = esm(module, { export const requireModule = process.env.NUXT_TS ? require : esm(module, {
cache: false, cache: false,
cjs: { cjs: {
cache: true, cache: true,

View File

@ -185,6 +185,10 @@ export default class WebpackBaseConfig {
this.nuxt, this.nuxt,
{ isServer: this.isServer, perfLoader } { isServer: this.isServer, perfLoader }
) )
const babelLoader = {
loader: require.resolve('babel-loader'),
options: this.getBabelOptions()
}
return [ return [
{ {
@ -224,23 +228,22 @@ export default class WebpackBaseConfig {
// item in transpile can be string or regex object // item in transpile can be string or regex object
return !this.modulesToTranspile.some(module => module.test(file)) return !this.modulesToTranspile.some(module => module.test(file))
}, },
use: perfLoader.js().concat({ use: perfLoader.js().concat(babelLoader)
loader: require.resolve('babel-loader'),
options: this.getBabelOptions()
})
}, },
{ {
test: /\.ts$/i, test: /\.ts$/i,
loader: 'ts-loader', use: [
options: this.loaders.ts babelLoader,
{
loader: 'ts-loader',
options: this.loaders.ts
}
]
}, },
{ {
test: /\.tsx$/i, test: /\.tsx$/i,
use: [ use: [
{ babelLoader,
loader: require.resolve('babel-loader'),
options: this.getBabelOptions()
},
{ {
loader: 'ts-loader', loader: 'ts-loader',
options: this.loaders.tsx options: this.loaders.tsx

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "esnext",
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"lib": ["esnext", "esnext.asynciterable", "dom"], "lib": ["esnext", "esnext.asynciterable", "dom"],