Skip to content

Commit

Permalink
feat: recognize mts files (#128)
Browse files Browse the repository at this point in the history
Resolve `.mts` files as TypeScript files.

Co-authored-by: Ethan Marsh <[email protected]>
  • Loading branch information
ecmarsh and Ethan Marsh authored Jul 1, 2024
1 parent f06ba6b commit 88e6665
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type SWCOptions = WithRequiredProperty<JscConfig, 'parser' | 'transform'>
export default createUnplugin<Options | undefined, false>(
({ tsconfigFile, minify, include, exclude, ...options } = {}) => {
const filter = createFilter(
include || /\.[jt]sx?$/,
include || /\.m?[jt]sx?$/,
exclude || /node_modules/,
)

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

const isTs = /\.tsx?$/.test(id)
const isTs = /\.m?tsx?$/.test(id)

let jsc: SWCOptions = {
parser: {
Expand Down
2 changes: 1 addition & 1 deletion src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs'
import path from 'path'
import { pathExists } from 'path-exists'

const RESOLVE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs']
const RESOLVE_EXTENSIONS = ['.tsx', '.ts', '.mts', '.jsx', '.js', '.mjs', '.cjs']

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

0 comments on commit 88e6665

Please sign in to comment.