Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal: Stop relying on webpack for legacy bundles generation
As a follow-up effort to #1420 (on which this work is based on), I attempt here to stop relying on webpack for the generation of our "legacy bundles", which are rarely used RxPlayer bundles that are communicated through release notes and which exposes the `RxPlayer` class through the global scope (`window`). The idea, the same than for #1420, was to simplify our bundling process by relying only on esbuild for this (instead of both webpack and esbuild depending on the situation). I chose esbuild over webpack here mainly because I better understand its role, behavior and most-of-all its API than webpack's - though its (much) faster bundling speed is a also a very good argument for this. Like for #1420, the last remaining issue was our usage of the babeljs transpiler to transpile to ES5 (our legacy bundles are ES5), but that's been fixed by switching to swc for that part. Our legacy bundle was purely configured by the `webpack.config.js` file at the root of our project that I here removed. To replace it, I re-purposed our `scripts/bundle_worker.mjs` script into a more generic `scripts/run_bundler.mjs` script for which we're now supposed to indicate the wanted input and output files. -- Still, I encountered an important issue while doing that in that I did not understand how we're supposed to indicate to esbuild that our entry file's export has to be exported through the global scope (all my introduction about the esbuild API being simpler to understand now loses all credibility!). I tried playing with its [`globalName`](https://esbuild.github.io/api/#global-name) and [`format`](https://esbuild.github.io/api/#format) configuration options which seem linked to that but couldn't make it work. For now, I gave up, adding a `__GLOBAL_SCOPE__` compile-time constant (boolean) to `src/index.ts` which has to be set to `true` before bundling if you want to export the RxPlayer through the global scope.
- Loading branch information