Skip to content

Commit

Permalink
feat: support jsconfig.json (from vscode)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Nov 27, 2021
1 parent d91d62c commit dfb9975
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const getOptions = async (
jsxImportSource?: string,
target?: string,
}> => {
// This call is cached
const { data, path } = await joycon.load([tsconfig || 'tsconfig.json'], cwd);
// joycon has its builtin-cache support
const { data, path } = await joycon.load([tsconfig || 'tsconfig.json', 'jsconfig.json'], cwd);
if (path && data) {
const {
importHelpers,
Expand Down
49 changes: 49 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,55 @@ console.log(foo$1);
const output = await build({}, { input: './fixture/index.tsx', dir });
output[0].code.should.equal(`var foo = /*#__PURE__*/ h("div", null, "foo");
export { foo };
`);
});

it('use custom jsxFactory (h) from jsconfig.json', async () => {
const dir = realFs(getTestName(), {
'./fixture/index.tsx': `
export const foo = <div>foo</div>
`,
'./fixture/jsconfig.json': `
{
"compilerOptions": {
"jsxFactory": "h"
}
}
`
});

const output = await build({}, { input: './fixture/index.tsx', dir });
output[0].code.should.equal(`var foo = /*#__PURE__*/ h("div", null, "foo");
export { foo };
`);
});

it('use tsconfig.json when tsconfig.json & jsconfig.json both exists', async () => {
const dir = realFs(getTestName(), {
'./fixture/index.tsx': `
export const foo = <div>foo</div>
`,
'./fixture/jsconfig.json': `
{
"compilerOptions": {
"jsxFactory": "h"
}
}
`,
'./fixture/tsconfig.json': `
{
"compilerOptions": {
"jsxFactory": "m"
}
}
`
});

const output = await build({}, { input: './fixture/index.tsx', dir });
output[0].code.should.equal(`var foo = /*#__PURE__*/ m("div", null, "foo");
export { foo };
`);
});
Expand Down

0 comments on commit dfb9975

Please sign in to comment.