webpack.js.org icon indicating copy to clipboard operation
webpack.js.org copied to clipboard

Add more explanation of the webpack 5 web worker bundling functionality

Open cmdcolin opened this issue 3 years ago • 4 comments

I was a little confused when reading the web workers document and have returned to it a couple times and only when i tried it out mysef to see that bundling happens with the "new Worker" usage was I aware that webpack does bundling with this, so I thought I'd add some notes about this to the docs!

Let me know if this makes sense

cmdcolin avatar Dec 17 '21 03:12 cmdcolin

CLA Signed

The committers are authorized under a signed CLA.

  • :white_check_mark: Colin Diesh (30b1596d07ecc990f27621d4f9b5450fd6042690)

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/webpack-docs/webpack-js-org/6DmD8B1pBixTTYZMR7B84AZA4T5Q
✅ Preview: https://webpack-js-org-git-fork-cmdcolin-cmdcolin-patch-1-webpack-docs.vercel.app

vercel[bot] avatar Dec 17 '21 03:12 vercel[bot]

Webpack is a bundler, so it's likely to bundle any files you have unless you tell it not to :) Hence I think it's not necessary to explain it? Otherwise we're going to explain a lot of native ECMAScript features. What do you think?

chenxsan avatar Dec 22 '21 14:12 chenxsan

thanks for considering. my basic thought is it is valuable to have extra context.

my thought process is sort of like this: "this seems like they are just using native js, i don't think it is doing any bundling on the worker resources because it's just importing a js file by name, that must mean deep-thought.js has to go in the public directory in create-react-app or something like that"

I guess perhaps import.meta.url maybe helps resolve this placement issue in native js, but import meta's are new to me and this also not necessarily explained by the docs, and again, just not clear that bundling happens on this file, or that it could be typescript, etc.

cmdcolin avatar Dec 22 '21 17:12 cmdcolin

Thanks for the PR. I agree with https://github.com/webpack/webpack.js.org/pull/5796#issuecomment-999637044, I believe the current docs are fine.

snitin315 avatar Feb 24 '24 18:02 snitin315

i'm surprised that you think this small change is not helpful. similarly, mentioning that you can import e.g. typescript files, or extensionless files in the new URL('...file here...') paramter, which works with just plain node.js type module resolution, that is not very clear from current docs IMO

cmdcolin avatar Feb 24 '24 20:02 cmdcolin