Skip to content

Commit

Permalink
fix(swc): SWC does not support custom sourceRoot and custom output
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Jun 27, 2023
1 parent 90387b2 commit fde03fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/compiler/defaults/swc-defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as ts from 'typescript';
import { Configuration } from '../../configuration';

export const swcDefaultsFactory = (tsOptions: ts.CompilerOptions) => {
export const swcDefaultsFactory = (
configuration: Configuration,
tsOptions: ts.CompilerOptions,
) => {
return {
swcOptions: {
module: {
Expand All @@ -25,8 +29,8 @@ export const swcDefaultsFactory = (tsOptions: ts.CompilerOptions) => {
swcrc: true,
},
cliOptions: {
outDir: 'dist',
filenames: ['src'],
outDir: tsOptions.outDir ?? 'dist',
filenames: [configuration.sourceRoot ?? 'src'],
sync: false,
extensions: ['.js', '.ts'],
watch: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/swc/swc-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class SwcCompiler extends BaseCompiler {
extras: SwcCompilerExtras,
onSuccess?: () => void,
) {
const swcOptions = swcDefaultsFactory(extras.tsOptions);
const swcOptions = swcDefaultsFactory(configuration, extras.tsOptions);
if (extras.watch) {
if (extras.typeCheck) {
this.runTypeChecker(configuration, tsConfigPath, appName, extras);
Expand Down

0 comments on commit fde03fa

Please sign in to comment.