FredKSchott / rollup-plugin-polyfill-node

A modern Node.js polyfill for your Rollup bundle.
Other
176 stars 55 forks source link

`readFile` is not exported by `polyfill-node.fs.js ` #43

Open Errorbot1122 opened 2 years ago

Errorbot1122 commented 2 years ago

This is the transfer of my issue in rollup-plugin-node-polyfills




WHAT!!!!!!!!!

https://github.com/ErrorBot1122/Roblox-File-Handler/commit/d0670bd3bdb340588eef969ca6b85417a73351c3

my live code is on replit

output:

>> npm run test

> rbx-file-handler@0.0.0 test /home/runner/Roblox-File-Handler-1
> npm run build; mocha || true

> rbx-file-handler@0.0.0 build
> rollup --config

index.js → builds/robloxFileHandler.mjs, builds/robloxFileHandler.js, builds/robloxFileHandler.min.mjs, builds/robloxFileHandler.min.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
xml2js (imported by index.js)
(!) Missing exports
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
index.js
readFile is not exported by polyfill-node.fs.js
348: 
349:   // Read the file
350:   fs.readFile(path, (rErr, data) => {
          ^
351:   
352:     if (rErr) {
created builds/robloxFileHandler.mjs, builds/robloxFileHandler.js, builds/robloxFileHandler.min.mjs, builds/robloxFileHandler.min.js in 6.7s

Classes/*.mjs, Datatypes/*.mjs, Enums/*.mjs → builds/RoModules.mjs, builds/RoModules.min.mjs...
created builds/RoModules.mjs, builds/RoModules.min.mjs in 2.8s

  MAIN
    parseFile
      ✔ Exists?
      ✔ Returns object with valid XML? (64ms)
      Read any valid RBXLX file
        ✔ Can parse simple baseplate? (RBXLX)
        ✔ Can parse simple baseplate? (XML) (97ms)
        ✔ Can parse simple baseplate? (TXT)
      Read diffent file sizes
        ✔ Can parse a large normel RBXLX file (1211ms)
    Classes
      ✔ exported classes exsit
      ✔ can create instance

  BUILDS
    ✔ Normal build exists
    ✔ Minifided build exists
    ✔ Minifided build is smaller the normal build

  11 passing (2s)

P.S. Sorry about the low quality, I'm just burned out today :(

busterbogheart commented 2 years ago

@ErrorBot1122 Did you get anywhere with this? Having a similar issue with homedir from 'os' core module.

Errorbot1122 commented 2 years ago

Sadly, I could not find a module that polyfills FS for browsers. What I did was just not use rollup altogether as I did not really NEED the browser build in the first place. All a did was make an issue about it here and hope that they add it the future it to the browser that adds the polyfill. That's why I made this issue in the first place.

What I suggest for you is to find an alternative for the OS module as I don't think that browsers have a way to access the OS. (for security reasons) You could also try looking online to try / the rollup documentation to see if there are any fixes or workarounds. (Im to lazy to do that irl)