mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix(bundler): add missing semicolons in minified bun module imports (#26372)
## Summary
- Fix missing semicolons in minified output when using both default and
named imports from `"bun"` module
- The issue occurred in `printInternalBunImport` when transitioning
between star_name, default_name, and items sections without flushing
pending semicolons
## Test plan
- Added regression tests in `test/regression/issue/26371.test.ts`
covering:
- Default + named imports (`import bun, { embeddedFiles } from "bun"`)
- Namespace + named imports (`import * as bun from "bun"; import {
embeddedFiles } from "bun"`)
- Namespace + default + named imports combination
- Verified test fails with `USE_SYSTEM_BUN=1` (reproduces bug)
- Verified test passes with `bun bd test` (fix works)
Fixes #26371
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1109,15 +1109,15 @@ describe("bundler", () => {
|
||||
"/entry.js": /* js */ `
|
||||
// Test all equality operators with typeof undefined
|
||||
console.log(typeof x !== 'undefined');
|
||||
console.log(typeof x != 'undefined');
|
||||
console.log(typeof x != 'undefined');
|
||||
console.log('undefined' !== typeof x);
|
||||
console.log('undefined' != typeof x);
|
||||
|
||||
|
||||
console.log(typeof x === 'undefined');
|
||||
console.log(typeof x == 'undefined');
|
||||
console.log('undefined' === typeof x);
|
||||
console.log('undefined' == typeof x);
|
||||
|
||||
|
||||
// These should not be optimized
|
||||
console.log(typeof x === 'string');
|
||||
console.log(x === 'undefined');
|
||||
@@ -1135,4 +1135,61 @@ describe("bundler", () => {
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
// https://github.com/oven-sh/bun/issues/26371
|
||||
// Minified bundler output missing semicolon between statements when
|
||||
// using both default and named imports from "bun" module
|
||||
itBundled("minify/BunImportSemicolonInsertion", {
|
||||
files: {
|
||||
"/entry.js": /* js */ `
|
||||
import bun, { embeddedFiles } from "bun"
|
||||
console.log(typeof embeddedFiles)
|
||||
console.log(typeof bun.argv)
|
||||
`,
|
||||
},
|
||||
minifySyntax: true,
|
||||
minifyWhitespace: true,
|
||||
minifyIdentifiers: true,
|
||||
target: "bun",
|
||||
run: {
|
||||
stdout: "object\nobject",
|
||||
},
|
||||
});
|
||||
|
||||
itBundled("minify/BunImportNamespaceAndNamed", {
|
||||
files: {
|
||||
"/entry.js": /* js */ `
|
||||
import * as bun from "bun"
|
||||
import { embeddedFiles } from "bun"
|
||||
console.log(typeof embeddedFiles)
|
||||
console.log(typeof bun.argv)
|
||||
`,
|
||||
},
|
||||
minifySyntax: true,
|
||||
minifyWhitespace: true,
|
||||
minifyIdentifiers: true,
|
||||
target: "bun",
|
||||
run: {
|
||||
stdout: "object\nobject",
|
||||
},
|
||||
});
|
||||
|
||||
itBundled("minify/BunImportDefaultNamespaceAndNamed", {
|
||||
files: {
|
||||
"/entry.js": /* js */ `
|
||||
import bun, * as bunNs from "bun"
|
||||
import { embeddedFiles } from "bun"
|
||||
console.log(typeof embeddedFiles)
|
||||
console.log(typeof bun.argv)
|
||||
console.log(typeof bunNs.argv)
|
||||
`,
|
||||
},
|
||||
minifySyntax: true,
|
||||
minifyWhitespace: true,
|
||||
minifyIdentifiers: true,
|
||||
target: "bun",
|
||||
run: {
|
||||
stdout: "object\nobject\nobject",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user