Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why use fs? #49

Open
hopeless-programmer-online opened this issue Oct 18, 2024 · 1 comment
Open

Why use fs? #49

hopeless-programmer-online opened this issue Oct 18, 2024 · 1 comment

Comments

@hopeless-programmer-online

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.

@MichaelXF
Copy link

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants