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

Support parent-module (npm package) #4324

Closed
birkskyum opened this issue Aug 25, 2023 · 1 comment
Closed

Support parent-module (npm package) #4324

birkskyum opened this issue Aug 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@birkskyum
Copy link
Collaborator

birkskyum commented Aug 25, 2023

parent-module - npm - github

What version of Bun is running?

0.8.1+16b4bf341acc0f4804f0b6bdf5298c180cd00366

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

Example from https://www.npmjs.com/package/parent-module :

// bar.js
import parentModule from 'parent-module';

export default function bar() {
	console.log(parentModule());
	//=> '/Users/<myyser>/<path>/foo.js'
};

// foo.js
import bar from './bar.js';

bar();

bun foo.js

What is the expected behavior?

That it doesn't break and prints the foo.js path:

/Users/<myyser>/<path>/foo.js

What do you see instead?

➜ bun foo.js 
2 | 
3 | export default function parentModule(filePath) {
4 |     const stacks = callsites();
5 | 
6 |     if (!filePath) {
7 |             return stacks[2].getFileName();
             ^
TypeError: undefined is not an object (evaluating 'stacks[2].getFileName')
      at parentModule (/Users/admin/repos/bun-parent-module-test/node_modules/parent-module/index.js:7:9)
      at bar (/Users/admin/repos/bun-parent-module-test/bar.ts:4:13)
      at /Users/admin/repos/bun-parent-module-test/foo.ts:3:0

Additional information

Blocks:

@Jarred-Sumner
Copy link
Collaborator

Fixed in #5802

This will be released in Bun v1.0.3.

If you don't want to wait until then, an hour after this comment was written you should be able to upgrade to the canary build of Bun:

bun upgrade --canary

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

No branches or pull requests

2 participants