tl;dr using require("protomaps-leaflet") returns the string "/static/media/index.e620cdf0cd3caacfc7b7.cjs" instead of an object of the package exports.
I'm currently developing a package that combines the use of vector map tiles for leaflet with the capability to store them in cache for offline use. For my package to work, I have imported a number of methods from Protomaps-leaflet. One of the methods I need to sourcesToViews() from views.ts. Importing this works fine; no errors from TypeScript or ESlint. Once I've compiled my package using npx tsc, linked it for testing, and imported it in my React.js app to test, it crashes. The cause being require("protomaps-leaflet") returns the string "/static/media/index.e620cdf0cd3caacfc7b7.cjs" instead of an object with all the methods like sourcesToViews(). Am I compiling my package incorrectly or importing the methods from "protomaps-leaflet" incorrectly?
I am aware that the main reason for empty imports/requires is due to circular imports but I have triple checked thisand used plugins to check for me and I don't have any circular imports.
tl;dr using
require("protomaps-leaflet")
returns the string"/static/media/index.e620cdf0cd3caacfc7b7.cjs"
instead of an object of the package exports.I'm currently developing a package that combines the use of vector map tiles for leaflet with the capability to store them in cache for offline use. For my package to work, I have imported a number of methods from Protomaps-leaflet. One of the methods I need to
sourcesToViews()
fromviews.ts
. Importing this works fine; no errors from TypeScript or ESlint. Once I've compiled my package usingnpx tsc
, linked it for testing, and imported it in my React.js app to test, it crashes. The cause beingrequire("protomaps-leaflet")
returns the string"/static/media/index.e620cdf0cd3caacfc7b7.cjs"
instead of an object with all the methods likesourcesToViews()
. Am I compiling my package incorrectly or importing the methods from "protomaps-leaflet" incorrectly?I am aware that the main reason for empty imports/requires is due to circular imports but I have triple checked thisand used plugins to check for me and I don't have any circular imports.
Here's my
tsconfig.json
from my package:And here is my
package.json
:And here is how I have imported
protomaps-leaflet
: