Problem
Bun-target bundles with split require() calls emit import.meta.require("./chunk-….js"). The call is synchronous: it evaluates the selected chunk and returns its namespace immediately.
Perry currently treats require as an unknown import.meta member. Generic member lowering turns the callee into undefined, so the compiled program fails with TypeError: value is not a function; the module collector also does not discover that chunk.
This is a Bun bundle primitive, independent of any particular application.
Minimal repro
dep.js:
globalThis.loads = (globalThis.loads ?? 0) + 1;
export const answer = 42;
main.js:
const first = import.meta.require("./dep.js");
const second = import.meta["require"]("./dep.js");
console.log(first.answer, second.answer, globalThis.loads);
perry compile main.js --platform bun -o app
./app
Expected:
Acceptance criteria
- Direct and computed-literal spellings lower to Perry's synchronous module-dispatch representation.
- Relative paths and
/$bunfs/root/… paths under --bunfs-root are discovered and compiled.
- The call returns the module namespace synchronously and evaluates the target once.
- A missing or non-statically-resolvable target produces the same bounded AOT diagnostic as synchronous
require(expr).
- Ordinary
import.meta properties and user-defined/shadowed values keep their existing behavior.
- An end-to-end compiled-binary regression covers both spellings.
Aliased native-addon discovery/distribution is separate from this issue (see #9606).
Problem
Bun-target bundles with split
require()calls emitimport.meta.require("./chunk-….js"). The call is synchronous: it evaluates the selected chunk and returns its namespace immediately.Perry currently treats
requireas an unknownimport.metamember. Generic member lowering turns the callee intoundefined, so the compiled program fails withTypeError: value is not a function; the module collector also does not discover that chunk.This is a Bun bundle primitive, independent of any particular application.
Minimal repro
dep.js:main.js:Expected:
Acceptance criteria
/$bunfs/root/…paths under--bunfs-rootare discovered and compiled.require(expr).import.metaproperties and user-defined/shadowed values keep their existing behavior.Aliased native-addon discovery/distribution is separate from this issue (see #9606).