madjam002 / yarnpnp2nix

A performance focused and space efficient way of packaging NodeJS applications with Nix
MIT License
43 stars 5 forks source link

[WIP] update yarn to latest RC #12

Closed adrian-gierakowski closed 10 months ago

adrian-gierakowski commented 1 year ago

current version dosen't work with typescrpit > 4.8

Btw. how about using the yarnBerry you build with nix, together with YARN_PLUGGINS in development shell (just like you do in mkYarnPackage.nix), instead of checking in plugin/.yarn/releases/yarn-4.0.0-rc.25.cjs? We could then remove the following 2 lines:

https://github.com/madjam002/yarnpnp2nix/blob/fd1155ca345b9298014294c7eab796b32eec328d/plugin/.yarnrc.yml#L1

https://github.com/madjam002/yarnpnp2nix/blob/fd1155ca345b9298014294c7eab796b32eec328d/test/workspace/.yarnrc.yml#L4

done here, happy to add it to this PR

adrian-gierakowski commented 1 year ago

This is WIP as I'm getting some error when building test example (I've fixed hash missmatch )

I've built the plugin and yarn without minification and here's the stack trace

       >     at populateYarnPaths (/nix/store/jgj51a4nsbhzby18ldm1p6zklsh4pvna-yarn-plugin-yarnpnp2nix/plugin.js:5488:31)
       >     at _Configuration.triggerHook (/nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:42325:19)
       >     at async genPackList (/nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:148293:5)
       >     at async /nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:148505:25
       >     at async prepareForPack (/nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:148199:7)
       >     at async /nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:148503:9
       >     at async StreamReport.start (/nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:44426:13)
       >     at async PackCommand.execute (/nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:148498:22)
       >     at async PackCommand.validateAndExecute (/nix/store/mld37kzhq116qfyw2bp8svw5b07bk815-yarn-berry/bin/yarn:16883:28)

and the code which it points at

in the plugin

            if (pkg.canonicalReference.startsWith("workspace:")) {
              if (pkg.drvPath !== process.env.out) {
                await project.addWorkspace(pkg.packageLocation ?? path3.join(pkg.drvPath, "node_modules", pkg.name));
              }
            }

in yarn

        addWorkspace(workspace) {
          const dup = this.workspacesByIdent.get(workspace.locator.identHash);
adrian-gierakowski commented 1 year ago

Right, I forgot to update the yarnpkgs deps in package.json and addWorkspace changed

https://github.com/yarnpkg/berry/blob/86b6258251f4c355e52a98809ab4318d921b59a5/packages/yarnpkg-nm/sources/buildNodeModulesTree.ts#L236

adrian-gierakowski commented 1 year ago

note that rc44 is had a regressions which was fixed in rc45

regarding the issue above, I've got a fix here

https://github.com/rhinofi/yarnpnp2nix/commit/6cefb2ea79b50f209fba4b55173122f9bb8c870a#diff-114fea8423670f3f4d9e01d18a9f58055142f78ea3b9a99b3ea4e2c828687e6eL785-R785

do let me know if you'd consider accepting this PR and I can clean this up

madjam002 commented 10 months ago

Closing as the bundled version of Yarn has been removed and yarn-berry will be used from nixpkgs that is passed in, currently on 23.11 this is Yarn 4.0.1.