-
-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import attributes not yet supported (Error thrown from acorn
dependency)
#3128
Comments
I'm seeing the same issue on MacOS.
|
I had this issue when I tried to import a let packageJson = JSON.parse(
(await readFile(new URL(`package.json`, import.meta.url))).toString(),
) But definitely want to return to Import attributes soon 🙏 |
@what1s1ove You may need to import like so import eleventyPackage from "@11ty/eleventy/package.json" with { type: 'json' }; That's what solved the JSON import for me. In your case I guess you'd do import packageJson from "./package.json" with { type: 'json' }; The Edit: Formatting |
Ah, I’m using Node v20 for which |
The error seems unrelated to the I get the error as well yet the building works just fine. 🤷 |
Hello guys! acornjs/acorn#1228 (comment) (the issue is about decorators, but this proposal is also on the stage 3 right now)
|
Thanks @what1s1ove; your solution earlier in this thread works, so I’ll use that for now. Thanks for the background info 🙏 |
Perhaps you are using a different syntax that is not part of ECMAScript (it is at stage 3 or below).
As I understand, acorn is used only in development server. If you use |
Interesting, thanks for the background info! I'm only using it to get the 11ty version used for building the site so I guess I can work around it somehow until it is fixed upstream. |
You can make a import { createRequire } from "node:module";
const require = createRequire(import.meta.url); And then you can just import JSON data using it like so: const data = require("data.json"); |
I’ve been getting this issue, too. I’m using the What I don’t understand is: Why does it only error on |
acorn
dependency when serving site using v3.0.0 canaryacorn
dependency)
Going to track this one here to circle back when Import Attributes are stable in Node.js (and included a summary of this thread as well!): 11ty/eleventy-dependency-tree-esm#2 Thanks y’all! |
Improved the error messaging here in 3.0.0-alpha.14 after looking at an issue from @bobmonsour’s 11ty bundle (https://github.com/bobmonsour/11tybundle.dev/blob/839b73059e3efce10369829125d8ebc5dba89fdc/src/_data/bundledata.js) (cc @uncenter too):
The awkward part of this issue is that Node.js will parse these fine (with an experimental warning) but the |
Operating system
macOS Sonoma 14.2
Eleventy
3.0.0-alpha.2
Describe the bug
Hello from a courageous canary tester! 👋
I have upgraded to
3.0.0-alpha.2
, and converted my project from CommonJS to ESM. The site builds without error (npx eleventy
), but when serving (npx eleventy --serve
) the following error is thrown:I am using 11ty’s default dev server.
Branch: https://github.com/paulrobertlloyd/paulrobertlloyd-v4/tree/eleventy-esm
Upgrade commit: paulrobertlloyd/paulrobertlloyd-v4@ba4cd64
Reproduction steps
No response
Expected behavior
No response
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: