Use a single JS entrypoint modeled after Blacklight #1503
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is prep work for #1443, pulled out of #1467.
Prior to this PR, we bundled Geoblacklight's JS separately from the generated app's JS. This was done because we have to manage the registration of all of the stimulus controllers and then call all the initializer functions that make up the GBL core before the app's JS runs, so they are available.
After this PR, Geoblacklight's JS is more extendable & interoperable due to borrowing a paradigm from Blacklight. You can now do:
which is all that's needed to register the controllers and ensure everything is set up. You can also do:
to run arbitrary code after Geoblacklight is set up, just like Blacklight's
onLoad
hook. This hook also fires whether or not you're using Turbo. Individual controllers and modules can still be imported, e.g. if you wanted to subclass them:Because of this, the application now only needs a single unified JS entrypoint, where we import Geoblacklight and then add any other JS we want. The whole thing is bundled into a single file by Vite.