-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: Adopt the inline bootstrap loader #797
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but we should retain support for the old way of loading, since a) removing it would be a major breaking change that requires a non-trivial code rewrite for users b) the old way is still officially valid and supported.
I think a good option would be to define a separate InlineLoaderOptions
type, and have Loader
accept both that and LoaderOptions
. Then fork the logic based on the options object that Loader
is instantiated with.
There's, of course, other ways to go about this, but we should make this change in a non-breaking way, so dropping the old loader entirely isn't an option.
My goal was to make this a non-breaking change. Can you elaborate on the breakage you are seeing?
|
Ah I see, I had thought the libraries specified in One question since I haven't been able to test this manually yes - if a user is still using |
It should be...
That's not how it's intended to function. Gave it a quick test: https://jsfiddle.net/q1xe8fs0/ - google.maps.Map is available as soon as any part of maps JS is loaded. Happy to investigate a sample that demonstrates otherwise. Aside: are there plans to fix the e2e tests (#795) soon? Happy to wait for that if we want to increase confidence. So far my testing has just been the unit tests. |
If I remove If I upgrade after this PR, I would have to explicitly add So existing code that looks like this: const loader = new Loader({
apiKey: "myKey",
libraries: ["places"]
});
loader
.load()
.then((google) => {
new google.maps.Map(document.getElementById("map"), mapOptions);
}); would instead have to look like this: const loader = new Loader({
apiKey: "myKey",
libraries: ["places", "maps"] // or "core"
});
loader
.load()
.then(async (google) => {
await google.maps.importLibrary("maps"); // or core
new google.maps.Map(document.getElementById("map"), mapOptions);
});
I'll try to take a look soon, since I'd like to get this PR merged. Since this is going to change the lib to only use the inline loader script under the hood, can you also take a look at |
That's because the inline bootstrap loader doesn't load anything until the first importLibrary call. That's why this PR includes a call to
Tested manually, this still works.
done |
ok awesome - I didn't catch the |
* Adopt the inline bootstrap loader: https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import and provide an importLibrary() alias 6fe1903
## [1.16.0](v1.15.2...v1.16.0) (2023-06-05) ### Features * Adopt the inline bootstrap loader ([#797](#797)) ([6fe1903](6fe1903)) ### Miscellaneous Chores * Update jest.config.js ([559dc7e](559dc7e)) * Update release.yml ([f77bf1f](f77bf1f)) * Update release.yml ([c578e13](c578e13)) * Update release.yml ([0625600](0625600)) * Update release.yml ([2c02ac8](2c02ac8)) * Update release.yml ([6fae278](6fae278)) * Update release.yml ([e71b478](e71b478)) * Update release.yml ([18386f1](18386f1)) * Update release.yml ([105f3e9](105f3e9)) * Update release.yml ([b8019ac](b8019ac)) * Update release.yml ([3b9f3ac](3b9f3ac)) * Update release.yml ([cbcec6e](cbcec6e))
🎉 This PR is included in version 1.16.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import