TestCommonJSVariableInESMTypeModule
---------- /out.js ----------
// entry.js
module.exports = null;

================================================================================
TestPackageJsonBadMain
---------- /Users/user/project/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, module) {
    module.exports = function() {
      return 123;
    };
  }
});

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

================================================================================
TestPackageJsonBrowserIndexNoExt
---------- /Users/user/project/out.js ----------
// Users/user/project/src/demo-pkg/no-ext-browser/index.js
var browser = "browser";

// Users/user/project/src/demo-pkg/no-ext/index.js
var node = "node";

// Users/user/project/src/demo-pkg/ext-browser/index.js
var browser2 = "browser";

// Users/user/project/src/entry.js
console.log(browser);
console.log(node);
console.log(browser2);
console.log(browser2);

================================================================================
TestPackageJsonBrowserIssue2002A
---------- /Users/user/project/out.js ----------
// Users/user/project/src/node_modules/sub/bar.js
var require_bar = __commonJS({
  "Users/user/project/src/node_modules/sub/bar.js"() {
    works();
  }
});

// Users/user/project/src/node_modules/pkg/sub/foo.js
var require_foo = __commonJS({
  "Users/user/project/src/node_modules/pkg/sub/foo.js"() {
    require_bar();
  }
});

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

================================================================================
TestPackageJsonBrowserIssue2002B
---------- /Users/user/project/out.js ----------
// Users/user/project/src/node_modules/pkg/sub/bar.js
var require_bar = __commonJS({
  "Users/user/project/src/node_modules/pkg/sub/bar.js"() {
    works();
  }
});

// Users/user/project/src/node_modules/pkg/sub/foo.js
var require_foo = __commonJS({
  "Users/user/project/src/node_modules/pkg/sub/foo.js"() {
    require_bar();
  }
});

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

================================================================================
TestPackageJsonBrowserIssue2002C
---------- /Users/user/project/out.js ----------
// Users/user/project/src/node_modules/sub/index.js
var require_sub = __commonJS({
  "Users/user/project/src/node_modules/sub/index.js"() {
    works();
  }
});

// Users/user/project/src/node_modules/pkg/sub/foo.js
var require_foo = __commonJS({
  "Users/user/project/src/node_modules/pkg/sub/foo.js"() {
    require_sub();
  }
});

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

================================================================================
TestPackageJsonBrowserMapAvoidMissing
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/component-indexof/index.js
var require_component_indexof = __commonJS({
  "Users/user/project/node_modules/component-indexof/index.js"(exports, module) {
    module.exports = function() {
      return 234;
    };
  }
});

// Users/user/project/node_modules/component-classes/index.js
try {
  index = require_component_indexof();
} catch (err) {
  index = require_component_indexof();
}
var index;

================================================================================
TestPackageJsonBrowserMapModuleDisabled
---------- /Users/user/project/out.js ----------
// (disabled):Users/user/project/node_modules/node-pkg/index.js
var require_node_pkg = __commonJS({
  "(disabled):Users/user/project/node_modules/node-pkg/index.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, module) {
    var fn2 = require_node_pkg();
    module.exports = function() {
      return fn2();
    };
  }
});

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

================================================================================
TestPackageJsonBrowserMapModuleToModule
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/node-pkg-browser/index.js
var require_node_pkg_browser = __commonJS({
  "Users/user/project/node_modules/node-pkg-browser/index.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports, module) {
    var fn2 = require_node_pkg_browser();
    module.exports = function() {
      return fn2();
    };
  }
});

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

================================================================================
TestPackageJsonBrowserMapModuleToRelative
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/node-pkg-browser.js
var require_node_pkg_browser = __commonJS({
  "Users/user/project/node_modules/demo-pkg/node-pkg-browser.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports, module) {
    var fn2 = require_node_pkg_browser();
    module.exports = function() {
      return fn2();
    };
  }
});

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

================================================================================
TestPackageJsonBrowserMapNativeModuleDisabled
---------- /Users/user/project/out.js ----------
// (disabled):fs
var require_fs = __commonJS({
  "(disabled):fs"() {
  }
});

