deptoolkit icon indicating copy to clipboard operation
deptoolkit copied to clipboard

Rewrite browser extension: TS, no Webpack

Open basilesimon opened this issue 3 years ago • 5 comments

basilesimon avatar Aug 11 '21 10:08 basilesimon

Sorry for the interruption: does using TyoeScript mean you no longer need Webpack to bundle for the browser?

edsu avatar Aug 11 '21 18:08 edsu

Hey Ed, thanks for stopping by 👋

I'd love to do away with Webpack, if I'm honest. Doesn't really feel right to be installing 800+ packages for a browser extension...

This part of the plumbing, so to speak, isn't really my cup of tea, hence the help wanted tag 🙂

Would you happen to have thoughts or knowledge of these things, by any chance?

basilesimon avatar Aug 12 '21 08:08 basilesimon

There's this rather feature-full template, which includes TypeScript (yay) but also React (uh), Babel (er), and Webpack (ah...). That's about 1,500 packages to install to run it...

basilesimon avatar Aug 13 '21 08:08 basilesimon

I totally understand, and is exactly why I was asking :-) I've been meaning to switch over to using TypeScript and was wondering if it made some of the Webpack bloat go away.

I think one approach to doing away with Webpack while still using components is to use the browser's native support for custom elements. I think libraries like lit-element help with that. Packaging with Webpack or Rollup sneak back into the picture once you need to import another module. But if your browser extension doesn't really have any dependencies that need to be bundled along with it maybe this approach would work?

edsu avatar Aug 13 '21 12:08 edsu

But if your browser extension doesn't really have any dependencies that need to be bundled along with it maybe this approach would work?

I know, it's tragic isn't it! A big reason for adding Webpack support was to offer a nicer dev experience, which quite frankly benefits from in-browser hot reloading without having to re-import your manifest into the browser...

basilesimon avatar Aug 16 '21 08:08 basilesimon