-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Gatsby compatibility #1938
Add Gatsby compatibility #1938
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the change has been verified to work on web, I can't see much danger in this change.
That said, I've never played with these specific parameters before :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@NSpehler thanks. can you also add a changelog entry? |
Should I add it here https://github.com/katspaugh/wavesurfer.js/blob/master/CHANGES.md#340-unreleased in the 3.4.0 release? |
yep! |
…nto gatsby-compatibility
I've just edited the changelog to add this to the 4.0.0 release. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Hey All - I'm working on getting wavesurfer.js to work with a new Gatsby project I'm working on for a client, and am running into the window is not defined error. Here's the output from the console. Any insight would be appreciated! Thx. 3529 | * @return {function} Available
WebpackError: ReferenceError: window is not defined
|
Getting this same error with Vercel...I can change the file locally as referenced here: #1841 })(window = { devicePixelRatio: 1 }, function() { ^^ but this doesn't work for statically generated deploys. It seems as if the PR to solve this issue doesn't work or work as intended. Since adding Wavesurfer to my Next.js/Vercel project I'm not able to create a successful build. Build log: 23:18:03.407 > Build error occurred
23:18:03.408 ReferenceError: window is not defined
23:18:03.408 at Object../src/util/request-animation-frame.js (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:3399:16)
23:18:03.408 at __webpack_require__ (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:35:30)
23:18:03.408 at Object../src/util/index.js (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:3046:53)
23:18:03.410 at __webpack_require__ (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:35:30)
23:18:03.410 at Object../src/wavesurfer.js (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:3459:36)
23:18:03.410 at __webpack_require__ (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:35:30)
23:18:03.410 at /vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:99:18
23:18:03.410 at /vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:102:10
23:18:03.410 at webpackUniversalModuleDefinition (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:8:20)
23:18:03.411 at Object.<anonymous> (/vercel/workpath0/node_modules/wavesurfer.js/dist/wavesurfer.js:15:3) {
23:18:03.411 type: 'ReferenceError'
23:18:03.411 }
23:18:03.457 error Command failed with exit code 1. Can we get a proper fix for this? Thanks!!! |
I think there is a problem with SSR in general. There is a window reference that breaks the build also using sveltekit/vite. |
Short description of changes:
Up until now, Wavesurfer.js breaks the build on static site generator, because
window
is undefined during build.To fix this, I've slightly changed the Webpack configuration to make Wavesurfer.js compatible with Gatsby (and most likely other static site generators).
I have followed the recommendation of the Webpack documentation at https://webpack.js.org/configuration/output/#outputglobalobject
Setting the
globalObject
option tothis
effectively makes the UMD build available on both browsers and Node.js.We would love to see this merged, and thank you for all of your work on Wavesurfer.js!
Breaking in the external API:
None
Breaking changes in the internal API:
None
Todos/Notes:
Related Issues and other PRs:
See issue #1841