dojo / cli-build-webpack

🚀 **DEPRECATED** Dojo 2 - cli command for building applications
http://dojo.io
Other
4 stars 19 forks source link

Add worker-loader dependency to support web workers #169

Closed maier49 closed 7 years ago

maier49 commented 7 years ago

Type: feature

The following has been addressed in the PR:

Description:

Adding this dependency would allow the use of webworkers in a dojo app using this syntax

const worker: Worker = new (require('worker-loader?name=hackerNewsWebWorker.js!./hackerNewsWebWorker'));

It works with a normal build or the dev server, and causes a separate compilation for the webworker. Dependencies can be pulled into the webworker and will be built into a separate bundle.

kitsonk commented 7 years ago

Awesome!

Are there any changes to authoring tests in downstream applications?

Also, we should have at least some sort of test with this as well.

matt-gadd commented 7 years ago

Although I have no issue with the dependency, we so far have tried to avoid inline webpack loader requires, for the same reasoning as AMD plugins.

kitsonk commented 7 years ago

we so far have tried to avoid inline webpack loader requires

Yeah, good point, I hadn't appreciated that. Would a better approach be an abstraction that is part of Dojo 2 (maybe core) that ensure that it worked.

Also, if we do go with an approach like this, we should still find a better way to integrate it. We can type plugins now with something like:

declare module 'worker-loader?*' {
  export = /* ... */
}

Would we not be able to create something that wrapped ES import() that we could also inject some feature detection, so the code was isomorphic on Node.js as well?

maier49 commented 7 years ago

This feature needs further discussion to decide on the best approach. https://github.com/dojo/meta/issues/190 has been created for that purpose.