Skip to content

Commit 88e6665

Browse files
ecmarshEthan Marsh
andauthored
feat: recognize mts files (#128)
Resolve `.mts` files as TypeScript files. Co-authored-by: Ethan Marsh <ethan@ethans-mbp.lan>
1 parent f06ba6b commit 88e6665

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type SWCOptions = WithRequiredProperty<JscConfig, 'parser' | 'transform'>
2424
export default createUnplugin<Options | undefined, false>(
2525
({ tsconfigFile, minify, include, exclude, ...options } = {}) => {
2626
const filter = createFilter(
27-
include || /\.[jt]sx?$/,
27+
include || /\.m?[jt]sx?$/,
2828
exclude || /node_modules/,
2929
)
3030

@@ -44,7 +44,7 @@ export default createUnplugin<Options | undefined, false>(
4444
tsconfigFile === true ? undefined : tsconfigFile,
4545
)?.data?.compilerOptions || {}
4646

47-
const isTs = /\.tsx?$/.test(id)
47+
const isTs = /\.m?tsx?$/.test(id)
4848

4949
let jsc: SWCOptions = {
5050
parser: {

src/resolve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs'
22
import path from 'path'
33
import { pathExists } from 'path-exists'
44

5-
const RESOLVE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs']
5+
const RESOLVE_EXTENSIONS = ['.tsx', '.ts', '.mts', '.jsx', '.js', '.mjs', '.cjs']
66

77
const resolveFile = async(resolved: string, index = false) => {
88
for (const ext of RESOLVE_EXTENSIONS) {

0 commit comments

Comments
 (0)