Skip to content

Commit

Permalink
fix(typescript): fallback to checking cjs/mjs on missing cts/mts
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed May 16, 2022
1 parent 2aeb6ca commit a047682
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@esbuild-kit/cjs-loader": "^1.0.0",
"@esbuild-kit/esm-loader": "^1.1.0"
"@esbuild-kit/esm-loader": "^1.1.1"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/specs/javascript/cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
expect(nodeProcess.stderr).toBe('');
});

test('TypeScript Import', async () => {
const nodeProcess = await node.import(importPath, { typescript: true });
expect(nodeProcess.stdout).toBe(`${output}\n{"default":1234}`);
});

test('Require', async () => {
const nodeProcess = await node.require(importPath);
expect(nodeProcess.stdout).toBe(`${output}\n1234`);
Expand Down
6 changes: 6 additions & 0 deletions tests/specs/javascript/esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
expect(nodeProcess.stderr).toBe('');
});

test('TypeScript Import', async () => {
const nodeProcess = await node.import(importPath, { typescript: true });
expect(nodeProcess.stdout).toBe(`${output}\n{"default":1234}`);
expect(nodeProcess.stderr).toBe('');
});

test('Require', async () => {
const nodeProcess = await node.require(importPath);
expect(nodeProcess.stdout).toBe(`${output}\n{"default":1234}`);
Expand Down

0 comments on commit a047682

Please sign in to comment.