mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(nuxt-ts): typescript support improvements (#4750)
This commit is contained in:
parent
8c915887f4
commit
dfaffc0183
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
use: [
|
||||||
|
babelLoader,
|
||||||
|
{
|
||||||
loader: 'ts-loader',
|
loader: 'ts-loader',
|
||||||
options: this.loaders.ts
|
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
|
||||||
|
2
test/fixtures/typescript/tsconfig.json
vendored
2
test/fixtures/typescript/tsconfig.json
vendored
@ -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"],
|
||||||
|
Loading…
Reference in New Issue
Block a user