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": {
"target": "es5",
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": ["es2015", "dom"],
"lib": ["esnext", "esnext.asynciterable", "dom"],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,

View File

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

View File

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

View File

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

View File

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