Open trygve-lie opened 3 months ago
I import the package like this, so I can build and preview my Nuxt project :
import * as MarkerClustererPackage from '@googlemaps/markerclusterer';
let markerCluster: MarkerClustererPackage.MarkerClusterer = new MarkerClustererPackage.MarkerClusterer({...});
Is your feature request related to a problem? Please describe.
This module exports a UMD module in the
main
field and it provides an ESM version through themodule
field in package.json. Node.js supports mixing CJS and ESM modules these days but this setup does not go well with using this module in node.js.The
module
field are only used by bundlers. Its not supported by node.js. So when trying to use this module with node.js without bundling it will try to load the file references in themain
field which is a UMD file that node.js does not understand either.Iow; how the ESM version is exposed in this module is wrong according to node.js.
My problem with this is that this breaks SSR of Lit web components (I am using this module in a Lit web component) and it also breaks SSR in Nuxt it seems like. Using this module with Lit SSR is possible if it only where exported correctly.
Describe the solution you'd like
Set package.json to
type: module
and export the ESM as recommended by node.js: https://nodejs.org/api/packages.html#dual-commonjses-module-packagesBasically add:
Describe alternatives you've considered
I don't think there is an alternative way of doing this.