Skip to content

Commit

Permalink
fix(js): return empty array if no helper dependencies found (#10582)
Browse files Browse the repository at this point in the history
* fix(js): return empty array if no helper dependencies found

* chore(js): add test for generate package json with helper dependency
  • Loading branch information
nartc committed Jun 4, 2022
1 parent 26177d1 commit 5daeaf8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion e2e/node/src/node.test.ts
Expand Up @@ -260,7 +260,7 @@ describe('Build Node apps', () => {
beforeEach(() => newProject());

it('should generate a package.json with the `--generatePackageJson` flag', async () => {
newProject();
const scope = newProject();
const nestapp = uniq('nestapp');
runCLI(`generate @nrwl/nest:app ${nestapp} --linter=eslint`);

Expand All @@ -284,6 +284,29 @@ describe('Build Node apps', () => {
version: '0.0.1',
})
);

const nodeapp = uniq('nodeapp');
runCLI(`generate @nrwl/node:app ${nodeapp}`);

const jslib = uniq('jslib');
runCLI(`generate @nrwl/js:lib ${jslib} --buildable`);

updateFile(
`apps/${nodeapp}/src/main.ts`,
`
import { ${jslib} } from '@${scope}/${jslib}';
console.log('Hello World!');
${jslib}();
`
);

await runCLIAsync(`build ${nodeapp} --generate-package-json`);
checkFilesExist(`dist/apps/${nestapp}/package.json`);
const nodeAppPackageJson = JSON.parse(
readFile(`dist/apps/${nodeapp}/package.json`)
);

expect(nodeAppPackageJson['dependencies']['tslib']).toBeTruthy();
}, 300000);

describe('NestJS', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/utils/compiler-helper-dependency.ts
Expand Up @@ -103,7 +103,7 @@ export function getHelperDependenciesFromProjectGraph(
!projectGraph.dependencies[sourceProject] ||
!projectGraph.dependencies[sourceProject].length
)
return;
return [];

const sourceDependencies = projectGraph.dependencies[sourceProject];
const internalDependencies = sourceDependencies.reduce(
Expand Down

0 comments on commit 5daeaf8

Please sign in to comment.