MatrixAI / js-pagination

Pagination library that supports Offset and Cursor based pagination
https://matrix.ai
Apache License 2.0
0 stars 0 forks source link

default.nix should actually build the package #1

Closed CMCDragonkai closed 3 years ago

CMCDragonkai commented 5 years ago

To actually do this, you have to make sure it brings in the dev dependencies. Then runs the npm run build to produce the final executable.

But to do this, this means the node2nix needs to generate dev dependencies, otherwise they won't be specified properly. Unless you can run nix in nix.

Furthermore this would just build a library, not the actual executable. But that's fine.

This will probably require this: https://github.com/svanderburg/node2nix/issues/149#issuecomment-534839565 for it to work properly.

CMCDragonkai commented 5 years ago

Adding --development flag does in fact add all the deps into node-packages.nix expanding it out to 4000 lines. This then does get installed during a nix-build, unfortunately this is not actually needed. What we want to do is realize that development dependencies are not needed at the final package, and are only relevant for running npm run build which requires those dev dependencies to be available in the local environment. Meaning they have to exist in the local node_modules directory, since we cannot make use of NODE_PATH like other programming languages. Given that these deps would be placed into the Nix store, it makes sense that this would then be need to be symlinked into the nix-build temporary directory.

CMCDragonkai commented 5 years ago

Related to: https://github.com/MatrixAI/JavaScript-Demo/issues/1

So it seems for now...

You would have to keep the built files dist in the actual repository so the dev dependencies are not required.

This means on git clone, you could build with nix-build which would get all the production dependencies as well.

Alternatively:

# where dist doesn't exist in the repo
git clone
nix-shell
npm install
npm run build
nix-build

vs

# where dist does exist in the repo
git clone
nix-build
CMCDragonkai commented 5 years ago

This is a low priority since JS libraries still go through NPM. Any nixified dependency still relies on the NPM. So as long as it is on NPM, that is sufficient for it to be used.

CMCDragonkai commented 3 years ago

Because this is a library and not an application, there's no need for this to be packaged up as a Nix package.

Only Node applications require any kind nixifying.

So this can be closed for now.