// Users/user/project/node_modules/demo-pkg/index.js
var require_demo_pkg = __commonJS({
  "Users/user/project/node_modules/demo-pkg/index.js"(exports, module) {
    var fs = require_fs();
    module.exports = function() {
      return fs.readFile();
    };
  }
});

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

================================================================================
TestPackageJsonBrowserMapRelativeDisabled
---------- /Users/user/project/out.js ----------
// (disabled):Users/user/project/node_modules/demo-pkg/util-node
var require_util_node = __commonJS({
  "(disabled):Users/user/project/node_modules/demo-pkg/util-node"() {
  }
});

// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    var util = require_util_node();
    module.exports = function(obj) {
      return util.inspect(obj);
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserMapRelativeToModule
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/util-browser/index.js
var require_util_browser = __commonJS({
  "Users/user/project/node_modules/util-browser/index.js"(exports, module) {
    module.exports = "util-browser";
  }
});

// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    var util = require_util_browser();
    module.exports = function() {
      return ["main", util];
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserMapRelativeToRelative
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/lib/util-browser.js
var require_util_browser = __commonJS({
  "Users/user/project/node_modules/demo-pkg/lib/util-browser.js"(exports, module) {
    module.exports = "util-browser";
  }
});

// Users/user/project/node_modules/demo-pkg/main-browser.js
var require_main_browser = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main-browser.js"(exports, module) {
    var util = require_util_browser();
    module.exports = function() {
      return ["main-browser", util];
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main_browser());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserNoExt
---------- /Users/user/project/out.js ----------
// Users/user/project/src/demo-pkg/no-ext-browser.js
var browser = "browser";

// Users/user/project/src/demo-pkg/no-ext.js
var node = "node";

// Users/user/project/src/demo-pkg/ext-browser.js
var browser2 = "browser";

// Users/user/project/src/entry.js
console.log(browser);
console.log(node);
console.log(browser2);
console.log(browser2);

================================================================================
TestPackageJsonBrowserNodeModulesIndexNoExt
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/no-ext-browser/index.js
var browser = "browser";

// Users/user/project/node_modules/demo-pkg/no-ext/index.js
var node = "node";

// Users/user/project/node_modules/demo-pkg/ext-browser/index.js
var browser2 = "browser";

// Users/user/project/src/entry.js
console.log(browser);
console.log(node);
console.log(browser2);
console.log(browser2);

================================================================================
TestPackageJsonBrowserNodeModulesNoExt
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/no-ext-browser.js
var browser = "browser";

// Users/user/project/node_modules/demo-pkg/no-ext.js
var node = "node";

// Users/user/project/node_modules/demo-pkg/ext-browser.js
var browser2 = "browser";

// Users/user/project/src/entry.js
console.log(browser);
console.log(node);
console.log(browser2);
console.log(browser2);

================================================================================
TestPackageJsonBrowserOverMainNode
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserOverModuleBrowser
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.browser.js
var require_main_browser = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.browser.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main_browser());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserString
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/browser.js
var require_browser = __commonJS({
  "Users/user/project/node_modules/demo-pkg/browser.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_browser());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserWithMainNode
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonBrowserWithModuleBrowser
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.browser.esm.js
function main_browser_esm_default() {
  return 123;
}

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

================================================================================
TestPackageJsonDisabledTypeModuleIssue3367
---------- /out.js ----------
// (disabled):node_modules/foo/index.js
var require_foo = __commonJS({
  "(disabled):node_modules/foo/index.js"() {
  }
});

// entry.js
var import_foo = __toESM(require_foo());
(0, import_foo.default)();

================================================================================
TestPackageJsonDualPackageHazardImportAndRequireBrowser
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.browser.js
var require_main_browser = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.browser.js"(exports, module) {
    module.exports = "browser main";
  }
});

// Users/user/project/src/test-main.js
console.log(require_main_browser());

