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

Error when trying to use this in WebPack. #8

Closed
chr15m opened this issue Sep 25, 2019 · 5 comments
Closed

Error when trying to use this in WebPack. #8

chr15m opened this issue Sep 25, 2019 · 5 comments

Comments

@chr15m
Copy link

chr15m commented Sep 25, 2019

Hi @feross - I know you're very busy so hopefully this won't take much of your time.

When I try to do a simple import * as timidity from "timidity"; and then run that file through webpack I get the following 2 errors:

ERROR in ./node_modules/timidity/libtimidity.wasm
Module not found: Error: Can't resolve 'env' in '/home/chrism/dev/something/node_modules/timidity'
 @ ./node_modules/timidity/libtimidity.wasm
 @ ./node_modules/timidity/index.js
 @ ./src/js/index.js

ERROR in ./node_modules/timidity/libtimidity.wasm
WebAssembly module is included in initial chunk.
This is not allowed, because WebAssembly download and compilation must happen asynchronous.
Add an async splitpoint (i. e. import()) somewhere between your entrypoint and the WebAssembly module:
* ./src/js/index.js --> ./node_modules/timidity/index.js --> ./node_modules/timidity/libtimidity.wasm

I'm not a heavy webpack user but maybe you have some pointers as to how I can fix this? Will issue a PR if I get it working.

@chr15m
Copy link
Author

chr15m commented Sep 25, 2019

If I follow the advice in the second error it goes away but I still get the first error ("Can't resolve 'env'").

@chr15m
Copy link
Author

chr15m commented Sep 25, 2019

Just saw this: webpack/webpack#7352

I will follow up with the workaround linked there.

@chr15m chr15m closed this as completed Sep 25, 2019
@chr15m
Copy link
Author

chr15m commented Sep 26, 2019

I got webpack to build without errors using the suggested workaround:

  "module": {
    "rules": [
      {
        "test": /libtimidity\.wasm$/,
        "type": "javascript/auto", // ← !!
        "loader": "file-loader",
        "options": {
          "publicPath": "/"
        }
      }
    ]
  }

However I couldn't figure out how to use that build. In the end I gave up and just used bg-sound in a script tag and banged a <bg-audio src="...mid"> into the page.

Hopefully in future somebody will get a demo app working with Timidity using Webpack.

@feross
Copy link
Owner

feross commented Oct 1, 2019

Glad you got it working. I'm not sure what the webpack issue is. It works fine in browserify with no config needed.

@chr15m
Copy link
Author

chr15m commented Oct 1, 2019

Yes I don't know why I didn't just try a browserify build instead. Great idea. Will do that for the next iteration. Thanks @feross very much appreciate your work!

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