davidmyersdev / vite-plugin-node-polyfills

A Vite plugin to polyfill Node's Core Modules for browser environments.
MIT License
263 stars 17 forks source link

Can this work with fs/promises? #25

Closed NoisyMonk closed 11 months ago

NoisyMonk commented 12 months ago

vite: 4.4.0 vite-plugin-node-polyfills: 0.9.0

I stumbled across this Plugin while trying to solve a "Failed to resolve entry for package "fs"" error and this looks promising. However while this Plugin does fix that first error, I then get the following error. Am I doing something wrong, or is this use case not covered?

image

image

davidmyersdev commented 11 months ago

This is a duplicate of #16. It's not currently supported, but it's on the roadmap for when I have time to get to it. Always happy to review a PR in the meantime though. 😄

shellscape commented 4 months ago

For anyone else who runs across this, add this resolve config to your vite config:

  resolve: {
    alias: {
      'node:fs/promises': 'node-stdlib-browser/mock/empty',
    }
  },

(Omit node: if you don't have imports using that protocol) That points the fs/promises import at the same mock that node-stdlib-browser uses for fs.