Skip to content

Commit

Permalink
feat(resolver): support tsx,jsx extensions (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Nov 9, 2023
1 parent 89cb240 commit 93955e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
30 changes: 16 additions & 14 deletions src/cjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,22 @@ const resolveTsFilename = (
&& isTsFilePatten.test(parent.filename)
&& tsPath
) {
try {
return defaultResolveFilename(
tsPath[0],
parent,
isMain,
options,
);
} catch (error) {
const { code } = error as NodeError;
if (
code !== 'MODULE_NOT_FOUND'
&& code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED'
) {
throw error;
for (const tryTsPath of tsPath) {
try {
return defaultResolveFilename(
tryTsPath,
parent,
isMain,
options,
);
} catch (error) {
const { code } = error as NodeError;
if (
code !== 'MODULE_NOT_FOUND'
&& code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED'
) {
throw error;
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/specs/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,19 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
// .ts
import './ts/index.ts';
import './ts/index.js';
// import './ts/index.jsx';
import './ts/index.jsx';
import './ts/index';
import './ts/';
// .jsx
import * as jsx from './jsx/index.jsx';
// import './jsx/index.js';
import './jsx/index.js';
import './jsx/index';
import './jsx/';
// .tsx
import './tsx/index.tsx';
// import './tsx/index.js';
import './tsx/index.js';
import './tsx/index.jsx';
import './tsx/index';
import './tsx/';
Expand Down

0 comments on commit 93955e6

Please sign in to comment.