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

v4: Remove next-tick dependency #1312

Merged
merged 1 commit into from
Nov 14, 2023

Commits on Nov 13, 2023

  1. v4: Remove next-tick dependency

    For years, we had a unique external dependency (the only non-dev
    dependency) called "next-tick" allowing us to schedule callbacks in
    micro-tasks, either to provide asynchronous browser API shims or for
    some specific logic where we would prefer to bring some asynchronicity
    in without the need of bringing the event loop into this.
    
    We were not too happy having this dependency because the name "nextTick"
    didn't ring a bell to most RxPlayer developers who never really worked
    with node.JS before, whereas the "microtask" concept is generally more
    known and understood in JavaScript environments, or at least is easier
    to look for on the internet.
    
    Moreover, now that we consider that a Promise object has to be
    accessible globally in the current environment as a precondition to run
    the RxPlayer (so IE11 is now only supported as long as `Promise` is
    polyfilled by the application, which almost everyone still
    supporting that target in a complex media application does anyway) and
    that specification-following Promise implementations include a mean
    to schedule microtasks, we have a very easy way to provide a shim in
    cases where the `queueMicroTask` global function is not already
    supported.
    
    So this commit removes the next-tick dependency and replace it by either
    the natively-provided `queueMicroTask` function or a Promise-based
    ponyfill if not, naming the result `queueMicroTask`, which should be
    much more familiar to JS dev and is a simpler implementation than what
    `next-tick` provided, we moreover now control.
    
    Its removal also means that now the RxPlayer has no dependency from
    an application perspective, which may eliminates some groups of issues
    applications sometimes have when doing weird things with their
    webpack/vite configs :p
    
    We may still have an issue for Promise implementations which do not
    rely on microtasks (or even event loop events, we shouldn't have an
    issue with those), but I would expect that the very large majority of
    Promise polyfills in use today respect that key part of the spec.
    peaBerberian committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    6443b1d View commit details
    Browse the repository at this point in the history