Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Stop relying on webpack for legacy bundles generation #1425

Commits on Apr 4, 2024

  1. 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.
    peaBerberian committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    3f6a3ff View commit details
    Browse the repository at this point in the history