diff options
author | 2023-05-11 20:00:54 -0700 | |
---|---|---|
committer | 2023-05-11 20:01:10 -0700 | |
commit | bfcc0b8960646d8e2c16af2f380c30171cc5c80a (patch) | |
tree | f2aba1b4570115ddf540223ff9668edd9a2794f3 | |
parent | dfd0f3e2527daffa06da791ccaed7dfe3240963e (diff) | |
download | bun-bfcc0b8960646d8e2c16af2f380c30171cc5c80a.tar.gz bun-bfcc0b8960646d8e2c16af2f380c30171cc5c80a.tar.zst bun-bfcc0b8960646d8e2c16af2f380c30171cc5c80a.zip |
handle module.exports.foo = class {} in the entry point in the runtime
Related to https://github.com/oven-sh/bun/issues/2862, but does not fix it
-rw-r--r-- | src/bundler/entry_points.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bundler/entry_points.zig b/src/bundler/entry_points.zig index 866d4b2f1..4eb973b01 100644 --- a/src/bundler/entry_points.zig +++ b/src/bundler/entry_points.zig @@ -191,7 +191,8 @@ pub const ServerEntryPoint = struct { \\var entryNamespace = start; \\var cjs = start?.default; \\if (cjs && typeof cjs === 'function' && cjsSymbol in cjs) {{ - \\ entryNamespace = cjs(); + \\ // if you module.exports = (class {}), don't call it + \\ entryNamespace = ("prototype" in cjs) ? cjs : cjs(); \\}} \\if (typeof entryNamespace?.then === 'function') {{ \\ entryNamespace = entryNamespace.then((entryNamespace) => {{ @@ -233,7 +234,8 @@ pub const ServerEntryPoint = struct { \\var entryNamespace = start; \\var cjs = start?.default; \\if (cjs && typeof cjs === 'function' && cjsSymbol in cjs) {{ - \\ entryNamespace = cjs(); + \\ // if you module.exports = (class {}), don't call it + \\ entryNamespace = ("prototype" in cjs) ? cjs : cjs(); \\}} \\if (typeof entryNamespace?.then === 'function') {{ \\ entryNamespace = entryNamespace.then((entryNamespace) => {{ |