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

Opt-in to ESM bundle of SDK #5028

Merged
merged 2 commits into from
Jan 22, 2025
Merged

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Jan 21, 2025

Partly closes open-formulieren/open-forms-sdk#76 - Depends on open-formulieren/open-forms-sdk#777

Changes

  • Added a module entrypoint that will be used by modern browsers
  • Kept the fallback for older browsers that don't support modules

I'm not yet updating the documentation for how to embed the SDK until this is out of experimental phase.

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh
    • Ran ./bin/compilemessages_js.sh
  • Dockerfile/scripts

    • Updated the Dockerfile with the necessary scripts from the ./bin folder
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

@sergei-maertens sergei-maertens force-pushed the feature/sdk-76-use-esm-bundle branch 2 times, most recently from 55a07ba to 9880ec4 Compare January 22, 2025 08:14
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.67%. Comparing base (a4d0095) to head (56a5a55).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5028   +/-   ##
=======================================
  Coverage   96.67%   96.67%           
=======================================
  Files         765      765           
  Lines       26125    26131    +6     
  Branches     3405     3407    +2     
=======================================
+ Hits        25256    25262    +6     
  Misses        606      606           
  Partials      263      263           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sergei-maertens sergei-maertens marked this pull request as ready for review January 22, 2025 12:07
… if the browser supports it

Using module type scripts makes it possible to opt into the benefits
of bundle splitting where only code is loaded that will actually be
used.

This sets up a wrapper entrypoint/script gated behind the type=module
feature of browsers so it's not executed by browsers that don't
natively support modules yet. An extra advantage is that we can pass
all the necessary configuration via data attributes and process them
in our script, meaning we don't need inline scripts and CSP nonces
anymore for this.

Finally, the SDK ESM module is added to the preload list since we are
guaranteed that we'll need it, and we avoid a waterfall when loading
the entrypoint and then dynamically importing the SDK bundle - those
can be fetched in parallel.
@sergei-maertens sergei-maertens force-pushed the feature/sdk-76-use-esm-bundle branch from 9880ec4 to 56a5a55 Compare January 22, 2025 12:08
Copy link
Contributor

@robinmolen robinmolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me

@sergei-maertens sergei-maertens merged commit 4a6b8a9 into master Jan 22, 2025
31 of 32 checks passed
@sergei-maertens sergei-maertens deleted the feature/sdk-76-use-esm-bundle branch January 22, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-enable dynamic loading of i18n modules & put our bundle on a diet
2 participants