You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The specific issue in memoizee is due to how Bun determines whether a module imported via require is a CommonJS module or an ES module. Currently, if you require a .js file that either is empty or contains "use strict" (as is the case for lib/registered-extensions.js), Node will consider it a CommonJS module and Bun's heuristics will decide it's an ES module. This makes a difference because CommonJS modules imported via require aren't frozen or sealed, but ES modules imported via require are. Therefore, in this case, Node will let you add properties to the module object and Bun won't. (The behavior differs slightly if you import a module via import. In that case, Bun and Node will treat an ES module as frozen and sealed and a CommonJS module as sealed but not frozen. This detail isn't relevant to this issue, though.)
Ideally, Bun's heuristics should, if the current version decides a module is ambiguous, check for "use strict" at global scope and declare the module to be a CommonJS module if it's found. This is because ES modules are in strict mode by default, so there's no reason to add an explicit "use strict", but "use strict" at global scope is perfectly sensible in a CommonJS module. If we change the heuristic as described in a future version of Bun, it will fix this issue.
It happens also with the latest bun version 1.1.38
Thanks
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.1.38+bf2f153f5
What platform is your computer?
Linux 6.8.0-48-generic x86_64 x86_64
What steps can reproduce the bug?
run
bun file.ts
orbun test
in a project usingmemoizee
packageWhat is the expected behavior?
successful run
What do you see instead?
Additional information
Issue is discussed broadly here - medikoo/memoizee#144. In short, inside a project that uses
memoizee
it is not possible to test it usingbun test
.Quoting @heimskr's response:
It happens also with the latest bun version
1.1.38
Thanks
The text was updated successfully, but these errors were encountered: