Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow using .swcrc when no option defined #165

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
...computedSwcOptions,
module: {
...computedSwcOptions.module,
type: (jestOptions.supportsStaticESM ? 'es6' : 'commonjs' as any)

Check warning on line 37 in index.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected any. Specify a different type
},
filename
})
Expand All @@ -47,7 +47,7 @@
module: {
...computedSwcOptions.module,
// async transform is always ESM
type: ('es6' as any)

Check warning on line 50 in index.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected any. Specify a different type
},
filename
})
Expand Down Expand Up @@ -105,7 +105,10 @@

function buildSwcTransformOpts(swcOptions: (Options & { experimental?: unknown }) | undefined): Options {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { experimental, ...computedSwcOptions } = swcOptions || (getOptionsFromSwrc() as Options & { experimental?: unknown })
const { experimental, ...computedSwcOptions } =
swcOptions && Object.keys(swcOptions).length > 0
? swcOptions
: getOptionsFromSwrc() as Options & { experimental?: unknown }

if (!computedSwcOptions.env && !computedSwcOptions.jsc?.target) {
set(
Expand All @@ -129,7 +132,7 @@
return computedSwcOptions
}

function insertInstrumentationOptions(jestOptions: TransformOptions<unknown>, canInstrument: boolean, swcTransformOpts: Options, instrumentOptions?: any) {

Check warning on line 135 in index.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected any. Specify a different type
const shouldInstrument = jestOptions.instrument && canInstrument

if (!shouldInstrument) {
Expand All @@ -155,7 +158,7 @@
swcTransformOpts.jsc.experimental.plugins?.push(['swc-plugin-coverage-instrument', instrumentOptions ?? {}])
}

function set(obj: any, path: string, value: any) {

Check warning on line 161 in index.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 161 in index.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected any. Specify a different type
let o = obj
const parents = path.split('.')
const key = parents.pop() as string
Expand Down
Loading