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

Support async functions for loading the utils script #1838

Commits on Oct 4, 2024

  1. Ensure loadUtils() errors don't go unhandled

    This makes sure any errors/rejections that occur when trying to load the utilities script asynchronously can be handled by developers of this package. Previously, you'd wind up with "unhandled promise rejection" errors in your console no matter what you did. The previous behavior also prevented testing async loading in Jest, which considers these async errors to be test failures.
    
    This also makes sure that the actual error gets passed through to the `itiInstance.promise` property so developers can get access to it, and better understand what the issue was. Previously, you'd just get the promise rejected with `undefined`.
    
    Finally, this changes the error message in builds that have the utilties built in. The previous method of producing an error caused *other* things in the library to fail (or really, never complete) and was not especially informative. There is now a more detailed message that shows up as an actual failure in all the right places instead of leaving some stuff hanging.
    Mr0grog committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    6d4e8fb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7a13ace View commit details
    Browse the repository at this point in the history
  3. Add support for utilsScript option as a function

    The argument to `loadUtils` and the value of the `utilsScript` option can now be a function that returns a promise for the utils module object instead of just a string to load them from. This makes it easier to build separate bundles for utils when using bundles like Webpack, Parcel, Vite, etc. as well as providing more flexible options for mocking or loading alternative versions of utils.
    
    Fixes jackocnr#1816.
    Mr0grog committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    8d54620 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cafc31a View commit details
    Browse the repository at this point in the history
  5. Port relevant tests to Jest

    Mr0grog committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    954b053 View commit details
    Browse the repository at this point in the history