Skip to content
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

Opt out of ngcc in postinstall-script #10062

Closed
stianmorsund opened this issue Apr 29, 2022 · 10 comments · Fixed by #10208
Closed

Opt out of ngcc in postinstall-script #10062

stianmorsund opened this issue Apr 29, 2022 · 10 comments · Fixed by #10208
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@stianmorsund
Copy link
Contributor

stianmorsund commented Apr 29, 2022

Current Behavior

Angulars lib and app-generator are appending ngcc on postinstall-script in package.json. Our organization does not need this post-compilation script, since all our dependencies are Ivy-compatible.

Expected Behavior

Discard behavior or add ability to opt out via configuration

Steps to Reproduce

  1. Call one of these generators. (We are using them as part of our workspace-generators)
    import { applicationGenerator } from '@nrwl/angular/generators';
    import { libraryGenerator } from '@nrwl/angular/generators';

  2. Observe that ngcc is appended to postinstall-script in package.json

Failure Logs

Environment

   OS   : darwin x64
   yarn : 1.22.18

   nx : 13.10.2
   @nrwl/angular : 13.8.3
   @nrwl/cli : 13.8.3
   @nrwl/cypress : 13.8.3
   @nrwl/detox : undefined
   @nrwl/devkit : 13.10.2
   @nrwl/eslint-plugin-nx : 13.8.3
   @nrwl/express : undefined
   @nrwl/jest : 13.8.3
   @nrwl/js : undefined
   @nrwl/linter : 13.8.3
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : 13.8.3
   @nrwl/nx-cloud : 13.1.5
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.3
   @nrwl/tao : 13.8.3
   @nrwl/web : undefined
   @nrwl/workspace : 13.8.3
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
   	 @angular/animations: 13.2.4
   	 @angular/cdk: 13.3.2
   	 @angular/common: 13.2.4
   	 @angular/compiler: 13.2.4
   	 @angular/core: 13.2.4
   	 @angular/forms: 13.2.4
   	 @angular/localize: 13.2.4
   	 @angular/material: 13.3.2
   	 @angular/platform-browser: 13.2.4
   	 @angular/platform-browser-dynamic: 13.2.4
   	 @angular/router: 13.2.4
   	 @ngrx/component: 13.1.0
   	 @ngrx/effects: 13.0.2
   	 @ngrx/entity: 13.0.2
   	 @ngrx/router-store: 13.0.2
   	 @ngrx/store: 13.0.2
   	 @ngrx/store-devtools: 13.0.2
   	 @angular-devkit/build-angular: 13.2.5
   	 @angular/cli: 13.2.5
   	 @angular/compiler-cli: 13.2.4
   	 @angular/language-service: 13.2.4
   	 @ngrx/schematics: 13.0.2
   	 @scullyio/init: 2.1.29
   	 @storybook/angular: 6.4.22
   	 eslint-plugin-ngrx: 2.1.2
   	 ng-mocks: 13.4.2
@AgentEnder AgentEnder added the scope: angular Issues related to Angular support in Nx label Apr 29, 2022
@AgentEnder
Copy link
Member

It would be good to add a --no-postinstall flag for the generators, @stianmorsund since you have some workspace generators you may be comfortable with adding it. Would you like to contribute this feature?

@stianmorsund
Copy link
Contributor Author

stianmorsund commented May 2, 2022

Sure, I can contribute! I dug a little bit deeper, and it looks like the applicationGenerator has a skipPackageJson-flag. When this is set it, it doesnt add the ngcc-script, which is what we want. However, in the libraryGenerator this flag is not possible to set directly. Could it be a solution to reconsider how this works for libraries instead of adding an additional no-postinstall-flag?

@AgentEnder
Copy link
Member

Sure, if there is already a skipPackageJson flag for the app generator, the new flag should match.

@leosvelperez
Copy link
Member

@stianmorsund, the skipPackageJson flag is available in both generators (app and lib) and it works the same for both of them. Please note that the flag is meant to skip adding dependencies to the package.json, and it's not intended to prevent other modifications.

Would you like to contribute by adding a skipPostinstall flag to both generators? Otherwise, let me know and I can add it later.

@AgentEnder
Copy link
Member

Thanks @leosvelperez, definitely more context on your end.

@stianmorsund
Copy link
Contributor Author

stianmorsund commented May 5, 2022

@stianmorsund, the skipPackageJson flag is available in both generators (app and lib) and it works the same for both of them. Please note that the flag is meant to skip adding dependencies to the package.json, and it's not intended to prevent other modifications.

Would you like to contribute by adding a skipPostinstall flag to both generators? Otherwise, let me know and I can add it later.

Hmm, I was looking at the definition at this location, which seems to miss the skipPackageJson-property:

https://github.com/nrwl/nx/blob/master/packages/angular/src/generators/library/schema.d.ts
That is the interface used when calling libraryGenerator.

Is this intended? :)

@leosvelperez
Copy link
Member

@stianmorsund it's not intended; it's a typing issue. The actual schema (schema.json) does have that property, but it's not reflected in the types for the generator options.

If you're up for adding the --skip-postinstall flag, you can also add the missing skipPackageJson to the schema.d.ts file in that same PR. Otherwise, let me know and I'll address this soon.

@stianmorsund
Copy link
Contributor Author

@stianmorsund it's not intended; it's a typing issue. The actual schema (schema.json) does have that property, but it's not reflected in the types for the generator options.

If you're up for adding the --skip-postinstall flag, you can also add the missing skipPackageJson to the schema.d.ts file in that same PR. Otherwise, let me know and I'll address this soon.

Allright, I'll see what I can do :)

@stianmorsund
Copy link
Contributor Author

stianmorsund commented May 6, 2022

I made a PR for the missing skipPackageJson-typing (#10179). I'll look into skipping postinstall later :)

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants