feat: allow passing TS config loader options#15234
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
| swc: extraTSLoaderOptions?.swc, | ||
| transpileOnly: extraTSLoaderOptions?.transpileOnly, |
There was a problem hiding this comment.
Instead of setting these two, can we just spread the config passed?
i.e.
tsLoader.register({
compilerOptions: {
module: 'CommonJS',
},
moduleTypes: {
'**': 'cjs',
},
...extraTSLoaderOptions,
});There was a problem hiding this comment.
I thought the same but not sure if it's a good idea to expose all options or not, done 4223489
There was a problem hiding this comment.
if people misconfigure, that's on them. I think exposing the API is better than having to expose more in the future
| const docblockTSLoaderOptions = docblockPragmas['jest-config-loader-options']; | ||
|
|
||
| if (typeof docblockTSLoaderOptions === 'string') { | ||
| extraTSLoaderOptions = JSON.parse(docblockTSLoaderOptions); |
There was a problem hiding this comment.
these should be passed to esbuild-register as well
SimenB
left a comment
There was a problem hiding this comment.
thanks! I like this approach 👍
| ): Promise<Config.InitialOptions> => { | ||
| // Get registered TypeScript compiler instance | ||
| const docblockPragmas = parse(extract(fs.readFileSync(configPath, 'utf8'))); | ||
| const tsLoader = docblockPragmas['jest-config-loader'] || 'ts-node'; |
There was a problem hiding this comment.
should we also change this default behavior of using ts-node if no loader is passed in a separate PR? it will be a breaking change though
There was a problem hiding this comment.
that's a separate thing, yeah. happy to take a PR
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Follow up #15190
this will allow us to pass config loader options in a docblock comment.
Currently, valid options are
swcandtranspileOnly, these options are useful if someone is usingts-nodefor loading ts config files.Test plan
Added e2e test