// Users/user/project/src/test-module.js
var import_demo_pkg = __toESM(require_main_browser());
console.log(import_demo_pkg.default);

================================================================================
TestPackageJsonDualPackageHazardImportAndRequireForceModuleBeforeMain
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/module.js
var module_exports = {};
__export(module_exports, {
  default: () => module_default
});
var module_default;
var init_module = __esm({
  "Users/user/project/node_modules/demo-pkg/module.js"() {
    module_default = "module";
  }
});

// Users/user/project/src/test-main.js
console.log((init_module(), __toCommonJS(module_exports)));

// Users/user/project/src/test-module.js
init_module();
console.log(module_default);

================================================================================
TestPackageJsonDualPackageHazardImportAndRequireImplicitMain
---------- /Users/user/project/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, module) {
    module.exports = "index";
  }
});

// Users/user/project/src/test-index.js
console.log(require_demo_pkg());

// Users/user/project/src/test-module.js
var import_demo_pkg = __toESM(require_demo_pkg());
console.log(import_demo_pkg.default);

================================================================================
TestPackageJsonDualPackageHazardImportAndRequireImplicitMainForceModuleBeforeMain
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/module.js
var module_exports = {};
__export(module_exports, {
  default: () => module_default
});
var module_default;
var init_module = __esm({
  "Users/user/project/node_modules/demo-pkg/module.js"() {
    module_default = "module";
  }
});

// Users/user/project/src/test-index.js
console.log((init_module(), __toCommonJS(module_exports)));

// Users/user/project/src/test-module.js
init_module();
console.log(module_default);

================================================================================
TestPackageJsonDualPackageHazardImportAndRequireSameFile
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    module.exports = "main";
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main());
console.log(import_demo_pkg.default, require_main());

================================================================================
TestPackageJsonDualPackageHazardImportAndRequireSeparateFiles
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    module.exports = "main";
  }
});

// Users/user/project/src/test-main.js
console.log(require_main());

// Users/user/project/src/test-module.js
var import_demo_pkg = __toESM(require_main());
console.log(import_demo_pkg.default);

================================================================================
TestPackageJsonDualPackageHazardImportOnly
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/module.js
var module_default = "module";

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

================================================================================
TestPackageJsonDualPackageHazardRequireOnly
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    module.exports = "main";
  }
});

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

================================================================================
TestPackageJsonExportsBrowser
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/browser.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsCustomConditions
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg1/custom2.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsDefaultOverImportAndRequire
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/default.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsEntryPointImportOverRequire
---------- /out.js ----------
// node_modules/pkg/import.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsEntryPointMainOnly
---------- /out.js ----------
// node_modules/pkg/main.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsEntryPointModuleOverMain
---------- /out.js ----------
// node_modules/pkg/module.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsImportOverRequire
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/import.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsNeutral
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/default.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsNode
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/node.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsNotExactMissingExtension
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg1/dir/bar.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsOrderIndependent
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg1/2/bar.js
console.log("SUCCESS");

// Users/user/project/node_modules/pkg2/1/bar.js
console.log("SUCCESS");

================================================================================
TestPackageJsonExportsPatternTrailers
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/dir/baz-foo.js
console.log("works");

// Users/user/project/node_modules/pkg2/public/abc.js
console.log("abc");

// Users/user/project/node_modules/pkg2/public/xyz.js
console.log("xyz");

================================================================================
TestPackageJsonExportsRequireOverImport
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg/require.js
var require_require = __commonJS({
  "Users/user/project/node_modules/pkg/require.js"() {
    console.log("SUCCESS");
  }
});

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

================================================================================
TestPackageJsonExportsWildcard
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/pkg1/file.js
console.log("SUCCESS");

// Users/user/project/node_modules/pkg1/file2.js
console.log("SUCCESS");

================================================================================
TestPackageJsonImportSelfUsingImport
---------- /Users/user/project/out.js ----------
// Users/user/project/src/foo-import.js
var foo_import_default = "foo";

// Users/user/project/src/index.js
var src_default = "index";
console.log(src_default, foo_import_default);
export {
  src_default as default
};

================================================================================
TestPackageJsonImportSelfUsingImportScoped
---------- /Users/user/project/out.js ----------
// Users/user/project/src/foo-import.js
var foo_import_default = "foo";

// Users/user/project/src/index.js
var src_default = "index";
console.log(src_default, foo_import_default);
export {
  src_default as default
};

================================================================================
TestPackageJsonImportSelfUsingRequire
---------- /Users/user/project/out.js ----------
// Users/user/project/src/foo-require.js
var require_foo_require = __commonJS({
  "Users/user/project/src/foo-require.js"(exports, module) {
    module.exports = "foo";
  }
});

// Users/user/project/src/index.js
var require_src = __commonJS({
  "Users/user/project/src/index.js"(exports, module) {
    module.exports = "index";
    console.log(
      require_src(),
      require_foo_require()
    );
  }
});
export default require_src();

================================================================================
TestPackageJsonImportSelfUsingRequireScoped
---------- /Users/user/project/out.js ----------
// Users/user/project/src/foo-require.js
var require_foo_require = __commonJS({
  "Users/user/project/src/foo-require.js"(exports, module) {
    module.exports = "foo";
  }
});

// Users/user/project/src/index.js
var require_src = __commonJS({
  "Users/user/project/src/index.js"(exports, module) {
    module.exports = "index";
    console.log(
      require_src(),
      require_foo_require()
    );
  }
});
export default require_src();

================================================================================
TestPackageJsonImports
---------- /Users/user/project/out.js ----------
// Users/user/project/src/a.js
console.log("a.js");

// Users/user/project/src/b.js
console.log("b.js");

// Users/user/project/src/some-star/c.js
console.log("c.js");

// Users/user/project/src/some-slash/d.js
console.log("d.js");

================================================================================
TestPackageJsonImportsRemapToOtherPackage
---------- /Users/user/project/out.js ----------
// Users/user/project/src/node_modules/pkg/a.js
console.log("a.js");

// Users/user/project/src/node_modules/pkg/b.js
console.log("b.js");

// Users/user/project/src/node_modules/pkg/some-star/c.js
console.log("c.js");

// Users/user/project/src/node_modules/pkg/some-slash/d.js
console.log("d.js");

================================================================================
TestPackageJsonMain
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/custom-main.js
var require_custom_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/custom-main.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_custom_main());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonMainFieldsA
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/a.js
var require_a = __commonJS({
  "Users/user/project/node_modules/demo-pkg/a.js"(exports, module) {
    module.exports = "a";
  }
});

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

================================================================================
TestPackageJsonMainFieldsB
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/b.js
var b_default = "b";

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

================================================================================
TestPackageJsonModule
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.esm.js
function main_esm_default() {
  return 123;
}

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

================================================================================
TestPackageJsonNeutralExplicitMainFields
---------- /Users/user/project/out.js ----------
// Users/user/project/node_modules/demo-pkg/main.js
var require_main = __commonJS({
  "Users/user/project/node_modules/demo-pkg/main.js"(exports, module) {
    module.exports = function() {
      return 123;
    };
  }
});

// Users/user/project/src/entry.js
var import_demo_pkg = __toESM(require_main());
console.log((0, import_demo_pkg.default)());

================================================================================
TestPackageJsonNodePathsIssue2752
---------- /out.js ----------
// usr/lib/pkg/pkg1/foo.js
console.log("pkg1");

// lib/pkg/pkg2/bar.js
console.log("pkg2");

// var/lib/pkg/@scope/pkg3/baz-browser.js
console.log("pkg3");

// tmp/pkg/@scope/pkg4/bat.js
console.log("pkg4");

================================================================================
TestPackageJsonSubpathImportNodeBuiltinIssue3485
---------- /out.js ----------
// entry.js
import fs from "fs";
import http from "node:http";
fs.readFileSync();
http.createServer();

================================================================================
TestPackageJsonTypeShouldBeTypes
---------- /Users/user/project/out.js ----------
