wabt.js icon indicating copy to clipboard operation
wabt.js copied to clipboard

Why use fs?

Open hopeless-programmer-online opened this issue 1 year ago • 1 comments

I want to use wabt in my next.s project via npm package. Obviously, fs doesn't exist in browser environment so the import fails when next.js tries to bundle the package. Is there a workaround without including <script> directly into HTML? If no, why wabt needs fs? Can it be split in two so I can only load parseWat which (i suppose) should not depend on fs? Thanks.

Same issue with Create-React-App. This can be solved by first checking for window:

const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';

if(!isBrowser){
  // Load fs, path
}

MichaelXF avatar Dec 04 '24 05:12 MichaelXF