Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit 21559e1

Browse files
authored
feat: better .mts support. (#25)
Co-authored-by: loynoir <[email protected]>
1 parent a4c01cb commit 21559e1

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

loader.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import JoyCon from 'joycon'
77

88
const isWindows = process.platform === 'win32'
99

10-
const extensionsRegex = /\.(m?tsx?|json)$/
10+
const extensionsRegex = /\.m?(tsx?|json)$/
1111
const tsconfigPath = new JoyCon({ parseJSON: () => {} }).loadSync(['tsconfig.json']).path
1212
const pluginTypescript = typescript({
1313
tsconfig: tsconfigPath,

test/entry.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ test('register cjs', async() => {
5353
assert(stdout === 'fs imported')
5454
})
5555

56+
test('register mts', async() => {
57+
const { stdout } = await execa('node', [
58+
'--experimental-loader',
59+
relativize(`${cwd}/loader.mjs`),
60+
relativize(`${cwd}/test/fixture.mts.mts`),
61+
])
62+
assert(stdout === 'hello from mts')
63+
})
64+
5665
test('package type module', async() => {
5766
const { stdout } = await execa('node', [
5867
'--experimental-loader',

test/fixture.mts.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('hello from mts')

0 commit comments

Comments
 (0)