Skip to content

Commit

Permalink
fix(js): patch migration from @nrwl/node:package to @nrwl/js:tsc to r…
Browse files Browse the repository at this point in the history
…ename srcRootForCompilationRoot option to rootDir (#12999)
  • Loading branch information
jaysoo committed Nov 4, 2022
1 parent 5a137d0 commit 9cbf9bf
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
Expand Up @@ -67,4 +67,52 @@ describe('Migration: rename package to tsc', () => {

expect(tasks).toBeUndefined();
});

it('should migrate srcRootForCompilationRoot option to rootDir', async () => {
let tree = createTreeWithEmptyV1Workspace();

tree.write(
'workspace.json',
JSON.stringify({
version: 2,
projects: {
mylib: {
root: 'libs/mylib',
sourceRoot: 'libs/mylib/src',
projectType: 'library',
targets: {
build: {
executor: '@nrwl/node:package',
options: {
srcRootForCompilationRoot: '.',
},
},
},
},
},
})
);

const tasks = await update(tree);

expect(tasks).toBeDefined();
expect(readJson(tree, 'workspace.json')).toEqual({
version: 2,
projects: {
mylib: {
root: 'libs/mylib',
sourceRoot: 'libs/mylib/src',
projectType: 'library',
targets: {
build: {
executor: '@nrwl/js:tsc',
options: {
rootDir: '.',
},
},
},
},
},
});
});
});
Expand Up @@ -29,6 +29,18 @@ export default async function update(host: Tree) {
transformers;
}

if (
projectConfiguration.targets[targetName].options
?.srcRootForCompilationRoot
) {
projectConfiguration.targets[targetName].options.rootDir =
projectConfiguration.targets[
targetName
].options.srcRootForCompilationRoot;
delete projectConfiguration.targets[targetName].options
.srcRootForCompilationRoot;
}

updateProjectConfiguration(host, projectName, projectConfiguration);
}
);
Expand Down

0 comments on commit 9cbf9bf

Please sign in to comment.