SukkaW / nolyfill

Speed up your package installation process, reduce your disk usage, and extend the lifespan of your precious SSD.
MIT License
1.11k stars 15 forks source link

"safer-buffer": "npm:@nolyfill/safer-buffer@^1" pnpm overrides crashes on repeated pnpm install while installing cypress #108

Closed JustFly1984 closed 1 month ago

JustFly1984 commented 1 month ago

removing "safer-buffer": "npm:@nolyfill/safer-buffer@^1" from overrides fixes an issue

an error:

node_modules/.pnpm/sshpk@1.18.0/node_modules/sshpk/lib/algs.js:57
│               p: Buffer.from(('00' +
│                         ^
│ TypeError: Cannot read properties of undefined (reading 'from')
SukkaW commented 1 month ago

Oh, I know what happened. safe-buffer exposes Buffer through named export, but @nolyfill/safer-buffer adds default export.

SukkaW commented 1 month ago

@JustFly1984 The nolyfill 1.0.41 just released!

JustFly1984 commented 1 month ago

@SukkaW It is fixed pnpm install issue, but introduced new issue - vite dev is crashing with next error.

/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:415
    throw new TypeError('argument fn must be a function')
    ^

TypeError: argument fn must be a function
    at Function.wrapfunction [as function] 

Removing overrides one by one doesn't help, I had to remove all overrides to restore dev mode.

this is the latest config generated by latest npx nolyfill:

      "array-flatten": "npm:@nolyfill/array-flatten@^1",
      "array-includes": "npm:@nolyfill/array-includes@^1",
      "array.prototype.findlast": "npm:@nolyfill/array.prototype.findlast@^1",
      "array.prototype.findlastindex": "npm:@nolyfill/array.prototype.findlastindex@^1",
      "array.prototype.flat": "npm:@nolyfill/array.prototype.flat@^1",
      "array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@^1",
      "array.prototype.tosorted": "npm:@nolyfill/array.prototype.tosorted@^1",
      "deep-equal": "npm:@nolyfill/deep-equal@^1",
      "es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@^1",
      "hasown": "npm:@nolyfill/hasown@^1",
      "is-arguments": "npm:@nolyfill/is-arguments@^1",
      "is-core-module": "npm:@nolyfill/is-core-module@^1",
      "is-generator-function": "npm:@nolyfill/is-generator-function@^1",
      "is-typed-array": "npm:@nolyfill/is-typed-array@^1",
      "isarray": "npm:@nolyfill/isarray@^1",
      "object.assign": "npm:@nolyfill/object.assign@^1",
      "object.entries": "npm:@nolyfill/object.entries@^1",
      "object.fromentries": "npm:@nolyfill/object.fromentries@^1",
      "object.groupby": "npm:@nolyfill/object.groupby@^1",
      "object.values": "npm:@nolyfill/object.values@^1",
      "safe-buffer": "npm:@nolyfill/safe-buffer@^1",
      "safe-regex-test": "npm:@nolyfill/safe-regex-test@^1",
      "side-channel": "npm:@nolyfill/side-channel@^1",
      "string.prototype.includes": "npm:@nolyfill/string.prototype.includes@^1",
      "string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@^1",
      "string.prototype.repeat": "npm:@nolyfill/string.prototype.repeat@^1",
      "string.prototype.trimend": "npm:@nolyfill/string.prototype.trimend@^1",
      "which-typed-array": "npm:@nolyfill/which-typed-array@^1"

I had to remove all of them to fix vite/remix dev app dev. I have to remove it from 6 repositories with vite and remix

JustFly1984 commented 1 month ago

The thing is I've rerun npx nolyfill, and now there is no way to rollback previous versions without reverting git commits and it is too late for that and it is time consuming.

JustFly1984 commented 1 month ago

@SukkaW Can you please specify specific versions in overrides? this way I could roll it back next time.

SukkaW commented 1 month ago

Oops. Lemme looking into this real quick!

JustFly1984 commented 1 month ago

@SukkaW still crashing with same error. Tried to update again. And still generates overrides with ^1 version

Can you please change code, so it does not use ^ in versions? ^ is useful only in packages, and risky in the end-consumer project's package.json.

For better transparency and review visibility, on sequential runs of pnpx nolyfill it will be so much useful to see updated versions directly in overrides and to commit it into the repo. Currently I have no patience to look through the lock file to see the difference.

SukkaW commented 1 month ago

@SukkaW It is fixed pnpm install issue, but introduced new issue - vite dev is crashing with next error.

/node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js:415
    throw new TypeError('argument fn must be a function')
    ^

TypeError: argument fn must be a function
    at Function.wrapfunction [as function] 

Would you provide me a reproduction so that I am able to see what has been passed to depd? depd is throwing an error about its parameter, but I don't know the exact parameter.

JustFly1984 commented 1 month ago

@SukkaW I've added you to https://github.com/hexmate-live/hexmate-remix-admin/invitations , please feel free to test copy .example.env to .env.development pnpm install && pnpm tun nolyfill && pnpm run dev

JustFly1984 commented 1 month ago

PS dev branch

SukkaW commented 1 month ago

@SukkaW I've added you to https://github.com/hexmate-live/hexmate-remix-admin/invitations , please feel free to test copy .example.env to .env.development pnpm install && pnpm tun nolyfill && pnpm run dev

I am able to reproduce the error. The issue is caused by @nolyfill/array-flatten. Turns out that although the latest version array-flatten uses named export, the previous version uses default export, so @nolyfill/array-flatten only adds named export, hence the issue.

SukkaW commented 1 month ago

@JustFly1984 The CI is already publishing the 1.0.42. Meanwhile, I have already left the repo, thanks for the reproduction!

JustFly1984 commented 1 month ago

Great that you have fixed that, but for the future, can you please fix overrides to use strict versions? I do not feel comfortable to update your packages overrides, cos I have no idea what exactly has changes

SukkaW commented 1 month ago

Great that you have fixed that, but for the future, can you please fix overrides to use strict versions? I do not feel comfortable to update your packages overrides, cos I have no idea what exactly has changes

I am thinking about the best way to implement this (also thinking about how to update). The nolyfill used to use @latest other than @^1, and we have changed that.

JustFly1984 commented 1 month ago

@SukkaW Please set your actual strict versions. For every consequence run of optimize, if any of your packages has updated, it should update override accordingly , if no updates... well no updates. As I've added the cli into devDependenxies anyway - hate to spam global namespace) it will be easier to track for new cli releases and rerun optimize script.