bun icon indicating copy to clipboard operation
bun copied to clipboard

--minify breaks source maps for Node

Open alxivnov opened this issue 1 year ago • 1 comments

What version of Bun is running?

1.1.2+c8d072c2a

What platform is your computer?

Linux 6.6.16-linuxkit aarch64 unknown

What steps can reproduce the bug?

Bundle a file which calls a method with console.trace() from imported module with bun build --sourcemap=inline --target=node --outfile ./bundle.mjs --minify ./index.js and then run it with node --enable-source-maps bundle.mjs.

  • index.js
/**
 * Comment line 1
 * Comment line 2
 * Comment line 3
 */

const error = require('./error.js');

error.trace();
  • error.js
/**
 * Error generater
 */
module.exports = {
	/**
	 * Throws error
	 */
	error() {
		throw new Error();
	},
	/**
	 * Prints stack trace
	 */
	trace() {
		console.trace('trace');
	},
}

What is the expected behavior?

Stack trace includes correct line number for trace() call: at Object.trace (/usr/src/app/error.js:15:11).

What do you see instead?

Stack trace includes incorrect line number for trace() call: at <anonymous> (/usr/src/app/error.js:4:8).

Additional information

Bundling works fine without --minify.

Снимок экрана 2024-04-07 в 22 16 57

alxivnov avatar Apr 07 '24 19:04 alxivnov

Bun doesn't support its own source maps.

Снимок экрана 2024-04-07 в 22 47 24

alxivnov avatar Apr 07 '24 19:04 alxivnov

Duplicate of #7427

Electroid avatar Apr 08 '24 16:04 Electroid