diff --git a/internal/bundler_tests/bundler_loader_test.go b/internal/bundler_tests/bundler_loader_test.go index bb096861b86..3ff10dd44c2 100644 --- a/internal/bundler_tests/bundler_loader_test.go +++ b/internal/bundler_tests/bundler_loader_test.go @@ -1299,7 +1299,8 @@ func TestWithTypeJSONOverrideLoader(t *testing.T) { }, entryPaths: []string{"/entry.js"}, options: config.Options{ - Mode: config.ModeBundle, + Mode: config.ModeBundle, + AbsOutputFile: "/out.js", }, }) } @@ -1314,7 +1315,8 @@ func TestWithTypeJSONOverrideLoaderGlob(t *testing.T) { }, entryPaths: []string{"/entry.js"}, options: config.Options{ - Mode: config.ModeBundle, + Mode: config.ModeBundle, + AbsOutputFile: "/out.js", }, }) } @@ -1383,6 +1385,7 @@ func TestEmptyLoaderJS(t *testing.T) { ".js": config.LoaderJS, ".empty": config.LoaderEmpty, }, + AbsOutputFile: "/out.js", }, expectedCompileLog: `entry.js: WARNING: Import "named" will always be undefined because the file "d.empty" has no exports `, @@ -1408,6 +1411,7 @@ func TestEmptyLoaderCSS(t *testing.T) { ".css": config.LoaderCSS, ".empty": config.LoaderEmpty, }, + AbsOutputFile: "/out.js", }, }) } @@ -1427,6 +1431,7 @@ func TestExtensionlessLoaderJS(t *testing.T) { ".js": config.LoaderJS, "": config.LoaderJS, }, + AbsOutputFile: "/out.js", }, }) } @@ -1446,6 +1451,7 @@ func TestExtensionlessLoaderCSS(t *testing.T) { ".css": config.LoaderCSS, "": config.LoaderCSS, }, + AbsOutputFile: "/out.js", }, }) } diff --git a/internal/bundler_tests/bundler_test.go b/internal/bundler_tests/bundler_test.go index 85b3d6e03d8..95b11a800d7 100644 --- a/internal/bundler_tests/bundler_test.go +++ b/internal/bundler_tests/bundler_test.go @@ -125,6 +125,9 @@ func (s *suite) __expectBundledImpl(t *testing.T, args bundled, fsKind fs.MockKi if args.absWorkingDir == "" { args.absWorkingDir = "/" } + if args.options.AbsOutputDir == "" { + args.options.AbsOutputDir = args.absWorkingDir // Match the behavior of the API in this case + } // Handle conversion to Windows-style paths if fsKind == fs.MockWindows { diff --git a/internal/bundler_tests/snapshots/snapshots_loader.txt b/internal/bundler_tests/snapshots/snapshots_loader.txt index 36d14aabe59..4b1c0db1016 100644 --- a/internal/bundler_tests/snapshots/snapshots_loader.txt +++ b/internal/bundler_tests/snapshots/snapshots_loader.txt @@ -12,7 +12,7 @@ console.log(require_test()); ================================================================================ TestEmptyLoaderCSS ----------- entry.css.map ---------- +---------- /out.js.map ---------- { "version": 3, "sources": ["entry.css"], @@ -21,7 +21,7 @@ TestEmptyLoaderCSS "names": [] } ----------- entry.css ---------- +---------- /out.js ---------- /* entry.css */ a { background: url(); @@ -54,13 +54,13 @@ a { } }, "outputs": { - "entry.css.map": { + "out.js.map": { "imports": [], "exports": [], "inputs": {}, "bytes": 203 }, - "entry.css": { + "out.js": { "imports": [ { "path": "", @@ -81,7 +81,7 @@ a { ================================================================================ TestEmptyLoaderJS ----------- entry.js.map ---------- +---------- /out.js.map ---------- { "version": 3, "sources": ["entry.js"], @@ -90,7 +90,7 @@ TestEmptyLoaderJS "names": ["def"] } ----------- entry.js ---------- +---------- /out.js ---------- // b.empty var require_b = __commonJS({ "b.empty"() { @@ -154,13 +154,13 @@ console.log(ns, import_c.default, void 0); } }, "outputs": { - "entry.js.map": { + "out.js.map": { "imports": [], "exports": [], "inputs": {}, "bytes": 377 }, - "entry.js": { + "out.js": { "imports": [], "exports": [], "entryPoint": "entry.js", @@ -182,7 +182,7 @@ console.log(ns, import_c.default, void 0); ================================================================================ TestExtensionlessLoaderCSS ----------- entry.css ---------- +---------- /out.js ---------- /* what */ .foo { color: red; @@ -192,7 +192,7 @@ TestExtensionlessLoaderCSS ================================================================================ TestExtensionlessLoaderJS ----------- entry.js ---------- +---------- /out.js ---------- // what foo(); @@ -1115,7 +1115,7 @@ console.log(require_test()); ================================================================================ TestWithTypeJSONOverrideLoader ----------- entry.js ---------- +---------- /out.js ---------- // foo.js var foo_default = { "this is json not js": true }; @@ -1124,7 +1124,7 @@ console.log(foo_default); ================================================================================ TestWithTypeJSONOverrideLoaderGlob ----------- entry.js ---------- +---------- /out.js ---------- // foo.js var foo_exports = {}; __export(foo_exports, {