polyfillsremix.run

Problem with Remix polyfills when importing oslo/password


I am trying to use oslo to implement auth functionality in my remix app. When importing oslo/password and rebuilding my app, the build fails with this error message:

✘ [ERROR] No matching export in "node-modules-polyfills:node:crypto" for import "scrypt"

    node_modules/oslo/dist/password/scrypt.js:1:9:
      1 │ import { scrypt } from "node:crypto";
        ╵          ~~~~~~

I am not really sure if this originates from Remix not adding the correct polyfill to the browser bundle or unnecessarily adding an outdated polyfill to the server bundle.

Steps I have taken so far (without success) include:

There is also a paragraph in the oslo docs, explaining that in Next.js webpack has to be specifically configured to make oslo/password work. However, I am not sure how to adapt this to Remix and whether this would even solve the problem.

Thank you in advance for all your help!


Solution

  • I have solved this by only using 'oslo/password' in server-only files (.server.ts).