Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cd52238
feat!: implement updated and simplified API
usefulthink Sep 10, 2025
9cb6216
chore: update bundlewatch workflow
usefulthink Sep 10, 2025
f377392
chore: update typedoc config
usefulthink Sep 11, 2025
249d1e9
chore: revert change in codeql.yml workflow
usefulthink Sep 11, 2025
e903388
chore: reorganize npm scripts
usefulthink Sep 11, 2025
8ada50e
chore: consistent license comments
usefulthink Sep 11, 2025
f691bb1
refactor: reformat messages, remove dev-switch for dev-only messages
usefulthink Sep 11, 2025
e345b83
chore: update build-config
usefulthink Sep 11, 2025
859f634
fix: add extra implementation signature
usefulthink Sep 11, 2025
17b6b04
fix: add full stub implementation of the 1.x interface
usefulthink Sep 16, 2025
ba82687
docs: add migration instructions
usefulthink Sep 16, 2025
a8f05bb
fix: corrected exported types and jsdoc
usefulthink Sep 16, 2025
524d031
docs: update MIGRATION.md
usefulthink Sep 16, 2025
d316777
refactor: rename "bootstrap" to "installImportLibrary"
usefulthink Sep 16, 2025
bbf18ab
chore: copyright year
usefulthink Sep 16, 2025
47a6fd3
chore: copyright year
usefulthink Sep 16, 2025
37b7f8e
chore: license-header first
usefulthink Sep 16, 2025
7429dde
fix: libraries and mapIds always specified as string[]
usefulthink Sep 16, 2025
c86821d
fix: make Loader stub fail hard
usefulthink Sep 17, 2025
7064109
fix: add docs for bootstrap function
usefulthink Sep 22, 2025
98e5019
fix: remove cooperative loading, rework dev-messages
usefulthink Sep 22, 2025
323800f
docs: update readme
usefulthink Sep 22, 2025
26b24f5
docs: update readme
usefulthink Sep 22, 2025
19d2f68
docs: update readme
usefulthink Sep 22, 2025
ad7aa17
fix: eslint issues
usefulthink Sep 22, 2025
43c8105
chore: remove generated documentation
usefulthink Sep 25, 2025
4372b4a
chore: remove builds for direct browser-usage
usefulthink Sep 25, 2025
9570c86
fix: move bootsrapping to setOptions, improve error-messages
usefulthink Sep 25, 2025
432a9a8
docs: typos in migration.md
usefulthink Sep 25, 2025
2637933
chore: remove example
usefulthink Sep 25, 2025
4261075
docs: update readme
usefulthink Sep 25, 2025
9b31130
docs: update readme
usefulthink Sep 25, 2025
92049aa
chore: npm update
usefulthink Sep 25, 2025
c11fd94
docs: update readme
usefulthink Sep 25, 2025
8d15fc3
docs: update readme
usefulthink Sep 25, 2025
4666330
docs: update readme
usefulthink Sep 25, 2025
996bdcd
chore: docs, formatting, linting, and minor changes
usefulthink Sep 26, 2025
a4687ac
Merge remote-tracking branch 'upstream/main' into v2.0-dev
usefulthink Sep 26, 2025
fa2a228
chore: fix package-lock.json
usefulthink Sep 26, 2025
fc9e517
chore: update bundlewatch config
usefulthink Sep 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

48 changes: 0 additions & 48 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/bundlewatch.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": [
{
"path": "dist/index.*.js"
"path": "dist/index*.js"
}
],
"ci": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bundlewatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ jobs:

- uses: jackyef/bundlewatch-gh-action@b9753bc9b3ea458ff21069eaf6206e01e046f0b5
with:
build-script: npm run prepare
build-script: npm run prepack
bundlewatch-github-token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
bundlewatch-config: .github/bundlewatch.config.json
50 changes: 0 additions & 50 deletions .github/workflows/docs.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/e2e.yml

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/bootstrap.js
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
bracketSpacing: false,
singleQuote: true,
trailingComma: "all",
arrowParens: "avoid",
};
1 change: 0 additions & 1 deletion .releaserc

