@nx/react
Version:
40 lines (39 loc) • 1.91 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateModuleFederationTsconfig = updateModuleFederationTsconfig;
const devkit_1 = require("@nx/devkit");
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
function updateModuleFederationTsconfig(host, options) {
const tsconfigPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json');
const tsconfigRuntimePath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json');
if (!host.exists(tsconfigPath) || !host.exists(tsconfigRuntimePath))
return;
// Not setting `baseUrl` does not work with MF.
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
(0, devkit_1.updateJson)(host, 'tsconfig.base.json', (json) => {
json.compilerOptions.baseUrl = '.';
return json;
});
// Update references to match what `nx sync` does.
if (options.remotes?.length) {
(0, devkit_1.updateJson)(host, tsconfigPath, (json) => {
json.references ??= [];
for (const remote of options.remotes) {
const remotePath = `../${remote}`;
if (!json.references.some((ref) => ref.path === remotePath))
json.references.push({ path: remotePath });
}
return json;
});
(0, devkit_1.updateJson)(host, tsconfigRuntimePath, (json) => {
json.references ??= [];
for (const remote of options.remotes) {
const remotePath = `../${remote}/tsconfig.app.json`;
if (!json.references.some((ref) => ref.path === remotePath))
json.references.push({ path: remotePath });
}
return json;
});
}
}
}
;