Open ccouzens opened 5 months ago
I have just ran into this issue, both within the browser via esm.sh distribution, and within a vanilla Node 22.11.0 environment.
It seems like this import with module attributes results in all of the MDN data getting nested within a default
property, which breaks everything expecting it to be available on the top-level object.
import * as compatData from "@mdn/browser-compat-data" with {type: "json"};
Hello,
Thank you for your project.
I've found that when using
browsersWithSupportForFeatures
I get an error when using esmodules, but not when using commonjs. I've attached 2 test files below.example.js
andexample.mjs
are effectively the same except for.js
uses commonjs and.mjs
uses esmodules. The path to the code imported isnode_modules/browserslist-generator/dist/cjs/index.cjs
for the.js
andnode_modules/browserslist-generator/dist/esm/index.js
for the.mjs
.I've reproduced this on node
v18.16.0
andv20.12.2
. My browserslist-generator isexample.js
example.mjs
I am happy to help solve this, although it may be a few days before I get round to it.