cloudflare / cloudflare/workerd

🚀 Feature Request: support import with type syntax (standard now)

Open
#5,265 14 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

### Describe the solution

Workers can import JSON like this:

```js
import Something from './file.json'
```

But you can't do that anywhere else.

This works in Chrome, Node, etc:

```js
import Something from './file.json' with {type: "json"}
```

But does not work in workers, you get:

![Image](https://github.com/user-attachments/assets/1694d150-a5a3-4b05-b695-02822fa3ff8f)

It would be nice to have workers support "with type" so it can be used in various places without having to change it specifically for workers.

Spec: https://github.com/tc39/proposal-import-attributes

Supported almost everywhere: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.