nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.51k stars 2.34k forks source link

nx library generates index.d.ts but not shared-module.d.ts #11195

Closed nhhockeyplayer closed 1 year ago

nhhockeyplayer commented 2 years ago

SUBJECT: nx library generates index.d.ts but not shared-module.d.ts

Current Behavior

Hi Team thanks for an elite magnificent product.

I have a repo (ask to collab if you want in) https://github.com/nhhockeyplayer/meanstacknh

and I designed a shell library exported from my barrel as follows (all are buildable & publishable) export * from './lib/admin-root-feature-shell.module';

after complete build I peek in the DIST folder and I seeindex.d.ts BUT I do not see (what I would expect to see) a library typedefs file named admin-root-feature-shell.module.d.ts

Expected Behavior

This typedefs file SHOULD be generated as part of the @nrwl/nx:library eFrastructure

admin-root-feature-shell.module.d.ts

Steps to Reproduce

just build my repo

nx build admin-root-feature-shell --prod

Failure Logs

none just missing typedefs file admin-root-feature-shell.module.d.ts

I have build and published angular libraries in the commercial field prior successfully so I have ng-packagr experience so thats been a moving target.

What Im seeing is when I to npm publish from nx root dir (this could be documented more with an example) Im seeing the entire monorepo being packed into my meanstacknh-0.0.0-npm.tgz and the contents is just the source code from my monorepo so something is up with the packaging and publishing Im not seeing what should be

Im happy to pass on token secrets if you want to try that its just three nx, github, npm

much of the documentation and issues surrounding lib package/publish is lackadaisical and rarely states whether one should be operating their $home/.npmrc or $project-root/.npmrc (if your able to get that far due to the npmjs.org consistency functionality transition to github) or both .npmrc auto-login files together from one or the other or both resident directories.

so I wonder how much of this is still in play at angular team

clarification about which directory your suppose to be in when executing the NPM pack, (or link for dev) and publish commands would help its sketchy scenarios for prod/dev are elusive and ideally we want to be able to publish the entire shabang in one command from the rootDir elegantly

thanks in advance for your assist

Environment

nx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.15.1
   OS   : darwin x64
   yarn : 1.22.18

   nx : 14.4.3
   @nrwl/angular : 14.4.3
   @nrwl/cypress : 14.4.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.4.3
   @nrwl/eslint-plugin-nx : 14.4.3
   @nrwl/express : 14.4.3
   @nrwl/jest : 14.4.3
   @nrwl/js : 14.4.3
   @nrwl/linter : 14.4.3
   @nrwl/nest : 14.4.3
   @nrwl/next : Not Found
   @nrwl/node : 14.4.3
   @nrwl/nx-cloud : 14.2.0
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : 8.12.11
   @nrwl/storybook : 14.4.3
   @nrwl/web : 14.4.3
   @nrwl/workspace : 14.4.3
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
     @fortawesome/angular-fontawesome: 0.11.1
     @ionic/angular: 6.1.14
     @ngrx/component: 14.0.2
     @ngrx/component-store: 14.0.2
     @ngrx/effects: 14.0.2
     @ngrx/entity: 14.0.2
     @ngrx/router-store: 14.0.2
     @ngrx/store: 14.0.2
     @nxtend/capacitor: 13.0.0
     @nxtend/ionic-angular: 13.1.0
     @storybook/angular: 6.5.9
     angular-builder-custom-terser-options: 1.0.1
     @compodoc/compodoc: 1.1.19
     @ngrx/schematics: 14.0.2
     @ngrx/store-devtools: 14.0.2
     ngx-build-plus: 14.0.0
nhhockeyplayer commented 2 years ago

some feedback or clarification on this would be helpful

I have done individual libs before with angular and ng-packagr and cd to dist folder to pack and publish and it lands nicely at host registry

for my Nx monorepo though I have dozen plus buildable publishable libs

and Im unsure how to follow thru with the publishing at this time because whats landing in the github registry for my package is just typescript code for each lib in the monorepo... no individual standard ng-packagr packaged libs as one would expect for each lib

Is this still a work in progress? If so we are ready to use it the Nx team has done phenomenal job so far and Im picking this stuff up on the fly running with it in prep for my next gig with each Nx migration to latest. Be nice to know if its just incomplete waiting to be released.

Im seeing my dist folders libs are composed and built properly with ng-packagr-lite but when I do npm publish from root dir the anatomy of whats in my dist folder for each lib is not reflected in the actual lib published to the registry

Some of my libs were created not too long ago and the executor for each project was "executor": "@nrwl/angular:package", and I just changed thenm all to "executor": "@nrwl/angular:ng-packagr-lite", in hopes for better result but none yet

im still seeing the monorepo typescript copied out to the registry for each lib

thanks for any feedback

nhhockeyplayer commented 2 years ago

Okay this was actually fixed by changing my executor to ng-packagr-lite, my dist folder looks legit now for all my libraries and their respective typedefs... less license files and readme's

QUES: ALL My libs were created using the --buildable and --publishable options... the fact that --buildable implies partial (paused/postponed) compilation create any conflict? Can a publishable lib publish alright if its buildable?

But the last phase is publish