This file was deleted.

136 changes: 136 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Migration from v1.x to v2.x

This guide provides instructions for migrating from version 1.x of
`@googlemaps/js-api-loader` to version 2.x.

## Core Concepts

The primary change in v2.x is the move from a class-based (`Loader`) to a
functional approach. This simplifies the API and aligns it with
[the recommended way](https://developers.google.com/maps/documentation/javascript/load-maps-js-api)
to load the Google Maps JavaScript API.

- **v1.x:** You would create an instance of the `Loader` class with your
configuration and then call methods like `load()` or `importLibrary()` on
that instance.
- **v2.x:** You now use two standalone functions: `setOptions()` to
configure the API loader and `importLibrary()` to load specific libraries.

Generally, the Loader constructor can be replaced with a call to `setOptions()`,
and the different methods used to actually load the API are all replaced
with calls to `importLibrary()`.

## Key Changes

| Feature | v1.x (`Loader` class) | v2.x (functions) |
| :--------------------- | :----------------------------------- | :-------------------------------------- |
| **Initialization** | `new Loader({ apiKey: '...', ... })` | `setOptions({ key: '...', ... })` |
| **Loading Libraries** | `loader.importLibrary('maps')` | `importLibrary('maps')` |
| **Legacy Loading** | `loader.load()` | Removed. Use `importLibrary()` instead. |
| **API Key Parameters** | `apiKey` | `key` |
| | `version` | `v` |

## Typical Use Cases Compared

### v1.x

The most common use case of the 1.x versions was loading a predefined set of
libraries explicitly, and then using the global `google.maps` namespace.

```javascript
import { Loader } from "@googlemaps/js-api-loader";

const loader = new Loader({
apiKey: "YOUR_API_KEY",
version: "weekly",
libraries: ["maps", "places"],
});

// a) using load() with promises
loader.load().then(() => initMap());

// b) using load() with async/await:
await loader.load();
initMap();

// c) using callback
loader.loadCallback(() => {
initMap();
});

function initMap() {
// use the global google.maps namespace once loading is complete
const map = new google.maps.Map(document.getElementById("map"), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8,
});
}
```

### v2.x

The typical use case from versions 2.0 onwards is to use `importLibrary` to get
access to the classes and features needed from the Maps JavaScript API.

```javascript
import { setOptions, importLibrary } from "@googlemaps/js-api-loader";

setOptions({
key: "YOUR_API_KEY",
v: "weekly",
});

try {
const { Map } = await importLibrary("maps");
// Use the maps library
const map = new Map(document.getElementById("map"), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8,
});
} catch (e) {
// do something
}
```

However, all the examples from the 1.x version can also be written based
on the 2.x version, since – besides returning the library object – the
`importLibrary()` function also populates the global `google.maps` namespace.

<details>
<summary>Imitating the 1.x API</summary>

```javascript
import { setOptions, importLibrary } from "@googlemaps/js-api-loader";

setOptions({
key: "YOUR_API_KEY",
v: "weekly",

// Libraries can still be specified in `setOptions`. This makes sure that
// all libraries are available when the importLibrary promise is resolved.
libraries: ["maps", "places"],
});

// The examples from above, rewritten with v2.0:
//
// a) using promises (note: which library is imported in these cases makes
// little difference: the libraries were specified in `setOptions` and
// we're not using the returned value)
importLibrary("core").then(() => initMap());

// b) using load() with async/await:
await importLibrary("core");
initMap();

// c) using a callback – this is identical to a)

function initMap() {
// Use the global google.maps namespace once loading is complete
const map = new google.maps.Map(document.getElementById("map"), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8,
});
}
```

</details>
Loading
Loading