Skip to content

Commit

Permalink
fix(js): remove hardcoded source-maps and add default value to source…
Browse files Browse the repository at this point in the history
…Maps in swcrc

ISSUES CLOSED: #9187
  • Loading branch information
Chau Tran authored and Chau Tran committed Mar 4, 2022
1 parent e54e36e commit 7c1b995
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions packages/js/src/utils/swc/add-swc-config.ts
Expand Up @@ -3,6 +3,14 @@
import { Tree } from '@nrwl/devkit';
import { join } from 'path';

export const defaultExclude = [
'./src/**/.*.spec.ts$',
'./**/.*.spec.ts$',
'./src/**/jest-setup.ts$',
'./**/jest-setup.ts$',
'./**/.*.js$',
];

const swcOptionsString = () => `{
"jsc": {
"target": "es2017",
Expand All @@ -23,13 +31,14 @@ const swcOptionsString = () => `{
"type": "commonjs",
"strict": true,
"noInterop": true
}
},
"sourceMaps": true,
"exclude": ${defaultExclude}
}`;

export function addSwcConfig(tree: Tree, projectDir: string) {
const swcrcPath = join(projectDir, '.swcrc');
const isSwcConfigExist = tree.exists(swcrcPath);
if (isSwcConfigExist) return;
const swcrcPath = join(projectDir, '.lib.swcrc');
if (tree.exists(swcrcPath)) return;

tree.write(swcrcPath, swcOptionsString());
}
2 changes: 1 addition & 1 deletion packages/js/src/utils/swc/compile-swc.ts
Expand Up @@ -10,7 +10,7 @@ function getSwcCmd(
{ swcrcPath, srcPath, destPath }: SwcCliOptions,
watch = false
) {
let swcCmd = `npx swc ${srcPath} -d ${destPath} --source-maps --no-swcrc --config-file=${swcrcPath}`;
let swcCmd = `npx swc ${srcPath} -d ${destPath} --no-swcrc --config-file=${swcrcPath}`;
return watch ? swcCmd.concat(' --watch') : swcCmd;
}

Expand Down

0 comments on commit 7c1b995

Please sign in to comment.