Skip to content

feat: Nx 12.4 support with Angular 12 and builder improvements #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 25, 2021

Conversation

NathanWalker
Copy link
Contributor

@NathanWalker NathanWalker commented Jun 25, 2021

closes #25
closes #23
closes #21

@NathanWalker NathanWalker merged commit 5952dfe into main Jun 25, 2021
@NathanWalker NathanWalker deleted the feat/nx-12-4-angular-12 branch June 25, 2021 04:14
"license": "SEE LICENSE IN <your-license-filename>",
"version": "0.0.0",
"scripts": {
"postinstall": "node ./tools/postinstall.js && npm run ngcc",
"ngcc": "ngcc --tsconfig tsconfig.app.json --properties es2015 module main --first-only"
"ngcc": "<%= pathOffset %>node_modules/.bin/ngcc --tsconfig tsconfig.app.json --properties es2015 module main --first-only"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NathanWalker Many thanks for this update, works like a charm. Please be aware that the generated ../../node_modules/.bin/ngcc --tsconfig tsconfig.app.json --properties es2015 module main --first-only will only work on unix machines. We have some windows developers in our team, they reported that this leads to an "Command '..' not found" error.

In our case this is not a problem since we're calling ngcc after install in the root package.json (which is in there by default, right?), so we deleted this call.

Before I open an issue (for the windows users):
What's the reason you put this line here? Is it a "just to be sure" matter or is there any reason behind that I am missing?

Copy link
Contributor Author

@NathanWalker NathanWalker Jun 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this up, I'm curious if you have a suggestion that would work well for windows here?
Essentially when running builds in CI in particular the postinstall does not pick up ngcc when referenced just like:

"ngcc": "ngcc --tsconfig tsconfig.app.json --properties es2015 module main --first-only"

Because ngcc is actually installed in root node_modules so the relative path ensures that it executes properly in those environments, however if Windows has an issue with that we need a way to execute ngcc properly. We had found during testing in some cases (did not seem 100%) however when ngcc did not process properly after a full clean then the first run would be subject to a runtime ivy related type of error (2nd run would be fine). So executing that after a clean seemed to always help so it is indeed a rather "just to be sure" matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably include that handling in the tools/postinstall.js itself and use something like this which would probably help both environments:

const child = childProcess.spawn(/^win/.test(process.platform) ? '..\\..\\node_modules\\.bin\\ngcc' : '../../node_modules/.bin/ngcc', ['--tsconfig', 'tsconfig.app.json', '--properties', 'es2015', 'module', 'main', '--first-only'], {
  cwd: process.cwd(),
  stdio: 'inherit',
});
child.on('close', (code) => {

});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, moving to postinstall.js sounds good. Shall I create another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have it here already, I'll publish another patch shortly with it ❤️ thanks again for mentioning!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Blazing fast, many thanks!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Released in 2.0.2 now - changeset is here:
32284d7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants