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

[Bug] installing on next.js causes error #158

Closed
chrisgervang opened this issue Sep 15, 2021 · 1 comment
Closed

[Bug] installing on next.js causes error #158

chrisgervang opened this issue Sep 15, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@chrisgervang
Copy link
Collaborator

chrisgervang commented Sep 15, 2021

Describe the bug
Fatal error thrown when importing hubble.gl related to webm-writer running require('fs') in a browser environment.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new next.js app
  2. npm install [email protected]
  3. Import anything from hubble in code
  4. npm run dev
  5. See error 'webm-writer fs not defined'

Expected behavior
hubble.gl should not throw this error in a browser environment.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser chrome
  • Version 93

Additional context
The issue is coming from hubble's webm-writer dependency and this line of code:

https://github.com/thenickdude/webm-writer-js/blob/ccec843765a4c8fe2e77b0d808730108de0e4353/src/BlobBuffer.js#L222-L226

@chrisgervang chrisgervang added the bug Something isn't working label Sep 15, 2021
@chrisgervang
Copy link
Collaborator Author

chrisgervang commented Sep 15, 2021

This issue is related to thenickdude/webm-writer-js#16 since next.js also uses webpack. The workaround is to modify the webpack config.

Workaround:

Webpack v4
See the quick-start config node.fs: 'empty'

node: {
fs: 'empty'
},

Webpack v5
This config was changed to resolve.fallback.fs: false, see docs.

next.config.js

module.exports = {
  ...
  webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    // Important: return the modified config
    config.resolve = {...config.resolve, fallback: {fs: false}};
    return config
  },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant