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

Single repository for app and related npm package #8

Open
skjnldsv opened this issue Nov 15, 2022 · 0 comments
Open

Single repository for app and related npm package #8

skjnldsv opened this issue Nov 15, 2022 · 0 comments
Labels
decided 👩‍⚖️ This is a summary of a previously addressed discussion

Comments

@skjnldsv
Copy link
Member

Single repository for app and related npm package

This decision have been taken after the following discussion: #3

Initial idea

Sometimes it may be useful to provide an npm package to ease the integration with an existing app or to provide reusable code.

For example text markdown rendering is reused in collectives and might be useful to other apps.

Splitting the text app into a package and the app would create extra overhead in particular for backporting fixes - but also in terms of testing, issue tracking etc. - we'd probably end up with a nextcloud/text repo and a nextcloud/nextcloud-text repo. Sounds confusing and might be asking for trouble.

So instead we'd like to build the @nextcloud/text npm package from the source code of the text app. This adds a new build target. In our case it also adds some tooling because we want to build esm packages - but it's far less intrusive than splitting the app in two repos.

The package.json file so far does not contain the fields relevant to packaging ('files', 'main', 'module', 'type') etc. We added them and we have a working prototype here: nextcloud/text#2386 So far it builds the package nicely and we can use it in collectives.

There's a bunch of metadata that is used both by the package and the app:

  • name in package.json
  • Version number in package.json
  • dependencies in package.json
  • Readme.md

Drawbacks

Seeing the issues with nextcloud/text#2614, it's a bad idea to have them both in the same root.

  1. A package.json is representing a single element.
  2. Having both the app AND the package is actually going to mess with the dependencies and make things messy in my opinion.

We took the decision to not share package.json

Recommendations:

  1. Do not serve multiple ressources from the same package.json
  2. you can have related apps and package in the same repo
  3. Make sure we have two separate packages for those use cases.
    Here is an example on how it could look like:
    MyApp/
    ├─ node_modules/
    ├─ dist/
    │  ├─ myapp.esm.js
    │  ├─ myapp.cjs.js
    │  └─ myapp.js
    ├─ js/
    │  └─ myapp-main.js
    ├─ src/
    │  ├─ package/
    │  │  ├─ node_modules/
    │  │  ├─ lib/
    │  │  │  └─ index.js
    │  │  └─ package.json
    │  └─ main.js
    ├─ package.json
    │
    
@skjnldsv skjnldsv added the decided 👩‍⚖️ This is a summary of a previously addressed discussion label Nov 15, 2022
@nextcloud nextcloud locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
decided 👩‍⚖️ This is a summary of a previously addressed discussion
Projects
None yet
Development

No branches or pull requests

1 participant