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

bundler: importing TOML objects with numeric keys fails #17926

Open
DonIsaac opened this issue Mar 6, 2025 · 1 comment · May be fixed by #17886
Open

bundler: importing TOML objects with numeric keys fails #17926

DonIsaac opened this issue Mar 6, 2025 · 1 comment · May be fixed by #17886
Assignees
Labels
bug Something isn't working bundler Something to do with the bundler

Comments

@DonIsaac
Copy link
Contributor

DonIsaac commented Mar 6, 2025

What version of Bun is running?

1.2.5-canary.70+8a177f6c8

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

Create these foo.toml and foo.json

0="bar"
{
  "0": "bar"
}

Then try to import them.

import foo from "./foo.json"; // or foo.toml

What is the expected behavior?

foo should have a value of { '0': 'bar' }

What do you see instead?

When importing foo.json:

> import foo from './foo.json'
226 |                         };
227 |                     }
228 |                     debuglog((`Importing: ${$.blueBright+moduleID+$.reset}`));
229 |                     try {
230 |                         // eslint-disable-next-line @typescript-eslint/no-unsafe-return
231 |                         return import.meta.require(moduleID);
                                                 ^
SyntaxError: JSON Parse error: Property name must be a string literal
      at require (/private/tmp/bunx-501-bun-repl@latest/node_modules/bun-repl/src/repl.ts:231:44)

> 

Importing foo.toml works in release builds, but fails with an assertion in debug and safe builds.

Additional information

No response

@DonIsaac DonIsaac added bug Something isn't working bundler Something to do with the bundler labels Mar 6, 2025
@DonIsaac DonIsaac self-assigned this Mar 6, 2025
@DonIsaac DonIsaac linked a pull request Mar 6, 2025 that will close this issue
@Jarred-Sumner Jarred-Sumner changed the title bundler: importing JSON, TOML objects with numeric keys fails bundler: importing TOML objects with numeric keys fails Mar 6, 2025
@Jarred-Sumner
Copy link
Collaborator

Note that this doesn't apply to JSON unless it's JSONC (specifically tsconfig.json, package.json)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler Something to do with the bundler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants