diff options
author | 2023-05-01 00:16:32 -0400 | |
---|---|---|
committer | 2023-04-30 21:16:32 -0700 | |
commit | 137dc6e19fedc31e32e25e1a8d7d04070f1a9a27 (patch) | |
tree | 0b065ab6a42b265b55cc4cc879315eeb7285d146 | |
parent | c05a6744bb3b979272767c20b6ffe055a18a3c0c (diff) | |
download | bun-137dc6e19fedc31e32e25e1a8d7d04070f1a9a27.tar.gz bun-137dc6e19fedc31e32e25e1a8d7d04070f1a9a27.tar.zst bun-137dc6e19fedc31e32e25e1a8d7d04070f1a9a27.zip |
test default condition (#2776)
-rw-r--r-- | test/bundler/bundler_edgecase.test.ts | 50 | ||||
-rw-r--r-- | test/bundler/expectBundled.ts | 4 |
2 files changed, 52 insertions, 2 deletions
diff --git a/test/bundler/bundler_edgecase.test.ts b/test/bundler/bundler_edgecase.test.ts index 216e813d6..2c270d5a6 100644 --- a/test/bundler/bundler_edgecase.test.ts +++ b/test/bundler/bundler_edgecase.test.ts @@ -378,4 +378,54 @@ describe("bundler", () => { "/x.aaaa": `x`, }, }); + itBundled("edgecase/PackageJSONDefaultConditionRequire", { + files: { + "/entry.js": /* js */ ` + const react = require('react') + console.log(react) + `, + "/node_modules/react/package.json": /* json */ ` + { + "name": "react", + "exports": { + ".": { + "react-server": "./ignore.js", + "default": "./react.js", + } + } + } + `, + "/node_modules/react/react.js": /* js */ ` + module.exports = 123 + `, + }, + run: { + stdout: "123", + }, + }); + itBundled("edgecase/PackageJSONDefaultConditionImport", { + files: { + "/entry.js": /* js */ ` + import React from 'react' + console.log(React) + `, + "/node_modules/react/package.json": /* json */ ` + { + "name": "react", + "exports": { + ".": { + "react-server": "./ignore.js", + "default": "./react.js", + } + } + } + `, + "/node_modules/react/react.js": /* js */ ` + export default 123 + `, + }, + run: { + stdout: "123", + }, + }); }); diff --git a/test/bundler/expectBundled.ts b/test/bundler/expectBundled.ts index f6ad423f9..e7779f1a7 100644 --- a/test/bundler/expectBundled.ts +++ b/test/bundler/expectBundled.ts @@ -34,8 +34,8 @@ const DEBUG = process.env.BUN_BUNDLER_TEST_DEBUG; const FILTER = process.env.BUN_BUNDLER_TEST_FILTER; /** Set this to hide skips */ const HIDE_SKIP = process.env.BUN_BUNDLER_TEST_HIDE_SKIP; -/** Path to the bun. TODO: Once bundler is merged, we should remove the `bun-debug` fallback. */ -const BUN_EXE = (process.env.BUN_EXE && Bun.which(process.env.BUN_EXE)) ?? Bun.which("bun-debug") ?? bunExe(); +/** Path to the bun. */ +const BUN_EXE = (process.env.BUN_EXE && Bun.which(process.env.BUN_EXE)) ?? bunExe(); export const RUN_UNCHECKED_TESTS = false; const outBaseTemplate = path.join(tmpdir(), "bun-build-tests", `${ESBUILD ? "esbuild" : "bun"}-`); |