And according to this blog post, https://blog.nrwl.io/publishing-react-libraries-made-easy-d5b3d013deba one needs to manually change directories into each library manually individually one by one and do the following:

Lastly, to actually publish our library go into the dist/libs/use-viewport-size/ folder and run yarn publish --new-version. This command will publish the package using the version that we updated to earlier.

Has this functionality been automated as of yet for Nx ng-packgr-lite executor? What would be nice is if we could just do as follows from the toplevel rootDir nx publish

That would close out this ticket. Hoping for solution. This framework is a masterpiece. Thanks to all on the @nrwl/nx team.

I thought it helpful to list my publish sequence at this time

if I do npm publish from root Dir this is what lands in the github actions registry https://github.com/nhhockeyplayer/meanstacknh/packages/1556004

sunsewuent attempts to delete the package and get something else published with desired contents unsuccessful

meanstack02@admin feature-shell % npm publish
npm notice 
npm notice 📦  @meanstacknh/admin-root-feature-shell@0.0.1
npm notice === Tarball Contents === 
npm notice 172B   README.md                                       
npm notice 870B   esm2020/index.mjs                               
npm notice 17.8kB esm2020/lib/admin-root-feature-shell.module.mjs 
npm notice 3.4kB  esm2020/lib/modal/modal.component.mjs           
npm notice 4.8kB  esm2020/lib/navigation/navigation.component.mjs 
npm notice 55.5kB esm2020/lib/shell/shell.component.mjs           
npm notice 579B   esm2020/meanstacknh-admin-root-feature-shell.mjs
npm notice 200B   index.d.ts                                      
npm notice 1.3kB  lib/admin-root-feature-shell.module.d.ts        
npm notice 278B   lib/modal/modal.component.d.ts                  
npm notice 629B   lib/navigation/navigation.component.d.ts        
npm notice 1.5kB  lib/shell/shell.component.d.ts                  
npm notice 1.3kB  package.json                                    
npm notice === Tarball Details === 
npm notice name:          @meanstacknh/admin-root-feature-shell          
npm notice version:       0.0.1                                          
npm notice filename:      @meanstacknh/admin-root-feature-shell-0.0.1.tgz
npm notice package size:  19.6 kB                                        
npm notice unpacked size: 88.4 kB                                        
npm notice shasum:        fd2de22d6f8f3ce4199e3a2da2049802be89514f       
npm notice integrity:     sha512-hvMVd+t0qBE/A[...]SDLCGROkL9pJg==       
npm notice total files:   13                                             
npm notice 
npm notice Publishing to https://npm.pkg.github.com/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/@meanstacknh%2fadmin-root-feature-shell - The expected resource was not found.
npm ERR! 404 
npm ERR! 404  '@meanstacknh/admin-root-feature-shell@0.0.1' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/meanstack02/.npm/_logs/2022-07-24T08_36_25_536Z-debug-0.log
meanstack02@admin feature-shell % ls
README.md   esm2020     index.d.ts  lib     package.json
meanstack02@admin feature-shell % npm publish 0.0.2
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/0.0.2
npm ERR! 404 
npm ERR! 404  '0.0.2@latest' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/meanstack02/.npm/_logs/2022-07-24T08_36_57_059Z-debug-0.log
meanstack02@admin feature-shell % npm publish 0.0.0
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/0.0.0
npm ERR! 404 
npm ERR! 404  '0.0.0@latest' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/meanstack02/.npm/_logs/2022-07-24T08_37_06_310Z-debug-0.log
meanstack02@admin feature-shell % 

I cannot seem to get this package contents cobbled together into github registry as of yet

0.0.0 is conflicting with 0.0.0-semantic-release also the prefix and importPath seem a bit out of sync

any feedback on state of this feature is appreciated

nhhockeyplayer commented 2 years ago

this appears to be the process... rather cumbersome was hoping for something less involved and turn-key https://tane.dev/2020/05/publishing-npm-libraries-using-nx-and-github-actions/

nhhockeyplayer commented 2 years ago

Here is a newer process latter 2021 that doesn't involve a custom .github/scripts/publish-libraries.sh

https://yonatankra.com/how-to-deploy-npm-modules-in-an-nx-monorepo-and-github-actions/

still digging for the final cut on this and whether this is turn-key for Nx or being left wide open

Thanks for all you patience and diligence so far the field is ecstatic about these eFrastructure automations and cant wait to employ them Nx is literally THE way to develop software now. This effort sports an extensible spackled shining codebase. Awesome work.

nhhockeyplayer commented 2 years ago

a newer one https://gist.github.com/YonatanKra/36d2d5f68b750d6bf0edc5cfe94be277

not fond of using someone elses stuff uses: martinbeentjes/npm-get-version-action@master which should be built into the eFrastructure

especially when master is now main

hoping to pull this all together sooner than later

nhhockeyplayer commented 2 years ago

so this ticket has morphed into a publish ticket... since my local lib distribution was resolved using ng-packagr-lite

feel free to close if you want and create a publish issue if Nx team thinks thats the course

I guess the main question being QUES: is publish in automation development at this time ? Looking forward to your best.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 1 year ago

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.