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

[Loaders] Runtime does not respect import ... with { type: "json" } #12175

Open
A-D-E-A opened this issue Jun 26, 2024 · 1 comment
Open

[Loaders] Runtime does not respect import ... with { type: "json" } #12175

A-D-E-A opened this issue Jun 26, 2024 · 1 comment
Labels
bug Something isn't working transpiler parser || printer

Comments

@A-D-E-A
Copy link
Contributor

A-D-E-A commented Jun 26, 2024

What version of Bun is running?

1.1.17+bb66bba1b

What platform is your computer?

Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 unknown

What steps can reproduce the bug?

Use a test json file with any extension other than "json".
For example, "data.any":

{ "hello": "world" }

Then, write index.ts:

import data from "./data.any" with { type: "json" };
console.log(json);
console.log(typeof data);

What is the expected behavior?

The console should show

{
  hello: "world",
}
object

What do you see instead?

The console shows

/path/to/file/data.any
string

Additional information

It works for other types, such as "toml", "text" or "file". Only "json" (to my knowledge) is affected.

@A-D-E-A A-D-E-A added bug Something isn't working needs triage labels Jun 26, 2024
@paperdave paperdave added bundler Something to do with the bundler and removed needs triage labels Jun 27, 2024
@paperdave paperdave added transpiler parser || printer and removed bundler Something to do with the bundler labels Jul 19, 2024
@paperdave paperdave changed the title [Loaders] Bun does not respect an import with { type: "json" } [Loaders] Runtime does not respect import ... with { type: "json" } Jul 19, 2024
@paperdave
Copy link
Collaborator

recategorizing this as not a bundler bug but a runtime bug. a workaround to this would be to temporarily use bun build --target=bun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working transpiler parser || printer
Projects
None yet
Development

No branches or pull requests

2 participants