Closed kyoshino closed 3 weeks ago
Hey @kyoshino thanks for the feedback and detailed trace. I'll try to check how I can fix the import that I think may be faulty in the caching logic. I'll get back to you soon!
Hey again @kyoshino , would you be ok to test locally this bundled version? It's an npm pack
output so it should work with a regular npm install ./path/to/maptiler-sdk-2.2.2.tgz
I know it's not ideal, but I'll be off by the end of the week and this is just much faster to iterate. Also locally on a sample project, I do not have the same issue as you have, so I suppose it depends on the bundler of the end project and its configuration, which makes it hard to reproduce. If this works on your end, I'll push the fix to NPM tomorrow.
Just installed maptiler-sdk-2.2.2.tgz
and I’ve got the same error with a different trace:
Named export 'AJAXError' not found. The requested module 'maplibre-gl' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'maplibre-gl';
const { AJAXError, AttributionControl: AttributionControlMLGL, BoxZoomHandler: BoxZoomHandlerMLGL, CanvasSource: CanvasSourceMLGL, CooperativeGesturesHandler: CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl: FullscreenControlMLGL, GeoJSONSource: GeoJSONSourceMLGL, GeolocateControl: GeolocateControlMLGL, Hash, ImageSource: ImageSourceMLGL, KeyboardHandler: KeyboardHandlerMLGL, LngLat, LngLatBounds, LogoControl: LogoControlMLGL, Map: MapMLGL, MapMouseEvent: MapMouseEventMLGL, MapTouchEvent: MapTouchEventMLGL, MapWheelEvent: MapWheelEventMLGL, Marker: MarkerMLGL, MercatorCoordinate, NavigationControl: NavigationControlMLGL, Point, Popup: PopupMLGL, RasterDEMTileSource: RasterDEMTileSourceMLGL, RasterTileSource: RasterTileSourceMLGL, ScaleControl: ScaleControlMLGL, ScrollZoomHandler: ScrollZoomHandlerMLGL, Style: StyleMLGL, TerrainControl: TerrainControlMLGL, TwoFingersTouchPitchHandler: TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource: VectorTileSourceMLGL, VideoSource: VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config: configMLGL, getVersion: getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getWorkerCount, getWorkerUrl, importScriptInWorkers, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl } = pkg;
file:///Users/Kohei/Sites/PROJECT/node_modules/.pnpm/@maptiler+sdk@file+maptiler-sdk-2.2.2.tgz/node_modules/@maptiler/sdk/dist/maptiler-sdk.mjs:2
export { AJAXError, AttributionControl as AttributionControlMLGL, BoxZoomHandler as BoxZoomHandlerMLGL, CanvasSource as CanvasSourceMLGL, CooperativeGesturesHandler as CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl as FullscreenControlMLGL, GeoJSONSource as GeoJSONSourceMLGL, GeolocateControl as GeolocateControlMLGL, Hash, ImageSource as ImageSourceMLGL, KeyboardHandler as KeyboardHandlerMLGL, LngLat, LngLatBounds, LogoControl as LogoControlMLGL, Map as MapMLGL, MapMouseEvent as MapMouseEventMLGL, MapTouchEvent as MapTouchEventMLGL, MapWheelEvent as MapWheelEventMLGL, Marker as MarkerMLGL, MercatorCoordinate, NavigationControl as NavigationControlMLGL, Point, Popup as PopupMLGL, RasterDEMTileSource as RasterDEMTileSourceMLGL, RasterTileSource as RasterTileSourceMLGL, ScaleControl as ScaleControlMLGL, ScrollZoomHandler as ScrollZoomHandlerMLGL, Style as StyleMLGL, TerrainControl as TerrainControlMLGL, TwoFingersTouchPitchHandler as TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource as VectorTileSourceMLGL, VideoSource as VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config as configMLGL, getVersion as getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getWorkerCount, getWorkerUrl, importScriptInWorkers, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl } from 'maplibre-gl';
^^^^^^^^^
SyntaxError: Named export 'AJAXError' not found. The requested module 'maplibre-gl' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'maplibre-gl';
const { AJAXError, AttributionControl: AttributionControlMLGL, BoxZoomHandler: BoxZoomHandlerMLGL, CanvasSource: CanvasSourceMLGL, CooperativeGesturesHandler: CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl: FullscreenControlMLGL, GeoJSONSource: GeoJSONSourceMLGL, GeolocateControl: GeolocateControlMLGL, Hash, ImageSource: ImageSourceMLGL, KeyboardHandler: KeyboardHandlerMLGL, LngLat, LngLatBounds, LogoControl: LogoControlMLGL, Map: MapMLGL, MapMouseEvent: MapMouseEventMLGL, MapTouchEvent: MapTouchEventMLGL, MapWheelEvent: MapWheelEventMLGL, Marker: MarkerMLGL, MercatorCoordinate, NavigationControl: NavigationControlMLGL, Point, Popup: PopupMLGL, RasterDEMTileSource: RasterDEMTileSourceMLGL, RasterTileSource: RasterTileSourceMLGL, ScaleControl: ScaleControlMLGL, ScrollZoomHandler: ScrollZoomHandlerMLGL, Style: StyleMLGL, TerrainControl: TerrainControlMLGL, TwoFingersTouchPitchHandler: TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource: VectorTileSourceMLGL, VideoSource: VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config: configMLGL, getVersion: getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getWorkerCount, getWorkerUrl, importScriptInWorkers, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async nodeImport (file:///Users/Kohei/Sites/PROJECT/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10_sass@1.77.8/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:53536:15)
at async ssrImport (file:///Users/Kohei/Sites/PROJECT/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10_sass@1.77.8/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:53392:16)
at async eval (/Users/Kohei/Sites/PROJECT/src/lib/components/map.svelte:7:31)
at async instantiateModule (file:///Users/Kohei/Sites/PROJECT/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10_sass@1.77.8/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:53451:5
@jonathanlurie PR sent: https://github.com/maptiler/maptiler-sdk-js/pull/100
Thanks @kyoshino for the effort! I wrote some details as per why PR https://github.com/maptiler/maptiler-sdk-js/pull/100 does not fully work in this case. I have a few things to test on that front.
Hello @kyoshino , I made pretty big changes that should address the different issues we have with export and import. If you feel like testing it, here is a version: maptiler-sdk-2.2.2.tgz
It's not on NPM yet as I would like it to be tested by a colleague beforehand. I made quite a lot of changes:
export type LngLat = InstanceType<typeof LngLat>;
If you have a chance to try the archive above, please let me know if it addresses the issue you were having with the previous versions.
In case you want to check what has changed in this, it corresponds to what you can find on this branch: https://github.com/maptiler/maptiler-sdk-js/tree/RD-293
Just tested it and confirmed the error was gone!
Great! Thanks for the help @kyoshino !
Is this fix available on npm? I was using version 2.2.1 and facing this issue. Thanks.
I am using nuxt 3.12.2 and this issue only occurs when ssr: true.
Hello @YuvrajHereTL , have you tested with the fix (archive) from above? I haven't pushed it on NPM yet because I would like a colleague of mine to test it more.
Hi @jonathanlurie, sorry for the late reply, I tested it and its working for me, Is there any estimated date of release for this version?
great to hear @YuvrajHereTL ! I am currently off, but I'll try to make a release this week. I'll post an update here.
Hey @jonathanlurie , Any updates on this?
Hello @YuvrajHereTL @kyoshino I just pushed this version on NPM https://www.npmjs.com/package/@maptiler/sdk
MapTiler SDK JS v2.2.1 (https://github.com/maptiler/maptiler-sdk-js/pull/98) reintroduced the same regression as https://github.com/maptiler/maptiler-sdk-js/issues/78. I have a SvelteKit project, and a minimum
import
can reproduce the issue that leads to a 500 Internal Error.Code
Map.svelte
:jsconfig.json
:Error message