Skip to content

Commit d6059b7

Browse files
committed
feat: improve extension handling
1 parent ebde9d9 commit d6059b7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,34 @@ function swcModule () {
1717
const swcTSOptions = defu(swcOptions, {
1818
jsc: {
1919
parser: {
20-
syntax: 'typescript',
21-
dynamicImport: true
20+
syntax: 'typescript'
2221
}
2322
}
2423
})
2524

25+
nuxt.options.extensions.push('ts')
26+
nuxt.options.build.additionalExtensions = ['ts', 'tsx']
27+
2628
nuxt.hook('webpack:config', (configs) => {
2729
for (const config of configs) {
30+
config.resolve!.extensions!.push('.ts', '.tsx')
2831
config.module.rules = [
32+
...config.module.rules.filter(r => '.vue'.match(r.test)),
2933
{
30-
test: /\.m?[jt]sx?$/i,
34+
test: /\.m?jsx?$/i,
3135
use: {
3236
loader: require.resolve('swc-loader'),
3337
options: swcOptions
3438
}
3539
},
3640
{
37-
test: /\.m?[jt]sx?$/i,
41+
test: /\.tsx?$/i,
3842
use: {
3943
loader: require.resolve('swc-loader'),
4044
options: swcTSOptions
4145
}
4246
},
43-
...config.module.rules.filter(r => !'.js'.match(r.test))
47+
...config.module.rules.filter(r => !('.js'.match(r.test) || '.vue'.match(r.test)))
4448
]
4549
}
4650
})

0 commit comments

Comments
 (0)