| 1 Dec 2023 |
Lily Foster | In reply to @tensor5:matrix.org
Can someone help with this
mkYarnPackage {
src = fetchFromGitHub {
owner = "salesforcecli";
repo = "cli";
rev = "2.17.14";
hash = "sha256-lliHmc/LJCEkZcxBdnSAqpYpnz7R/g6Q2Oi7hIB04B4=";
};
buildPhase = ''
runHook preBuild
yarn --offline build
runHook postBuild
'';
postBuild = "npm prune --omit=dev";
doDist = false;
}
the problem I'm trying to solve is pruning devDependencies
just use yarn install --offline --frozen-lockfile --ignore-engines rather than trying to yarn build and then using npm | 16:06:03 |
Lily Foster | In reply to @tensor5:matrix.org
Can someone help with this
mkYarnPackage {
src = fetchFromGitHub {
owner = "salesforcecli";
repo = "cli";
rev = "2.17.14";
hash = "sha256-lliHmc/LJCEkZcxBdnSAqpYpnz7R/g6Q2Oi7hIB04B4=";
};
buildPhase = ''
runHook preBuild
yarn --offline build
runHook postBuild
'';
postBuild = "npm prune --omit=dev";
doDist = false;
}
the problem I'm trying to solve is pruning devDependencies
* just use yarn install --offline --frozen-lockfile --ignore-engines rather than trying to yarn build + npm prune | 16:06:12 |
Nicola Squartini | In reply to @lily:lily.flowers just use yarn install --offline --frozen-lockfile --ignore-engines rather than trying to yarn build and then using npm no luck
[] 0/1376error Can't make a request in offline mode ("https://registry.yarnpkg.com/got/-/got-11.8.6.tgz")
| 18:31:58 |
Lily Foster | In reply to @tensor5:matrix.org
no luck
[] 0/1376error Can't make a request in offline mode ("https://registry.yarnpkg.com/got/-/got-11.8.6.tgz")
ugh yarn2nix makes me sad. i'll look at the yarn2nix code in a bit and get back to you | 18:44:33 |
| 3 Dec 2023 |
| @ThorHop:matrix.org changed their display name from hopland (valorent vicky) to hopland (meticulous montesquieu). | 14:08:31 |
| 5 Dec 2023 |
| Federico Damián Schonborn changed their profile picture. | 00:38:02 |
| 8 Dec 2023 |
| fwam left the room. | 06:53:36 |
| 10 Dec 2023 |
Emma [it/its] ⚡️ | i wonder if theres a better way to do package nodejs apps... | 19:59:02 |
Emma [it/its] ⚡️ | https://github.com/spacebarchat/server/blob/dev/nix/flake.nix#L24-L57 | 19:59:31 |
Lily Foster | In reply to @emma:conduit.rory.gay https://github.com/spacebarchat/server/blob/dev/nix/flake.nix#L24-L57 they could have specified a good chunk of that in the package.json and let the default install behavior still run for buildNpmPackage. Then a postInstall hook would have been much shorter | 20:01:27 |
Emma [it/its] ⚡️ | i wrote that | 20:01:42 |
Emma [it/its] ⚡️ | hence why im asking for what i could improve | 20:01:53 |
Emma [it/its] ⚡️ | https://github.com/spacebarchat/server/blob/dev/nix/package.json#L113 | 20:02:18 |
Lily Foster | ah! i'll give specifics then, apologies. one moment, i only just got my laptop out | 20:05:17 |
Emma [it/its] ⚡️ | yeah, i'd love to ditch all of that mess and go back to normal nodejs behavior | 20:05:38 |
Lily Foster | quick question, is it critical to keep stuff not in the normal npm directory in $out? because this could be even shorter if so | 20:06:15 |
Emma [it/its] ⚡️ | not at all | 20:06:26 |
Lily Foster | (normal being $out/lib/node_modules/[package name]) | 20:06:30 |
Emma [it/its] ⚡️ | wait, how do you mean | 20:06:48 |
Lily Foster | like, the files here aren't getting install like npm install -g would do rn. which is fine, it would just involve moving things to the unexpected place in postInstall | 20:07:25 |
Emma [it/its] ⚡️ | i wrote all of that mess due to a bunch of imports cross-referencing projects | 20:08:22 |
Emma [it/its] ⚡️ | https://github.com/spacebarchat/server/blob/master/package.json | 20:08:40 |
Emma [it/its] ⚡️ | this is the non-nix package.json im using as base, by the way | 20:08:49 |
Lily Foster | In reply to @emma:conduit.rory.gay i wrote all of that mess due to a bunch of imports cross-referencing projects yeah i'm seeing that | 20:09:10 |
Emma [it/its] ⚡️ | Lily Foster i was browsing WebStorm settings... | 20:36:47 |
Emma [it/its] ⚡️ | I wonder if Use paths relative to project, resource or sources roots is a good option to turn on? | 20:37:02 |
Emma [it/its] ⚡️ |  Download Screenshot from 2023-12-10 21-37-16.png | 20:37:22 |
Emma [it/its] ⚡️ | (for imports, that is) | 20:38:14 |
Lily Foster | In reply to @emma:conduit.rory.gay https://github.com/spacebarchat/server/blob/master/package.json so this doesn't remove the openapi.json file, but this diff seems to build and run similarly in testing:
diff --git a/flake.nix b/flake.nix
index 71760eff..1391bca1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,46 +15,10 @@
pname = "spacebar-server-ts";
src = ./.;
name = "spacebar-server-ts";
- nativeBuildInputs = with pkgs; [ python3 ];
npmDepsHash = "sha256-axzbsD+jOViIQ9+qFSX41j6harBL9vyaXDKdOSaPW8M=";
- makeCacheWritable = true;
postPatch = ''
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
'';
- installPhase = ''
- runHook preInstall
- set -x
- #remove packages not needed for production, or at least try to...
- npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
- find node_modules -maxdepth 1 -type d -empty -delete
-
- mkdir -p $out/node_modules/
- cp -r node_modules/* $out/node_modules/
- cp -r dist/ $out/node_modules/@spacebar
- for i in dist/**/start.js
- do
- makeWrapper ${pkgs.nodejs-slim}/bin/node $out/bin/start-`dirname ''${i/dist\//}` --prefix NODE_PATH : $out/node_modules --add-flags $out/node_modules/@spacebar`dirname ''${i/dist/}`/start.js
- done
- set +x
- substituteInPlace package.json --replace 'dist/' 'node_modules/@spacebar/'
- find $out/node_modules/@spacebar/ -type f -name "*.js" | while read srcFile; do
- echo Patching imports in ''${srcFile/$out\/node_modules\/@spacebar//}...
- substituteInPlace $srcFile --replace 'require("./' 'require(__dirname + "/'
- substituteInPlace $srcFile --replace 'require("../' 'require(__dirname + "/../'
- substituteInPlace $srcFile --replace ', "assets"' ', "..", "assets"'
- #substituteInPlace $srcFile --replace 'require("@spacebar/' 'require("
- done
- set -x
- cp -r assets/ $out/
- cp package.json $out/
- rm -v $out/assets/openapi.json
- #rm -v $out/assets/schemas.json
-
- #debug utils:
- #cp $out/node_modules/@spacebar/ $out/build_output -r
- set +x
- runHook postInstall
- '';
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
diff --git a/package.json b/package.json
index 83ec9dcc..e0dcf4c9 100644
--- a/package.json
+++ b/package.json
@@ -37,6 +37,16 @@
"imports": {
"#*": "./dist/*/index.js"
},
+ "files": [
+ "dist",
+ "assets"
+ ],
+ "bin": {
+ "start-bundle": "dist/bundle/start.js",
+ "start-api": "dist/api/start.js",
+ "start-cdn": "dist/cdn/start.js",
+ "start-gateway": "dist/gateway/start.js"
+ },
"homepage": "https://spacebar.chat",
"devDependencies": {
"@types/amqplib": "^0.8.2",
| 20:38:21 |
Lily Foster | In reply to @emma:conduit.rory.gay I wonder if Use paths relative to project, resource or sources roots is a good option to turn on? for your IDE? | 20:38:55 |