Skip to content

Commit

Permalink
fix: deep merge user's module options (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Mar 19, 2023
1 parent 057e32b commit d95453e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/typescript-build/package.json
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"consola": "^2.15.3",
"defu": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^6.5.3",
"ts-loader": "^8.4.0"
},
Expand Down
11 changes: 4 additions & 7 deletions packages/typescript-build/src/index.ts
@@ -1,4 +1,5 @@
import path from 'path'
import { defu } from 'defu'
import consola from 'consola'
import { Module } from '@nuxt/types'
import { Options as TsLoaderOptions } from 'ts-loader'
Expand Down Expand Up @@ -27,11 +28,7 @@ const defaults: Options = {

const tsModule: Module<Options> = function (moduleOptions) {
// Combine options
const options = Object.assign(
defaults,
this.options.typescript,
moduleOptions
)
const options = defu(this.options.typescript, moduleOptions, defaults)

// Change color of CLI banner
this.options.cli.bannerColor = 'blue'
Expand Down Expand Up @@ -75,15 +72,15 @@ const tsModule: Module<Options> = function (moduleOptions) {
if (options.typeCheck && isClient && !isModern) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
config.plugins!.push(new ForkTsCheckerWebpackPlugin(Object.assign({
config.plugins!.push(new ForkTsCheckerWebpackPlugin(defu(options.typeCheck, {
typescript: {
configFile: path.resolve(this.options.rootDir!, 'tsconfig.json'),
extensions: {
vue: true
}
},
logger: consola.withScope('nuxt:typescript')
} as TsCheckerOptions, options.typeCheck)))
} as TsCheckerOptions)))
}
})
}
Expand Down

0 comments on commit d95453e

Please sign in to comment.