GoogleChromeLabs / wasm-bindgen-rayon

An adapter for enabling Rayon-based concurrency on the Web with WebAssembly.
https://github.com/RReverser/wasm-bindgen-rayon
Apache License 2.0
404 stars 35 forks source link

Webpack warning of circular dependencies inside workerHelper.js #23

Closed codeart1st closed 2 years ago

codeart1st commented 2 years ago
WARNING in [entry] [initial]
Circular dependency between chunks with runtime (main, pkg_snippets_wasm-bindgen-rayon-7afa899f36665473_src_workerHelpers_js, src_worker_js-pkg_snippets_wasm-bindgen-rayon-7afa899f36665473_src_workerHelpers_js)
This prevents using hashes of each other and should be avoided.

Current versions of webpack don't seem to like the recursion inside workerHelper.js

      // Self-spawn into a new Worker.
      //
      // TODO: while `new URL('...', import.meta.url) becomes a semi-standard
      // way to get asset URLs relative to the module across various bundlers
      // and browser, ideally we should switch to `import.meta.resolve`
      // once it becomes a standard.
      //
      // Note: we could use `../../..` as the URL here to inline workerHelpers.js
      // into the parent entry instead of creating another split point -
      // this would be preferable from optimization perspective -
      // however, Webpack then eliminates all message handler code
      // because wasm-pack produces "sideEffects":false in package.json
      // unconditionally.
      //
      // The only way to work around that is to have side effect code
      // in an entry point such as Worker file itself.
      const worker = new Worker(new URL('./workerHelpers.js', import.meta.url), {
        type: 'module'
      });
maxammann commented 2 years ago

I kind of suspect that this is expected and nothing to worry about. I mean this circular dependency is in fact by purpose.

codeart1st commented 2 years ago

If it's intendet and there are no ways to ignore this warning in the library itself, the issue can be closed.

Currently to get rid of the message I added the following to my webpack config.

  ignoreWarnings: [
    /Circular dependency between chunks with runtime/
  ],
maxammann commented 2 years ago

ignoreWarnings: [ /Circular dependency between chunks with runtime/ ],

This actually ignores all kinds of these messages. I would not do this as you might miss proper issues!

I'm still investigating whether there is a way around this. I'm currently creating a library with a similar goal and experience the same issue.

RReverser commented 2 years ago

It is intended, yes, hence feel free to close. Side-note: as a Ukrainian, I'm currently not super-inclined to look at code and will be slow to respond to issues.

codeart1st commented 2 years ago

Close it now as a kind of documentation.

OT: I wish all ukrainian people and the russian people which were arrested because of demonstration peace in the world. ☮