Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Circular dep in Wasm import #7

Open
jacogr opened this issue Feb 15, 2019 · 6 comments
Open

Circular dep in Wasm import #7

jacogr opened this issue Feb 15, 2019 · 6 comments

Comments

@jacogr
Copy link
Contributor

jacogr commented Feb 15, 2019

Basically webpack displays this -

    WARNING in /Users/jacogreeff/Projects/polkadot/apps/node_modules/@parity/schnorrkel-js/schnorrkel_js.js 232:25-39
    Critical dependency: the request of a dependency is an expression

Due to schnorrkel_js.js importing schnorrkel_js_bg.js and that requiring schnorrkel_js.js

@jacogr
Copy link
Contributor Author

jacogr commented Feb 15, 2019

Additionally -

Uncaught RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.compile, or compile on a worker thread.
    at Object.eval (schnorrkel_js_bg.js?9681:5)

@jacogr
Copy link
Contributor Author

jacogr commented Feb 15, 2019

Worked around the circular dep in polkadot-js/common#306, made the WASM init async in polkadot-js/common#307 and fixed dependency as expression in polkadot-js/common#308

(For now, basically some adjustments to the generated files which is being maintained in that repo until there are a general solutions available)

@jacogr
Copy link
Contributor Author

jacogr commented Feb 15, 2019

Last issue (that I don't have a work-around in for) is the require here -

module.exports.__wbg_require_86edd37cfda5f13d = function(arg0, arg1) {
    let varg0 = getStringFromWasm(arg0, arg1);
    return addHeapObject(require(varg0));
};

Cannot see why WASM would need to require. Anyway, for now will just have to deal with the warning in React apps and deal with the bug reports. (Leaning towards just removing/stubbing that and seeing if it still works)

@kianenigma
Copy link
Collaborator

I've seen the warning but never really paid much attention to it as

  • I personally prefer nodejs for testing.
  • I didn't see such an issue in the scope of this project at the beginning. Now with a version published in npmjs I actually do so we have a point here. I'll keep it open and try to find a better fix. It also looks like (as you pointed out) that wasm-pack will expand its publish methods so a plan B is to just wait if it doesn't crash anything.
    The first circular import is strange and it is coming from code auto-generated from wasm-pack. Very strange.

@kianenigma
Copy link
Collaborator

I am no master in webpack and these new fancy import (back in my days there was just require and nothing more. no imports in the browser) but this like you mentioned:

Due to schnorrkel_js.js importing schnorrkel_js_bg.js and that requiring schnorrkel_js.js

Is actually what exists in the generated files originally, we are also writing it again as a part of our **fix import **.

@jacogr
Copy link
Contributor Author

jacogr commented Feb 15, 2019

Yeap, it is a wasm-pack generation issue, nothing that is introduced elsewhere.

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

No branches or pull requests

2 participants