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

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

Open
treeder opened this issue Jan 24, 2025 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@treeder
Copy link

treeder commented Jan 24, 2025

Describe the solution

Workers can import JSON like this:

import Something from './file.json'

But you can't do that anywhere else.

This works in Chrome and node, etc:

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

But does not work in workers, you get:

Image

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

@treeder treeder added the enhancement New feature or request label Jan 24, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 24, 2025
@edmundhung edmundhung removed this from workers-sdk Jan 27, 2025
@valtlai
Copy link

valtlai commented Jan 28, 2025

I just needed this to use the Fedify ActivityPub server framework on Workers. This one cannot be polyfilled as it’s a syntax feature, so I had to strip the import attributes with a post-install script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants