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

Publish @gnui npm packages #592

Closed
wants to merge 1 commit into from
Closed

Publish @gnui npm packages #592

wants to merge 1 commit into from

Conversation

fgravin
Copy link
Member

@fgravin fgravin commented Aug 25, 2023

Attempt to publish geonetwork-ui librarues as npm packages using Nx publishable targets.
eg. nx g @nrwl/angular:library ui/blabla --publishable=true --importPath=@gnui/ui-blabla

In this PR, 2 new libs

  • npm-publishable which includes npm-publishable-dep
  • which includes ui-widgets (renamed from @geonetwork-ui/ui/widgets to @geonetwork-ui/ui-widgets)
  • which includes util-shared and third party libraries (ngx-translate, @angular/material ...)

So npm-publishable library is the entry point in this case for the third party angular application.
To make it buildable & publishable, all dependencies must be publishable as well. So util-shared and ui-widgets configuration files have been modified too (project.json, package.json ....).

geonetwork-ui internal libraries depends on third party libraries that must be included in the package dependencies. I choose to add them as dependencies instead of peerDependencies.

  • ui-widgets/package.json
  "dependencies": {
    "tslib": "^2.3.0",
    "@angular/material": "16.0.4",
    "@angular/material-moment-adapter": "16.0.4",
    "ngx-chips": "3.0.0",
    "@ngx-translate/core": "~14.0.0",
    "@ngx-translate/http-loader": "~7.0.0",
    "ngx-dropzone": "^3.0.0",
    "@types/geojson": "^7946.0.7",
    "@bartholomej/ngx-translate-extract": "^8.0.2",
    "@biesbjerg/ngx-translate-extract-marker": "^1.0.0",
    "chroma-js": "^2.1.2"
  },
  • ui-widgets/ng-package.json
  "allowedNonPeerDependencies": [
    "@angular/material",
    "@angular/material-moment-adapter",
    "ngx-chips",
    "@ngx-translate/core",
    "@ngx-translate/http-loader",
    "ngx-dropzone",
    "@types/geojson",
    "@bartholomej/ngx-translate-extract",
    "@biesbjerg/ngx-translate-extract-marker",
    "chroma-js"
  ]

Build libraries
nx build npm-publishable

Publish libraries
npm i -g yalc
from all library build package folders (eg. dist/libs/npm/publishable) run yalc publish

Create the host app
nx ng new gnui-host

add dependencies from host

  • yalc add @gnui/publishable @gnui/publishable-dep @geonetwork-ui/util-shared @geonetwork-ui/ui-widgets
  • npm i to install the deps of the deps

Then include the module dependency, the <gnui-random> component and serve the application.

To continue

  • handle TW as peerDependency & configure it properly, or include a css in the package
  • try a material component
  • try fonts
  • try i18n
  • publish other libraries
  • create a npm init thing to add all deps at once from the third party app

@fgravin fgravin requested review from jahow and f-necas August 25, 2023 11:16
@fgravin
Copy link
Member Author

fgravin commented Aug 25, 2023

Note from Nx users, might be an automatic way to add lib deps in their package.json automatically

You need to add dependencies using updateBuildableProjectDepsInPackageJson or https://nx.dev/packages/eslint-plugin/documents/dependency-checks
or write them manually in package.json.

@f-necas
Copy link
Collaborator

f-necas commented Aug 25, 2023

@fgravin Have you been able to publish them in a local repository like Verdaccio or something else ?

@fgravin
Copy link
Member Author

fgravin commented Aug 25, 2023

@fgravin Have you been able to publish them in a local repository like Verdaccio or something else ?

I used yalc, it's mentioned in the PR description.

@f-necas
Copy link
Collaborator

f-necas commented Aug 25, 2023

Oh sorry, didn't notice it was a local pkg manager

@jahow jahow mentioned this pull request Nov 8, 2023
4 tasks
@fgravin fgravin closed this Nov 23, 2023
@fgravin fgravin deleted the npm-packages branch November 23, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants