Skip to content
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

Allow import file from "./file.json" with {type: "json"} (i.e. import attributes) #5470

Open
cedx opened this issue Nov 1, 2024 · 0 comments

Comments

@cedx
Copy link

cedx commented Nov 1, 2024

CoffeeScript supports import assertions:

import file from "./file.json" assert {type: "json"}

But the spec was replaced by import attributes (i.e. the assert keyword has been rewritten as with):

import file from "./file.json" with {type: "json"}

The new spec is currently at stage 3, and recently marked as stable in Node.js.
https://nodejs.org/api/esm.html#import-attributes

It would be cool if CoffeeScript supported the new syntax.
The alternative is pretty cumbersome:

import {readFileSync} from "node:fs"
import {join} from "node:path"
file = JSON.parse readFileSync join(import.meta.dirname, "./file.json"), "utf8"

Expected Behavior

No error when using import attributes.

Current Behavior

[...]\src\cli.coffee:4:35: error: reserved word 'with'
import pkg from "../package.json" with {type: "json"}

Environment

  • CoffeeScript version: 2.7.0
  • Node.js version: 23.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant