11ty / eleventy-dependency-tree-esm

MIT License
3 stars 2 forks source link

Error parsing files using import attributes #2

Open zachleat opened 7 months ago

zachleat commented 7 months ago

Notably, this feature is not yet stable in Node.js: https://nodejs.org/docs/latest/api/esm.html#import-attributes

import data from './data.json' with { type: 'json' };

Upstream issue: https://github.com/acornjs/acorn/issues/1289

@what1s1ove said it best: https://github.com/11ty/eleventy/issues/3128#issuecomment-1872516498

The easiest workaround is to use require in ESM as @uncenter notes here https://github.com/11ty/eleventy/issues/3128#issuecomment-1878745864:

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
what1s1ove commented 3 weeks ago

Hey @zachleat ! I guess now we can resolve it 🙂 https://github.com/acornjs/acorn/commit/3c6a5a98e8c6dcefef391e6114cc7e64657979d3

captainbrosset commented 3 weeks ago

This issue has preventing us from testing the web-features-explorer site locally for some time, so I'm very happy to see Acorn get support for import attributes! Has eleventy been updated to incorporate this upstream fix already?