@@ -61,70 +61,8 @@ const tsModule: Module<Options> = function (moduleOptions) {
6161 const babelLoader = jsxRuleLoaders [ jsxRuleLoaders . length - 1 ]
6262
6363 config . module ! . rules . push ( ...( [ 'ts' , 'tsx' ] as const ) . map ( ext => ( {
64- test : new RegExp ( `\.${ ext } import path from 'path '
65- import { defu } from 'defu '
66- import consola from 'consola'
67- import type { Module } from '@nuxt/types'
68- import type { Options as TsLoaderOptions } from 'ts-loader'
69- import type { ForkTsCheckerWebpackPluginOptions as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions'
70- import type TsCheckerLogger from 'fork-ts-checker-webpack-plugin/lib/logger/Logger'
71- import type { RuleSetUseItem } from 'webpack'
72- import { NormalModuleReplacementPlugin } from 'webpack'
73-
74- export interface Options {
75- ignoreNotFoundWarnings ?: boolean
76- loaders ?: {
77- ts ?: Partial < TsLoaderOptions >
78- tsx ?: Partial < TsLoaderOptions >
79- }
80- typeCheck ?: TsCheckerOptions | boolean
81- }
82-
83- declare module '@nuxt/types' {
84- interface NuxtOptions {
85- typescript : Options
86- }
87- }
88-
89- const defaults : Options = {
90- ignoreNotFoundWarnings : false ,
91- typeCheck : true
92- }
93-
94- const tsModule : Module < Options > = function ( moduleOptions ) {
95- // Combine options
96- const options = defu ( this . options . typescript , moduleOptions , defaults )
97-
98- // Change color of CLI banner
99- this . options . cli . bannerColor = 'blue'
100-
101- if ( ! this . options . extensions . includes ( 'ts' ) ) {
102- this . options . extensions . push ( 'ts' )
103- }
104-
105- // Extend Builder to handle .ts/.tsx files as routes and watch them
106- this . options . build . additionalExtensions = [ 'ts' , 'tsx' ]
107-
108- if ( options . ignoreNotFoundWarnings ) {
109- this . options . build . warningIgnoreFilters ! . push ( warn =>
110- warn . name === 'ModuleDependencyWarning' && / e x p o r t .* w a s n o t f o u n d i n / . test ( warn . message )
111- )
112- }
113-
114- this . extendBuild ( ( config , { isClient, isModern } ) => {
115- config . resolve ! . extensions ! . push ( '.ts' , '.tsx' )
116-
117- // Add alias for @babel /runtime/helpers
118- config . resolve ! . alias = {
119- ...config . resolve ! . alias ,
120- '@babel/runtime/helpers' : path . resolve ( this . options . rootDir ! , 'node_modules/@babel/runtime/helpers' )
121- }
122-
123- const jsxRuleLoaders = config . module ! . rules . find ( r => ( r . test as RegExp ) . test ( '.jsx' ) ) ! . use as RuleSetUseItem [ ]
124- const babelLoader = jsxRuleLoaders [ jsxRuleLoaders . length - 1 ]
125-
126- ) ,
127- ) , use : [
64+ test : new RegExp ( `\.${ ext } $` ) ,
65+ use : [
12866 babelLoader ,
12967 {
13068 loader : 'ts-loader' ,
@@ -135,8 +73,8 @@ const tsModule: Module<Options> = function (moduleOptions) {
13573 }
13674 }
13775 ]
138- } )
139- ) )
76+ } ) )
77+ )
14078 // Fix paths not resolving in async imports
14179 // https://github.com/nuxt/typescript/issues/520
14280 if ( this . nuxt . options . alias ) {
@@ -150,4 +88,4 @@ const tsModule: Module<Options> = function (moduleOptions) {
15088 }
15189 }
15290 ) )
153- }
91+ }
0 commit comments