Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Uncaught SyntaxError: import declarations may only appear at top level of a module #57

Open
CCRDude opened this issue Sep 13, 2024 · 0 comments

Comments

@CCRDude
Copy link

CCRDude commented Sep 13, 2024

Situation

Testing demo.

Expected

Console output about missed or cached tiles.

Experienced

Firefox 130.0 (64-bit) (macOS)

Uncaught SyntaxError: import declarations may only appear at top level of a module
L.TileLayer.PouchDBCached.js:3:1

Safari Version 17.6 (18618.3.11.11.7, 18618)

SyntaxError: Unexpected identifier 'PouchDB'. import call expects one or two arguments.
L.TileLayer.PouchDBCached.js:3

Chrome Version 128.0.6613.138 (Official Build) (x86_64)

Uncaught SyntaxError: Cannot use import statement outside a module
L.TileLayer.PouchDBCached.js:3

Attempted Workarounds

script type of TileLayer.PouchDBCached.js

Changed in a local copy:

	<script src="L.TileLayer.PouchDBCached.js"></script>

to

	<script type="module" src="L.TileLayer.PouchDBCached.js"></script>

Error is now:

Firefox

Uncaught TypeError: The specifier “pouchdb” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.

Safari

SyntaxError: Unexpected identifier 'PouchDB'. import call expects one or two arguments.

Chrome

Uncaught SyntaxError: Cannot use import statement outside a module (at L.TileLayer.PouchDBCached.js:3:1)

script type of TileLayer.PouchDBCached.js and pouchdb.js

Same as above.

Use tested versions

Replaced demo versions with:

			<script src="https://unpkg.com/leaflet@^1.0.0/dist/leaflet-src.js"></script>
			<script src="https://unpkg.com/pouchdb@^5.2.0/dist/pouchdb.js"></script>
			<script src="https://unpkg.com/leaflet.tilelayer.pouchdbcached@latest/L.TileLayer.PouchDBCached.js"></script>

This works.

Replaced leaflet 1.0 with leaflet 1.4. Still works.
Replaced leaflet 1.0 with leaflet 1.9.4 (latest). Still works.

Replaced L.TileLayer.PouchDBCaches.js with new version from GitHub - fails.
Replaced pouchdb.js from demo (which actually is 5.4.5) with latest 9.0.0 - fails.

Maybe we need information which pouchdb.js version works with the latest version of L.TileLayer.PouchDBCaches.js ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant