TestBase64LoaderRemoveUnused
---------- /out.js ----------
// entry.js
console.log("unused import");

================================================================================
TestDCEClassStaticBlocks
---------- /out.js ----------
// entry.ts
var A_keep = class {
  static {
    foo;
  }
};
var B_keep = class {
  static {
    this.foo;
  }
};
var C_keep = class {
  static {
    try {
      foo;
    } catch {
    }
  }
};
var D_keep = class {
  static {
    try {
    } finally {
      foo;
    }
  }
};

================================================================================
TestDCETypeOf
---------- /out.js ----------

================================================================================
TestDCETypeOfEqualsString
---------- /out.js ----------
(() => {
  // entry.js
  if (false)
    console.log(hasBar);
})();

================================================================================
TestDCETypeOfEqualsStringGuardCondition
---------- /out.js ----------
(() => {
  // entry.js
  var keep_1 = typeof x !== "object" ? x : null;
  var keep_1 = typeof x != "object" ? x : null;
  var keep_1 = typeof x === "object" ? null : x;
  var keep_1 = typeof x == "object" ? null : x;
  var keep_1 = typeof x !== "object" && x;
  var keep_1 = typeof x != "object" && x;
  var keep_1 = typeof x === "object" || x;
  var keep_1 = typeof x == "object" || x;
  var keep_1 = typeof x !== "object" ? x : null;
  var keep_1 = typeof x != "object" ? x : null;
  var keep_1 = typeof x === "object" ? null : x;
  var keep_1 = typeof x == "object" ? null : x;
  var keep_1 = typeof x !== "object" && x;
  var keep_1 = typeof x != "object" && x;
  var keep_1 = typeof x === "object" || x;
  var keep_1 = typeof x == "object" || x;
  var keep_2 = typeof x !== "undefined" ? y : null;
  var keep_2 = typeof x != "undefined" ? y : null;
  var keep_2 = typeof x === "undefined" ? null : y;
  var keep_2 = typeof x == "undefined" ? null : y;
  var keep_2 = typeof x !== "undefined" && y;
  var keep_2 = typeof x != "undefined" && y;
  var keep_2 = typeof x === "undefined" || y;
  var keep_2 = typeof x == "undefined" || y;
  var keep_2 = typeof x !== "undefined" ? y : null;
  var keep_2 = typeof x != "undefined" ? y : null;
  var keep_2 = typeof x === "undefined" ? null : y;
  var keep_2 = typeof x == "undefined" ? null : y;
  var keep_2 = typeof x !== "undefined" && y;
  var keep_2 = typeof x != "undefined" && y;
  var keep_2 = typeof x === "undefined" || y;
  var keep_2 = typeof x == "undefined" || y;
  var keep_3 = typeof x !== "undefined" ? null : x;
  var keep_3 = typeof x != "undefined" ? null : x;
  var keep_3 = typeof x === "undefined" ? x : null;
  var keep_3 = typeof x == "undefined" ? x : null;
  var keep_3 = typeof x !== "undefined" || x;
  var keep_3 = typeof x != "undefined" || x;
  var keep_3 = typeof x === "undefined" && x;
  var keep_3 = typeof x == "undefined" && x;
  var keep_3 = typeof x !== "undefined" ? null : x;
  var keep_3 = typeof x != "undefined" ? null : x;
  var keep_3 = typeof x === "undefined" ? x : null;
  var keep_3 = typeof x == "undefined" ? x : null;
  var keep_3 = typeof x !== "undefined" || x;
  var keep_3 = typeof x != "undefined" || x;
  var keep_3 = typeof x === "undefined" && x;
  var keep_3 = typeof x == "undefined" && x;
})();

================================================================================
TestDCETypeOfEqualsStringMangle
---------- /out.js ----------
(() => {
})();

================================================================================
TestDCEVarExports
---------- /out/a.js ----------
// a.js
var require_a = __commonJS({
  "a.js"(exports, module) {
    var foo = { bar: 123 };
    module.exports = foo;
  }
});
export default require_a();

---------- /out/b.js ----------
// b.js
var require_b = __commonJS({
  "b.js"(exports, module) {
    var exports = { bar: 123 };
    module.exports = exports;
  }
});
export default require_b();

---------- /out/c.js ----------
// c.js
var require_c = __commonJS({
  "c.js"(exports, module) {
    var module = { bar: 123 };
    exports.foo = module;
  }
});
export default require_c();

================================================================================
TestDataURLLoaderRemoveUnused
---------- /out.js ----------
// entry.js
console.log("unused import");

================================================================================
TestDeadCodeFollowingJump
---------- /out.js ----------
// entry.js
function testReturn() {
  return y + z();
  if (x)
    var y;
  function z() {
    KEEP_ME();
  }
}
function testThrow() {
  throw y + z();
  if (x)
    var y;
  function z() {
    KEEP_ME();
  }
}
function testBreak() {
  for (; ; ) {
    let z2 = function() {
      KEEP_ME();
    };
    var z = z2;
    y + z2();
    break;
    if (x)
      var y;
  }
}
function testContinue() {
  for (; ; ) {
    let z2 = function() {
      KEEP_ME();
    };
    var z = z2;
    y + z2();
    continue;
    if (x)
      var y;
  }
}
function testStmts() {
  return [a, b, c, d, e, f, g, h, i];
  for (; x; )
    var a;
  do
    var b;
  while (x);
  for (var c; ; )
    ;
  for (var d in x)
    ;
  for (var e of x)
    ;
  if (x)
    var f;
  if (!x)
    var g;
  var h;
  x:
    var i;
}
testReturn();
testThrow();
testBreak();
testContinue();
testStmts();

================================================================================
TestDisableTreeShaking
---------- /out.js ----------
// keep-me/index.js
console.log("side effects");

// entry.jsx
function KeepMe1() {
}
var keepMe2 = React.createElement(KeepMe1, null);
function keepMe3() {
  console.log("side effects");
}
var keepMe4 = keepMe3();
var keepMe5 = pure();
var keepMe6 = some.fn();

================================================================================
TestFileLoaderRemoveUnused
---------- /out.js ----------
// entry.js
console.log("unused import");

================================================================================
TestImportReExportOfNamespaceImport
---------- /out.js ----------
// Users/user/project/node_modules/pkg/foo.js
var require_foo = __commonJS({
  "Users/user/project/node_modules/pkg/foo.js"(exports, module) {
    module.exports = 123;
  }
});

// Users/user/project/node_modules/pkg/index.js
var import_foo = __toESM(require_foo());

// Users/user/project/entry.js
console.log(import_foo.default);

================================================================================
TestJSONLoaderRemoveUnused
---------- /out.js ----------
// entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayGlob
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/keep/this/file.js
console.log("this should be kept");

================================================================================
TestPackageJsonSideEffectsArrayKeep
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
console.log("hello");

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepMainImplicitMain
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index-main.js
var index_main_exports = {};
__export(index_main_exports, {
  foo: () => foo
});
var foo;
var init_index_main = __esm({
  "Users/user/project/node_modules/demo-pkg/index-main.js"() {
    foo = 123;
    console.log("this should be kept");
  }
});

// Users/user/project/src/entry.js
init_index_main();

// Users/user/project/src/require-demo-pkg.js
init_index_main();

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepMainImplicitModule
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepMainUseMain
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index-main.js
console.log("this should be kept");

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepMainUseModule
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepModuleImplicitMain
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index-main.js
var index_main_exports = {};
__export(index_main_exports, {
  foo: () => foo
});
var foo;
var init_index_main = __esm({
  "Users/user/project/node_modules/demo-pkg/index-main.js"() {
    foo = 123;
    console.log("this should be kept");
  }
});

// Users/user/project/src/require-demo-pkg.js
init_index_main();

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepModuleImplicitModule
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index-module.js
console.log("this should be kept");

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepModuleUseMain
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayKeepModuleUseModule
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index-module.js
console.log("this should be kept");

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsArrayRemove
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseAllFork
---------- /out.js ----------
// Users/user/project/node_modules/c/index.js
var foo;
var init_c = __esm({
  "Users/user/project/node_modules/c/index.js"() {
    foo = "foo";
  }
});

// Users/user/project/node_modules/b/index.js
var init_b = __esm({
  "Users/user/project/node_modules/b/index.js"() {
    init_c();
  }
});

// Users/user/project/node_modules/a/index.js
var a_exports = {};
__export(a_exports, {
  foo: () => foo
});
var init_a = __esm({
  "Users/user/project/node_modules/a/index.js"() {
    init_b();
  }
});

// Users/user/project/src/entry.js
Promise.resolve().then(() => (init_a(), a_exports)).then((x) => assert(x.foo === "foo"));

================================================================================
TestPackageJsonSideEffectsFalseIntermediateFilesChainAll
---------- /out.js ----------
// Users/user/project/node_modules/d/index.js
var foo = 123;

// Users/user/project/node_modules/b/index.js
throw "keep this";

// Users/user/project/src/entry.js
console.log(foo);

================================================================================
TestPackageJsonSideEffectsFalseIntermediateFilesChainOne
---------- /out.js ----------
// Users/user/project/node_modules/d/index.js
var foo = 123;

// Users/user/project/node_modules/b/index.js
throw "keep this";

// Users/user/project/src/entry.js
console.log(foo);

================================================================================
TestPackageJsonSideEffectsFalseIntermediateFilesDiamond
---------- /out.js ----------
// Users/user/project/node_modules/d/index.js
var foo = 123;

// Users/user/project/node_modules/b1/index.js
throw "keep this 1";

// Users/user/project/node_modules/b2/index.js
throw "keep this 2";

// Users/user/project/src/entry.js
console.log(foo);

================================================================================
TestPackageJsonSideEffectsFalseIntermediateFilesUnused
---------- /out.js ----------

================================================================================
TestPackageJsonSideEffectsFalseIntermediateFilesUsed
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/foo.js
var foo = 123;

// Users/user/project/node_modules/demo-pkg/index.js
throw "keep this";

// Users/user/project/src/entry.js
console.log(foo);

================================================================================
TestPackageJsonSideEffectsFalseKeepBareImportAndRequireCommonJS
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports) {
    exports.foo = 123;
    console.log("hello");
  }
});

// Users/user/project/src/entry.js
require_demo_pkg();
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseKeepBareImportAndRequireES6
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var demo_pkg_exports = {};
__export(demo_pkg_exports, {
  foo: () => foo
});
var foo;
var init_demo_pkg = __esm({
  "Users/user/project/node_modules/demo-pkg/index.js"() {
    foo = 123;
    console.log("hello");
  }
});

// Users/user/project/src/entry.js
init_demo_pkg();
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseKeepNamedImportCommonJS
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports) {
    exports.foo = 123;
    console.log("hello");
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_demo_pkg());
console.log(import_demo_pkg.foo);

================================================================================
TestPackageJsonSideEffectsFalseKeepNamedImportES6
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var foo = 123;
console.log("hello");

// Users/user/project/src/entry.js
console.log(foo);

================================================================================
TestPackageJsonSideEffectsFalseKeepStarImportCommonJS
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports) {
    exports.foo = 123;
    console.log("hello");
  }
});

// Users/user/project/src/entry.js
var ns = __toESM(require_demo_pkg());
console.log(ns);

================================================================================
TestPackageJsonSideEffectsFalseKeepStarImportES6
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var demo_pkg_exports = {};
__export(demo_pkg_exports, {
  foo: () => foo
});
var foo = 123;
console.log("hello");

// Users/user/project/src/entry.js
console.log(demo_pkg_exports);

================================================================================
TestPackageJsonSideEffectsFalseNoWarningInNodeModulesIssue999
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
console.log("unused import");

// Users/user/project/src/entry.js
console.log("used import");

================================================================================
TestPackageJsonSideEffectsFalseOneFork
---------- /out.js ----------
// Users/user/project/node_modules/c/index.js
var foo;
var init_c = __esm({
  "Users/user/project/node_modules/c/index.js"() {
    foo = "foo";
  }
});

// Users/user/project/node_modules/d/index.js
var init_d = __esm({
  "Users/user/project/node_modules/d/index.js"() {
  }
});

// Users/user/project/node_modules/b/index.js
var init_b = __esm({
  "Users/user/project/node_modules/b/index.js"() {
    init_c();
    init_d();
  }
});

// Users/user/project/node_modules/a/index.js
var a_exports = {};
__export(a_exports, {
  foo: () => foo
});
var init_a = __esm({
  "Users/user/project/node_modules/a/index.js"() {
    init_b();
  }
});

// Users/user/project/src/entry.js
Promise.resolve().then(() => (init_a(), a_exports)).then((x) => assert(x.foo === "foo"));

================================================================================
TestPackageJsonSideEffectsFalseRemoveBareImportCommonJS
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseRemoveBareImportES6
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseRemoveNamedImportCommonJS
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseRemoveNamedImportES6
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseRemoveStarImportCommonJS
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsFalseRemoveStarImportES6
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsKeepExportDefaultExpr
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var demo_pkg_default = exprWithSideEffects();

// Users/user/project/src/entry.js
console.log(demo_pkg_default);

================================================================================
TestPackageJsonSideEffectsNestedDirectoryRemove
---------- /out.js ----------
// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsTrueKeepCommonJS
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports) {
    exports.foo = 123;
    console.log("hello");
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_demo_pkg());
console.log("unused import");

================================================================================
TestPackageJsonSideEffectsTrueKeepES6
---------- /out.js ----------
// Users/user/project/node_modules/demo-pkg/index.js
console.log("hello");

// Users/user/project/src/entry.js
console.log("unused import");

================================================================================
TestRemoveTrailingReturn
---------- /out.js ----------
// entry.js
function foo() {
  a && b();
}
function bar() {
  return a && b(), KEEP_ME;
}
var entry_default = [
  foo,
  bar,
  function() {
    a && b();
  },
  function() {
    return a && b(), KEEP_ME;
  },
  () => {
    a && b();
  },
  () => (a && b(), KEEP_ME)
];
export {
  entry_default as default
};

================================================================================
TestRemoveUnusedImportMeta
---------- /out.js ----------
// entry.js
console.log("foo is unused");

