swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.78k stars 75 forks source link

avoid tsconfig.json (parseJsonConfigFileContent) and use .swcrc #690

Closed aaaristo closed 1 year ago

aaaristo commented 1 year ago

parseJsonConfigFileContent is quite slow on large projects, would it be possible to skip it and use .swcrc instead?

when removing the tsconfig.json node starts way faster, the problem is I cannot add jsx support. And it seems SWCRC=true has no effect.

aaaristo commented 1 year ago

This solves it in my case:

create ./swc-register.js

const ts = require('typescript');

require('@swc-node/register/register').register({
    target: ts.ScriptTarget.ES2018,
    module: ts.ModuleKind.CommonJS,
    moduleResolution: ts.ModuleResolutionKind.NodeJs,
    jsx: 'react',
    sourceMap: true,
    esModuleInterop: true,
});

node -r ./swc-register.js my-script.js

aaaristo commented 1 year ago

It seems a bit counterintuitive to configure swc-node with tsconfig and not swcrc.