@nx/rspack
Version:
50 lines (49 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.editTsConfig = editTsConfig;
const devkit_1 = require("@nx/devkit");
const path_1 = require("path");
function editTsConfig(tree, projectRoot, framework, relativePathToRootTsConfig) {
// Nx 15.8 moved util to @nx/js, but it is in @nx/workspace in 15.7
let shared;
try {
shared = require('@nx/js/src/utils/typescript/create-ts-config');
}
catch {
shared = require('@nx/workspace/src/utils/create-ts-config');
}
if (framework === 'react') {
const json = {
compilerOptions: {
jsx: 'react-jsx',
allowJs: false,
esModuleInterop: false,
allowSyntheticDefaultImports: true,
strict: true,
},
files: [],
include: [],
references: [
{
path: './tsconfig.app.json',
},
],
};
// inline tsconfig.base.json into the project
if (projectIsRootProjectInStandaloneWorkspace(projectRoot)) {
json.compileOnSave = false;
json.compilerOptions = {
...shared.tsConfigBaseOptions,
...json.compilerOptions,
};
json.exclude = ['node_modules', 'tmp'];
}
else {
json.extends = relativePathToRootTsConfig;
}
(0, devkit_1.writeJson)(tree, `${projectRoot}/tsconfig.json`, json);
}
}
function projectIsRootProjectInStandaloneWorkspace(projectRoot) {
return (0, path_1.relative)(devkit_1.workspaceRoot, projectRoot).length === 0;
}