privatenumber / pkgroll

📦 Zero-config package bundler for Node.js + TypeScript
MIT License
1.21k stars 29 forks source link

Single quoted in import aren't replaced with double quotes #94

Closed rtritto closed 1 month ago

rtritto commented 1 month ago

Problem

After run yarn pkgroll, the file

// /src/index.mjs
import path from 'node:path'
console.log('sep', path.seph)

is builded with import path having single quoted instead of double quotes.

// /dist/index.mjs
import path from 'node:path';

console.log("sep", path.seph);

Expected behavior

// /dist/index.mjs
import path from "node:path";

console.log("sep", path.seph);

Minimal reproduction URL

https://github.com/rtritto/test-pkgroll/tree/bug-quotes

Version

2.5.0

Node.js version

22.9.0

Package manager

yarn

Operating system

Windows

Bugs are expected to be fixed by those affected by it

Compensating engineering work financially will speed up resolution

privatenumber commented 1 month ago

Sorry, I'm confused—how is this a bug?

rtritto commented 1 month ago

Build contains mixed quotes (' and ").

Source:

// /src/index.ts
import path from 'node:path'
console.log('sep', path.seph)

Dist:

// /dist/index.mjs
- import path from 'node:path'  // current
+ import path from "node:path"  // expected
console.log("sep", path.seph)

The ' in imports should be replaced with " at same way of code below imports.

privatenumber commented 1 month ago

Okay, but why is this a bad thing? Is this breaking your code?

rtritto commented 1 month ago

Okay, but why is this a bad thing? Is this breaking your code?

It's bad because it's mixed, so it breaks for example with a search.

As standards and with other bundle libraries, the " is always used.

privatenumber commented 1 month ago

It's valid JS.

If you have a preference for specific quote styles in your output, I recommend running it through Prettier or ESLint for formatting.

Alternatively, you can use a quote-style agnostic regex search like this: (["']).+?\1.