aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-06-05 23:12:18 -0700
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-06-05 23:12:18 -0700
commit6a31893ce5bc8a0d4a3e8a7d6412b69644ab003c (patch)
tree4d11a20192280ae29a6ec740abf2b8108baf503e
parentec71e7afe49d5110f3c9d0eba8e49ea22a549e41 (diff)
downloadbun-dylan/fix-bundling-lodash-es-is-buffer.tar.gz
bun-dylan/fix-bundling-lodash-es-is-buffer.tar.zst
bun-dylan/fix-bundling-lodash-es-is-buffer.zip
only if assign target is none, tests for cjs/esm bundlingdylan/fix-bundling-lodash-es-is-buffer
-rw-r--r--src/js_parser.zig2
-rw-r--r--test/bundler/bundler_npm.test.ts49
2 files changed, 50 insertions, 1 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 5f46507d7..dfcf6ad0a 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -17620,7 +17620,7 @@ fn NewParser_(
if (comptime FeatureFlags.unwrap_commonjs_to_esm) {
if (!p.is_control_flow_dead and id.ref.eql(p.exports_ref)) {
- if (!p.commonjs_named_exports_deoptimized) {
+ if (!p.commonjs_named_exports_deoptimized and identifier_opts.assign_target != .none) {
if (identifier_opts.is_delete_target) {
p.deoptimizeCommonJSNamedExports();
return null;
diff --git a/test/bundler/bundler_npm.test.ts b/test/bundler/bundler_npm.test.ts
index 327d68087..1a62126a1 100644
--- a/test/bundler/bundler_npm.test.ts
+++ b/test/bundler/bundler_npm.test.ts
@@ -68,4 +68,53 @@ describe("bundler", () => {
stdout: "pass",
},
});
+ itBundled("npm/LodashEsmImportEsmExport", {
+ files: {
+ "/entry.js": /* js */ `
+ import { isEqual, uniq } from "lodash-es"
+ console.log(isEqual({a: 1}, {a: 1}))
+ `,
+ },
+ install: ["lodash-es"],
+ run: {
+ stdout: "true",
+ },
+ });
+ itBundled("npm/LodashEsmImportCjsExport", {
+ files: {
+ "/entry.js": /* js */ `
+ import { isEqual, uniq } from "lodash"
+ console.log(isEqual({a: 1}, {a: 1}))
+ `,
+ },
+ install: ["lodash"],
+ run: {
+ stdout: "true",
+ },
+ });
+ itBundled("npm/LodashCjsImportCjsExport", {
+ files: {
+ "/entry.js": /* js */ `
+ const { isEqual, uniq } = require("lodash");
+ console.log(isEqual({a: 1}, {a: 1}))
+ `,
+ },
+ install: ["lodash"],
+ run: {
+ stdout: "true",
+ },
+ });
+ itBundled("npm/LodashCjsImportEsmExport", {
+ todo: true,
+ files: {
+ "/entry.js": /* js */ `
+ const { isEqual, uniq } = require("lodash-es");
+ console.log(isEqual({a: 1}, {a: 1}))
+ `,
+ },
+ install: ["lodash-es"],
+ run: {
+ stdout: "true",
+ },
+ });
});