Skip to content

Commit

Permalink
feat: support named imports for json modules (#4)
Browse files Browse the repository at this point in the history
* feat: support named imports for json modules

* chore: update lock
  • Loading branch information
privatenumber authored May 13, 2022
1 parent 3a505f7 commit 2aeb6ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 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.0.0"
"@esbuild-kit/esm-loader": "^1.1.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

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

14 changes: 6 additions & 8 deletions tests/specs/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import type { NodeApis } from '../utils/tsx';

export default testSuite(async ({ describe }, node: NodeApis) => {
describe('Load JSON', ({ describe }) => {
const output = '{"loaded":"json"}';

describe('full path', ({ test }) => {
const importPath = './lib/json/index.json';

Expand All @@ -16,13 +14,13 @@ export default testSuite(async ({ describe }, node: NodeApis) => {

test('Import', async () => {
const nodeProcess = await node.import(importPath);
expect(nodeProcess.stdout).toBe(`{"default":${output}}`);
expect(nodeProcess.stdout).toBe('{"default":{"loaded":"json"},"loaded":"json"}');
expect(nodeProcess.stderr).toBe('');
});

test('Require', async () => {
const nodeProcess = await node.require(importPath);
expect(nodeProcess.stdout).toBe(output);
expect(nodeProcess.stdout).toBe('{"loaded":"json"}');
expect(nodeProcess.stderr).toBe('');
});
});
Expand All @@ -38,13 +36,13 @@ export default testSuite(async ({ describe }, node: NodeApis) => {

test('Import', async () => {
const nodeProcess = await node.import(importPath);
expect(nodeProcess.stdout).toBe(`{"default":${output}}`);
expect(nodeProcess.stdout).toBe('{"default":{"loaded":"json"},"loaded":"json"}');
expect(nodeProcess.stderr).toBe('');
});

test('Require', async () => {
const nodeProcess = await node.require(importPath);
expect(nodeProcess.stdout).toBe(output);
expect(nodeProcess.stdout).toBe('{"loaded":"json"}');
expect(nodeProcess.stderr).toBe('');
});
});
Expand All @@ -60,13 +58,13 @@ export default testSuite(async ({ describe }, node: NodeApis) => {

test('Import', async () => {
const nodeProcess = await node.import(importPath);
expect(nodeProcess.stdout).toBe(`{"default":${output}}`);
expect(nodeProcess.stdout).toBe('{"default":{"loaded":"json"},"loaded":"json"}');
expect(nodeProcess.stderr).toBe('');
});

test('Require', async () => {
const nodeProcess = await node.require(importPath);
expect(nodeProcess.stdout).toBe(output);
expect(nodeProcess.stdout).toBe('{"loaded":"json"}');
expect(nodeProcess.stderr).toBe('');
});
});
Expand Down

0 comments on commit 2aeb6ca

Please sign in to comment.