================================================================================
TestRemoveUnusedImports
---------- /out.js ----------
import "a";
import "b";
import "c";

================================================================================
TestRemoveUnusedImportsEval
---------- /out.js ----------
import a from "a";
import * as b from "b";
import { c } from "c";
eval("foo(a, b, c)");

================================================================================
TestRemoveUnusedImportsEvalTS
---------- /out.js ----------
eval("foo(a, b, c)");

================================================================================
TestRemoveUnusedPureCommentCalls
---------- /out.js ----------
// entry.js
function bar() {
}
var bare = foo(bar);
var at_no = /* @__PURE__ */ foo(bar());
var new_at_no = /* @__PURE__ */ new foo(bar());
var nospace_at_no = /* @__PURE__ */ foo(bar());
var nospace_new_at_no = /* @__PURE__ */ new foo(bar());
var num_no = /* @__PURE__ */ foo(bar());
var new_num_no = /* @__PURE__ */ new foo(bar());
var nospace_num_no = /* @__PURE__ */ foo(bar());
var nospace_new_num_no = /* @__PURE__ */ new foo(bar());
var dot_no = /* @__PURE__ */ foo(sideEffect()).dot(bar());
var new_dot_no = /* @__PURE__ */ new foo(sideEffect()).dot(bar());
var nested_no = [1, /* @__PURE__ */ foo(bar()), 2];
var new_nested_no = [1, /* @__PURE__ */ new foo(bar()), 2];
var single_at_no = /* @__PURE__ */ foo(bar());
var new_single_at_no = /* @__PURE__ */ new foo(bar());
var single_num_no = /* @__PURE__ */ foo(bar());
var new_single_num_no = /* @__PURE__ */ new foo(bar());
var bad_no = foo(bar);
var new_bad_no = new foo(bar);
var parens_no = foo(bar);
var new_parens_no = new foo(bar);
var exp_no = /* @__PURE__ */ foo() ** foo();
var new_exp_no = /* @__PURE__ */ new foo() ** foo();

================================================================================
TestTextLoaderRemoveUnused
---------- /out.js ----------
// entry.js
console.log("unused import");

================================================================================
TestTreeShakingBinaryOperators
---------- /out.js ----------
// entry.js
var keep;
var keep2;
keep + keep2;
keep - keep2;
keep * keep2;
keep / keep2;
keep % keep2;
keep ** keep2;
keep < keep2;
keep <= keep2;
keep > keep2;
keep >= keep2;
keep in keep2;
keep instanceof keep2;
keep << keep2;
keep >> keep2;
keep >>> keep2;
keep == keep2;
keep != keep2;
keep | keep2;
keep & keep2;
keep ^ keep2;
keep = keep2;
keep += keep2;
keep -= keep2;
keep *= keep2;
keep /= keep2;
keep %= keep2;
keep **= keep2;
keep <<= keep2;
keep >>= keep2;
keep >>>= keep2;
keep |= keep2;
keep &= keep2;
keep ^= keep2;
keep ??= keep2;
keep ||= keep2;
keep &&= keep2;

================================================================================
TestTreeShakingImportIdentifier
---------- /out.js ----------
// b.js
var Base = class {
};

// a.js
var Keep = class extends Base {
};

// entry.js
new Keep();

================================================================================
TestTreeShakingInESMWrapper
---------- /out.js ----------
// lib.js
var keep1, keep2;
var init_lib = __esm({
  "lib.js"() {
    keep1 = () => "keep1";
    keep2 = () => "keep2";
  }
});

// cjs.js
var cjs_exports = {};
__export(cjs_exports, {
  default: () => cjs_default
});
var cjs_default;
var init_cjs = __esm({
  "cjs.js"() {
    init_lib();
    cjs_default = keep2();
  }
});

// entry.js
init_lib();
console.log(keep1(), (init_cjs(), __toCommonJS(cjs_exports)));

================================================================================
TestTreeShakingNoBundleCJS
---------- /out.js ----------
function keep() {
}
function unused() {
}
keep();

================================================================================
TestTreeShakingNoBundleESM
---------- /out.js ----------
function keep() {
}
function unused() {
}
keep();

================================================================================
TestTreeShakingNoBundleIIFE
---------- /out.js ----------
(() => {
  function keep() {
  }
  keep();
})();

================================================================================
TestTreeShakingReactElements
---------- /out.js ----------
// entry.jsx
function Foo() {
}
var d = /* @__PURE__ */ React.createElement("div", null);
var e = /* @__PURE__ */ React.createElement(Foo, null, d);
var f = /* @__PURE__ */ React.createElement(React.Fragment, null, e);
console.log(f);

================================================================================
TestTreeShakingUnaryOperators
---------- /out.js ----------
// entry.js
var keep;
+keep;
-keep;
~keep;
delete keep;
++keep;
--keep;
keep++;
keep--;
