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

Not able to use the library as a browser module because of "path" dependency

Open Himujjal opened this issue 4 years ago • 6 comments

I am trying to import this library as a module in the browser. There is a require("path") dependency that is preventing it from being used as a browser module. Any solutions to this problem.

Himujjal avatar Mar 03 '21 21:03 Himujjal

Hmm, the require("path") looks like something that is either part of WABT's glue code (note that this issue tracker is part of an automated buildbot that is not adding own code), or part of the glue code generated by Emscripten.

dcodeIO avatar Mar 03 '21 22:03 dcodeIO

So, I checked with rollup and webpack. Both cannot get the library as such. Is there any way that can be done differently? Or are there any examples where it is used as a npm module instead of importing directly on the <script> tags

Himujjal avatar Mar 04 '21 00:03 Himujjal

Last time I checked it worked just fine as an npm module via require("wabt"), but bundling it may require shimming node's path module apparently. I know that webpack can do this with config options, either stubbing the module out (not sure if that'll work, depends on what wabt does with it I guess) or providing an alternative implementation that works in the browser.

dcodeIO avatar Mar 04 '21 01:03 dcodeIO

For rollup it sayd requires$$0 not found. I am assuming it must be due to the reliance of require in the browser. Now the UMD module works perfectly fine using window.WabtModule (try importing <script src="wabt.js"></script>).

Himujjal avatar Mar 04 '21 06:03 Himujjal

I tried it with parcel and its the only bundler that seems to work with this module as per my configurations. This is an emscripten issue perhaps.

Himujjal avatar Mar 04 '21 08:03 Himujjal

v1.0.16 works for me, v1.0.17, not.

Butterwell avatar Sep 05 '21 13:09 Butterwell