oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.46k stars 2.71k forks source link

support `Module._pathCache` #13627

Open cirospaciari opened 1 month ago

cirospaciari commented 1 month ago

What version of Bun is running?

1.1.26+0a37423ba

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

import * as Module from "node:module";
console.log(Module._pathCache); // undefined in bun 

node.js output:

[Object: null prototype] {
  '/Users/cirospaciari/Repos/bun/test.mjs\x00': '/Users/cirospaciari/Repos/bun/test.mjs'
}

What is the expected behavior?

Module._pathCache should be defined like in node.js:

/** @type {Record<string, string>} */
Module._pathCache = { __proto__: null };

What do you see instead?

undefined

Additional information

This would improve compatibility with: tailwindcss-intellisense https://github.com/tailwindlabs/tailwindcss-intellisense/issues/1021 Nuxt https://github.com/oven-sh/bun/issues/3771

Node.js code: https://github.com/nodejs/node/blob/5a22d8e0134e9f161071e5b67922be1576f8db16/lib/internal/modules/cjs/loader.js#L310

CarlosEduR commented 1 month ago

interesting one!