diff --git a/internal/bundler/bundler_default_test.go b/internal/bundler/bundler_default_test.go index 27e04839c42..de95a580600 100644 --- a/internal/bundler/bundler_default_test.go +++ b/internal/bundler/bundler_default_test.go @@ -5415,7 +5415,7 @@ fragment.jsx: WARNING: "import.meta" is not available in the configured target e } func TestBundlingFilesOutsideOfOutbase(t *testing.T) { - splitting_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/src/entry.js": ` console.log('test') @@ -5510,7 +5510,7 @@ var relocateEntries = []string{ } func TestVarRelocatingBundle(t *testing.T) { - splitting_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: relocateFiles, entryPaths: relocateEntries, options: config.Options{ @@ -5522,7 +5522,7 @@ func TestVarRelocatingBundle(t *testing.T) { } func TestVarRelocatingNoBundle(t *testing.T) { - splitting_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: relocateFiles, entryPaths: relocateEntries, options: config.Options{ @@ -5817,7 +5817,7 @@ func TestEntryNamesNonPortableCharacter(t *testing.T) { } func TestEntryNamesChunkNamesExtPlaceholder(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/src/entries/entry1.js": `import "../lib/shared.js"; import "./entry1.css"; console.log('entry1')`, "/src/entries/entry2.js": `import "../lib/shared.js"; import "./entry2.css"; console.log('entry2')`, @@ -5849,7 +5849,7 @@ func TestEntryNamesChunkNamesExtPlaceholder(t *testing.T) { } func TestMinifyIdentifiersImportPathFrequencyAnalysis(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/import.js": ` import foo from "./WWWWWWWWWWXXXXXXXXXXYYYYYYYYYYZZZZZZZZZZ" @@ -5877,7 +5877,7 @@ func TestMinifyIdentifiersImportPathFrequencyAnalysis(t *testing.T) { } func TestToESMWrapperOmission(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import 'a_nowrap' @@ -5928,7 +5928,7 @@ func TestToESMWrapperOmission(t *testing.T) { // return foo2; // }; func TestNamedFunctionExpressionArgumentCollision(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` let x = function foo(foo) { @@ -5947,7 +5947,7 @@ func TestNamedFunctionExpressionArgumentCollision(t *testing.T) { } func TestNoWarnCommonJSExportsInESMPassThrough(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/cjs-in-esm.js": ` export let foo = 1 @@ -5976,7 +5976,7 @@ func TestNoWarnCommonJSExportsInESMPassThrough(t *testing.T) { } func TestWarnCommonJSExportsInESMConvert(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/cjs-in-esm.js": ` export let foo = 1 @@ -6019,7 +6019,7 @@ cjs-in-esm2.js: NOTE: This file is considered to be an ECMAScript module because } func TestWarnCommonJSExportsInESMBundle(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/cjs-in-esm.js": ` export let foo = 1 @@ -6059,7 +6059,7 @@ cjs-in-esm.js: NOTE: This file is considered to be an ECMAScript module because } func TestMangleProps(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry1.js": ` export function shouldMangle() { @@ -6115,7 +6115,7 @@ func TestMangleProps(t *testing.T) { } func TestManglePropsMinify(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ // These repeating characters test for frequency analysis @@ -6175,7 +6175,7 @@ func TestManglePropsMinify(t *testing.T) { } func TestManglePropsKeywordPropertyMinify(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` class Foo { @@ -6196,7 +6196,7 @@ func TestManglePropsKeywordPropertyMinify(t *testing.T) { } func TestManglePropsOptionalChain(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` export default function(x) { @@ -6221,7 +6221,7 @@ func TestManglePropsOptionalChain(t *testing.T) { } func TestManglePropsLoweredOptionalChain(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` export default function(x) { @@ -6247,7 +6247,7 @@ func TestManglePropsLoweredOptionalChain(t *testing.T) { } func TestReserveProps(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` export default { @@ -6267,7 +6267,7 @@ func TestReserveProps(t *testing.T) { } func TestManglePropsImportExport(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ // These don't count as property names, and aren't mangled "/esm.js": ` @@ -6294,7 +6294,7 @@ func TestManglePropsImportExport(t *testing.T) { } func TestManglePropsImportExportBundled(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ // Note: import and export syntax does not count as a property name. That // means the following code is broken. This test just serves to document @@ -6339,7 +6339,7 @@ func TestManglePropsImportExportBundled(t *testing.T) { } func TestManglePropsJSXTransform(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.jsx": ` let Foo = { @@ -6371,7 +6371,7 @@ func TestManglePropsJSXTransform(t *testing.T) { } func TestManglePropsJSXPreserve(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.jsx": ` let Foo = { @@ -6396,7 +6396,7 @@ func TestManglePropsJSXPreserve(t *testing.T) { } func TestManglePropsJSXTransformNamespace(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.jsx": ` export default [ @@ -6416,7 +6416,7 @@ func TestManglePropsJSXTransformNamespace(t *testing.T) { } func TestManglePropsAvoidCollisions(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` export default { @@ -6438,7 +6438,7 @@ func TestManglePropsAvoidCollisions(t *testing.T) { } func TestManglePropsTypeScriptFeatures(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/parameter-properties.ts": ` class Foo { @@ -6546,7 +6546,7 @@ func TestManglePropsTypeScriptFeatures(t *testing.T) { } func TestManglePropsShorthand(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` // This should print as "({ y }) => ({ y })" not "({ y: y }) => ({ y: y })" @@ -6564,7 +6564,7 @@ func TestManglePropsShorthand(t *testing.T) { } func TestManglePropsNoShorthand(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` // This should print as "({ y }) => ({ y: y })" not "({ y: y }) => ({ y: y })" @@ -6583,7 +6583,7 @@ func TestManglePropsNoShorthand(t *testing.T) { } func TestManglePropsLoweredClassFields(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` class Foo { @@ -6608,7 +6608,7 @@ func TestManglePropsLoweredClassFields(t *testing.T) { // The fix was to prevent the property "constructor" from being mangled. // See: https://github.com/evanw/esbuild/issues/1976 func TestManglePropsSuperCall(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` class Foo {} @@ -6629,7 +6629,7 @@ func TestManglePropsSuperCall(t *testing.T) { } func TestMangleNoQuotedProps(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` x['_doNotMangleThis']; @@ -6657,7 +6657,7 @@ func TestMangleNoQuotedProps(t *testing.T) { } func TestMangleNoQuotedPropsMinifySyntax(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` x['_doNotMangleThis']; @@ -6686,7 +6686,7 @@ func TestMangleNoQuotedPropsMinifySyntax(t *testing.T) { } func TestMangleQuotedProps(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/keep.js": ` foo("_keepThisProperty"); @@ -6734,7 +6734,7 @@ func TestMangleQuotedProps(t *testing.T) { } func TestMangleQuotedPropsMinifySyntax(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/keep.js": ` foo("_keepThisProperty"); @@ -6783,7 +6783,7 @@ func TestMangleQuotedPropsMinifySyntax(t *testing.T) { } func TestIndirectRequireMessage(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/array.js": `let x = [require]`, "/assign.js": `require = x`, @@ -6813,7 +6813,7 @@ ident.js: DEBUG: Indirect calls to "require" will not be bundled } func TestAmbiguousReexportMsg(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` export * from './a' @@ -6839,7 +6839,7 @@ b.js: NOTE: Another definition of "x" comes from "b.js" here: // See: https://github.com/evanw/esbuild/issues/2537 func TestNonDeterminismIssue2537(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` export function aap(noot: boolean, wim: number) { @@ -6875,7 +6875,7 @@ func TestNonDeterminismIssue2537(t *testing.T) { // See: https://github.com/evanw/esbuild/issues/2697 func TestMinifiedJSXPreserveWithObjectSpread(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.jsx": ` const obj = { @@ -6913,7 +6913,7 @@ func TestMinifiedJSXPreserveWithObjectSpread(t *testing.T) { } func TestPackageAlias(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import "pkg1" @@ -6958,7 +6958,7 @@ func TestPackageAlias(t *testing.T) { } func TestErrorsForAssertTypeJSON(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/js-entry.js": ` import all from './foo.json' assert { type: 'json' } @@ -7037,7 +7037,7 @@ NOTE: You can either keep the import assertion and only use the "default" import } func TestOutputForAssertTypeJSON(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/js-entry.js": ` import all from './foo.json' assert { type: 'json' } @@ -7084,7 +7084,7 @@ NOTE: You can either keep the import assertion and only use the "default" import } func TestExternalPackages(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/project/entry.js": ` import 'pkg1' @@ -7117,7 +7117,7 @@ func TestExternalPackages(t *testing.T) { } func TestMetafileVariousCases(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/project/entry.js": ` import a from 'extern-esm' @@ -7182,7 +7182,7 @@ func TestMetafileVariousCases(t *testing.T) { } func TestMetafileNoBundle(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/project/entry.js": ` import a from 'pkg' @@ -7216,7 +7216,7 @@ func TestMetafileNoBundle(t *testing.T) { } func TestMetafileVeryLongExternalPaths(t *testing.T) { - loader_suite.expectBundled(t, bundled{ + default_suite.expectBundled(t, bundled{ files: map[string]string{ "/project/bytesInOutput should be at least 99 (1).js": ` import a from './` + strings.Repeat("1", 99) + `.file' diff --git a/internal/bundler/bundler_loader_test.go b/internal/bundler/bundler_loader_test.go index e4658d5733c..8cb44597cff 100644 --- a/internal/bundler/bundler_loader_test.go +++ b/internal/bundler/bundler_loader_test.go @@ -786,7 +786,7 @@ func TestLoaderJSONSharedWithMultipleEntriesIssue413(t *testing.T) { } func TestLoaderFileWithQueryParameter(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` // Each of these should have a separate identity (i.e. end up in the output file twice) @@ -809,7 +809,7 @@ func TestLoaderFileWithQueryParameter(t *testing.T) { } func TestLoaderFromExtensionWithQueryParameter(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import foo from './file.abc?query.xyz' @@ -831,7 +831,7 @@ func TestLoaderFromExtensionWithQueryParameter(t *testing.T) { } func TestLoaderDataURLTextCSS(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.css": ` @import "data:text/css,body{color:%72%65%64}"; @@ -849,7 +849,7 @@ func TestLoaderDataURLTextCSS(t *testing.T) { } func TestLoaderDataURLTextCSSCannotImport(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.css": ` @import "data:text/css,@import './other.css';"; @@ -869,7 +869,7 @@ func TestLoaderDataURLTextCSSCannotImport(t *testing.T) { } func TestLoaderDataURLTextJavaScript(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import "data:text/javascript,console.log('%31%32%33')"; @@ -887,7 +887,7 @@ func TestLoaderDataURLTextJavaScript(t *testing.T) { } func TestLoaderDataURLTextJavaScriptCannotImport(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import "data:text/javascript,import './other.js'" @@ -908,7 +908,7 @@ func TestLoaderDataURLTextJavaScriptCannotImport(t *testing.T) { // The "+" character must not be interpreted as a " " character func TestLoaderDataURLTextJavaScriptPlusCharacter(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import "data:text/javascript,console.log(1+2)"; @@ -923,7 +923,7 @@ func TestLoaderDataURLTextJavaScriptPlusCharacter(t *testing.T) { } func TestLoaderDataURLApplicationJSON(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import a from 'data:application/json,"%31%32%33"'; @@ -944,7 +944,7 @@ func TestLoaderDataURLApplicationJSON(t *testing.T) { } func TestLoaderDataURLUnknownMIME(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import a from 'data:some/thing;what,someData%31%32%33'; @@ -961,7 +961,7 @@ func TestLoaderDataURLUnknownMIME(t *testing.T) { } func TestLoaderDataURLExtensionBasedMIME(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.foo": ` export { default as css } from "./example.css" @@ -1121,7 +1121,7 @@ func TestLoaderDataURLEscapePercents(t *testing.T) { } func TestLoaderCopyWithBundleFromJS(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/Users/user/project/src/entry.js": ` import x from "../assets/some.file" @@ -1143,7 +1143,7 @@ func TestLoaderCopyWithBundleFromJS(t *testing.T) { } func TestLoaderCopyWithBundleFromCSS(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/Users/user/project/src/entry.css": ` body { @@ -1166,7 +1166,7 @@ func TestLoaderCopyWithBundleFromCSS(t *testing.T) { } func TestLoaderCopyWithBundleEntryPoint(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/Users/user/project/src/entry.js": ` import x from "../assets/some.file" @@ -1198,7 +1198,7 @@ func TestLoaderCopyWithBundleEntryPoint(t *testing.T) { } func TestLoaderCopyWithTransform(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/Users/user/project/src/entry.js": `console.log('entry')`, "/Users/user/project/assets/some.file": `stuff`, @@ -1220,7 +1220,7 @@ func TestLoaderCopyWithTransform(t *testing.T) { } func TestLoaderCopyWithFormat(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/Users/user/project/src/entry.js": `console.log('entry')`, "/Users/user/project/assets/some.file": `stuff`, @@ -1243,7 +1243,7 @@ func TestLoaderCopyWithFormat(t *testing.T) { } func TestJSXAutomaticNoNameCollision(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.jsx": ` import { Link } from "@remix-run/react" @@ -1263,7 +1263,7 @@ func TestJSXAutomaticNoNameCollision(t *testing.T) { } func TestAssertTypeJSONWrongLoader(t *testing.T) { - default_suite.expectBundled(t, bundled{ + loader_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": ` import foo from './foo.json' assert { type: 'json' } diff --git a/internal/bundler/bundler_packagejson_test.go b/internal/bundler/bundler_packagejson_test.go index 9096d70f8ba..a14c9844993 100644 --- a/internal/bundler/bundler_packagejson_test.go +++ b/internal/bundler/bundler_packagejson_test.go @@ -2715,7 +2715,7 @@ NOTE: You can mark the path "xyz/src/foo.js" as external to exclude it from the } func TestCommonJSVariableInESMTypeModule(t *testing.T) { - ts_suite.expectBundled(t, bundled{ + packagejson_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.js": `module.exports = null`, "/package.json": `{ "type": "module" }`, diff --git a/internal/bundler/bundler_ts_test.go b/internal/bundler/bundler_ts_test.go index 21528dd4e4b..2dfb8460a36 100644 --- a/internal/bundler/bundler_ts_test.go +++ b/internal/bundler/bundler_ts_test.go @@ -1238,7 +1238,7 @@ func TestExportTypeIssue379(t *testing.T) { } func TestThisInsideFunctionTS(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` function foo(x = this) { console.log(this) } @@ -1277,7 +1277,7 @@ func TestThisInsideFunctionTS(t *testing.T) { } func TestThisInsideFunctionTSUseDefineForClassFields(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` function foo(x = this) { console.log(this) } @@ -1316,7 +1316,7 @@ func TestThisInsideFunctionTSUseDefineForClassFields(t *testing.T) { } func TestThisInsideFunctionTSNoBundle(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` function foo(x = this) { console.log(this) } @@ -1354,7 +1354,7 @@ func TestThisInsideFunctionTSNoBundle(t *testing.T) { } func TestThisInsideFunctionTSNoBundleUseDefineForClassFields(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` function foo(x = this) { console.log(this) } @@ -1393,7 +1393,7 @@ func TestThisInsideFunctionTSNoBundleUseDefineForClassFields(t *testing.T) { } func TestTSComputedClassFieldUseDefineFalse(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` class Foo { @@ -1417,7 +1417,7 @@ func TestTSComputedClassFieldUseDefineFalse(t *testing.T) { } func TestTSComputedClassFieldUseDefineTrue(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` class Foo { @@ -1441,7 +1441,7 @@ func TestTSComputedClassFieldUseDefineTrue(t *testing.T) { } func TestTSComputedClassFieldUseDefineTrueLower(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` class Foo { @@ -1466,7 +1466,7 @@ func TestTSComputedClassFieldUseDefineTrueLower(t *testing.T) { } func TestTSAbstractClassFieldUseAssign(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` const keepThis = Symbol('keepThis') @@ -1491,7 +1491,7 @@ func TestTSAbstractClassFieldUseAssign(t *testing.T) { } func TestTSAbstractClassFieldUseDefine(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` const keepThisToo = Symbol('keepThisToo') @@ -1516,7 +1516,7 @@ func TestTSAbstractClassFieldUseDefine(t *testing.T) { } func TestTSImportMTS(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` import './imported.mjs' @@ -1535,7 +1535,7 @@ func TestTSImportMTS(t *testing.T) { } func TestTSImportCTS(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` require('./required.cjs') @@ -1554,7 +1554,7 @@ func TestTSImportCTS(t *testing.T) { } func TestTSSideEffectsFalseWarningTypeDeclarations(t *testing.T) { - default_suite.expectBundled(t, bundled{ + ts_suite.expectBundled(t, bundled{ files: map[string]string{ "/entry.ts": ` import "some-js" diff --git a/internal/bundler/snapshots/snapshots_default.txt b/internal/bundler/snapshots/snapshots_default.txt index b58648fa0ce..204cfc6d045 100644 --- a/internal/bundler/snapshots/snapshots_default.txt +++ b/internal/bundler/snapshots/snapshots_default.txt @@ -1,3 +1,20 @@ +TestAmbiguousReexportMsg +---------- /out/entry.js ---------- +// a.js +var a = 1; + +// b.js +var b = 3; + +// c.js +var c = 4; +export { + a, + b, + c +}; + +================================================================================ TestArgumentDefaultValueScopeNoBundle ---------- /out.js ---------- export function a(o = foo) { @@ -209,6 +226,12 @@ console.log([ require_fs() ]); +================================================================================ +TestBundlingFilesOutsideOfOutbase +---------- /out/_.._/_.._/_.._/src/entry.js ---------- +// src/entry.js +console.log("test"); + ================================================================================ TestCallImportNamespaceWarning ---------- /out/js.js ---------- @@ -637,6 +660,36 @@ var init_types = __esm({ // entry.js console.log((init_types(), __toCommonJS(types_exports))); +================================================================================ +TestEntryNamesChunkNamesExtPlaceholder +---------- /out/main/js/entry1-L7KI5G7A.js ---------- +import "../../common/js/chunk-XHGYOYUR.js"; + +// src/entries/entry1.js +console.log("entry1"); + +---------- /out/main/js/entry2-KTHKWVT2.js ---------- +import "../../common/js/chunk-XHGYOYUR.js"; + +// src/entries/entry2.js +console.log("entry2"); + +---------- /out/common/js/chunk-XHGYOYUR.js ---------- +// src/lib/shared.js +console.log("shared"); + +---------- /out/main/css/entry1-3JZGIUSL.css ---------- +/* src/entries/entry1.css */ +a:after { + content: "entry1"; +} + +---------- /out/main/css/entry2-NXZBPPIA.css ---------- +/* src/entries/entry2.css */ +a:after { + content: "entry2"; +} + ================================================================================ TestEntryNamesNoSlashAfterDir ---------- /out/app1-main.js ---------- @@ -1058,6 +1111,21 @@ import sha256 from "../src/sha256.min.js"; import config from "/api/config?a=1&b=2"; console.log(foo, out, sha256, config); +================================================================================ +TestExternalPackages +---------- /out.js ---------- +// project/entry.js +import "pkg1"; + +// project/file.js +console.log("file"); + +// project/node_modules/pkg2/index.js +console.log("pkg2"); + +// project/libs/pkg3.js +console.log("pkg3"); + ================================================================================ TestExternalWildcardDoesNotMatchEntryPoint ---------- /out.js ---------- @@ -1362,6 +1430,24 @@ var file_default2 = "This is some text"; // entry.js console.log(file_default, file_default2); +================================================================================ +TestIndirectRequireMessage +---------- /out/array.js ---------- + +---------- /out/assign.js ---------- +// assign.js +__require = x; + +---------- /out/dot.js ---------- +// dot.js +var x = __require.cache; + +---------- /out/ident.js ---------- + +---------- /out/index.js ---------- +// index.js +var x = __require[cache]; + ================================================================================ TestInject ---------- /out.js ---------- @@ -1472,13 +1558,6 @@ function Fragment() { import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime"; console.log(/* @__PURE__ */ jsx2("div", { jsx }), /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2(Fragment, {}) })); -================================================================================ -TestJSXAutomaticNoNameCollision ----------- /out.js ---------- -var import_react = require("react"); -var import_react2 = require("@remix-run/react"); -const x = /* @__PURE__ */ (0, import_react.createElement)(import_react2.Link, { ...y, key: z }); - ================================================================================ TestJSXConstantFragments ---------- /out.js ---------- @@ -1998,243 +2077,466 @@ c { /* entry.css */ ================================================================================ -TestLoaderCopyWithBundleEntryPoint ----------- /out/assets/some.file ---------- -stuff ----------- /out/src/entry.js ---------- -// Users/user/project/src/entry.js -import x from "../assets/some.file"; -console.log(x); - ----------- /out/src/entry.css ---------- -/* Users/user/project/src/entry.css */ -body { - background: url(../assets/some.file); -} +TestMangleNoQuotedProps +---------- /out/entry.js ---------- +x["_doNotMangleThis"]; +x?.["_doNotMangleThis"]; +x[y ? "_doNotMangleThis" : z]; +x?.[y ? "_doNotMangleThis" : z]; +x[y ? z : "_doNotMangleThis"]; +x?.[y ? z : "_doNotMangleThis"]; +({ "_doNotMangleThis": x }); +(class { + "_doNotMangleThis" = x; +}); +var { "_doNotMangleThis": x } = y; +"_doNotMangleThis" in x; +(y ? "_doNotMangleThis" : z) in x; +(y ? z : "_doNotMangleThis") in x; ================================================================================ -TestLoaderCopyWithBundleFromCSS ----------- /out/some-BYATPJRB.file ---------- -stuff ----------- /out/src/entry.css ---------- -/* Users/user/project/src/entry.css */ -body { - background: url(../some-BYATPJRB.file); -} +TestMangleNoQuotedPropsMinifySyntax +---------- /out/entry.js ---------- +x._doNotMangleThis, x?._doNotMangleThis, x[y ? "_doNotMangleThis" : z], x?.[y ? "_doNotMangleThis" : z], x[y ? z : "_doNotMangleThis"], x?.[y ? z : "_doNotMangleThis"], class { + _doNotMangleThis = x; +}; +var { _doNotMangleThis: x } = y; +"_doNotMangleThis" in x, (y ? "_doNotMangleThis" : z) in x, (y ? z : "_doNotMangleThis") in x; ================================================================================ -TestLoaderCopyWithBundleFromJS ----------- /out/some-BYATPJRB.file ---------- -stuff ----------- /out/src/entry.js ---------- -// Users/user/project/src/entry.js -import x from "../some-BYATPJRB.file"; -console.log(x); +TestMangleProps +---------- /out/entry1.js ---------- +export function shouldMangle() { + let foo = { + a: 0, + b() { + } + }; + let { a: bar_ } = foo; + ({ a: bar_ } = foo); + class foo_ { + a = 0; + b() { + } + static a = 0; + static b() { + } + } + return { a: bar_, c: foo_ }; +} +export function shouldNotMangle() { + let foo = { + "bar_": 0, + "baz_"() { + } + }; + let { "bar_": bar_ } = foo; + ({ "bar_": bar_ } = foo); + class foo_ { + "bar_" = 0; + "baz_"() { + } + static "bar_" = 0; + static "baz_"() { + } + } + return { "bar_": bar_, "foo_": foo_ }; +} -================================================================================ -TestLoaderCopyWithFormat ----------- /out/src/entry.js ---------- -(() => { - console.log("entry"); -})(); +---------- /out/entry2.js ---------- +export default { + a: 0, + "baz_": 1 +}; ----------- /out/assets/some.file ---------- -stuff ================================================================================ -TestLoaderCopyWithTransform ----------- /out/src/entry.js ---------- -console.log("entry"); +TestManglePropsAvoidCollisions +---------- /out.js ---------- +export default { + c: 0, + d: 1, + a: 2, + b: 3, + __proto__: {} +}; ----------- /out/assets/some.file ---------- -stuff ================================================================================ -TestLoaderDataURLApplicationJSON ----------- /out/entry.js ---------- -// -var json_31_32_33_default = "123"; +TestManglePropsImportExport +---------- /out/esm.js ---------- +export let foo_ = 123; +import { bar_ } from "xyz"; -// -var json_base64_eyJ3b3JrcyI6dHJ1ZX0_default = { works: true }; - -// -var json_charset_UTF_8_31_32_33_default = 123; - -// -var json_charset_UTF_8_base64_eyJ3b3JrcyI6dHJ1ZX0_default = { works: true }; - -// entry.js -console.log([ - json_31_32_33_default, - json_base64_eyJ3b3JrcyI6dHJ1ZX0_default, - json_charset_UTF_8_31_32_33_default, - json_charset_UTF_8_base64_eyJ3b3JrcyI6dHJ1ZX0_default -]); +---------- /out/cjs.js ---------- +exports.a = 123; +let bar_ = require("xyz").b; ================================================================================ -TestLoaderDataURLExtensionBasedMIME ----------- /out/entry.js ---------- -// example.css -var example_default = "data:text/css;charset=utf-8,css"; - -// example.eot -var example_default2 = "data:application/vnd.ms-fontobject,eot"; - -// example.gif -var example_default3 = "data:image/gif,gif"; - -// example.htm -var example_default4 = "data:text/html;charset=utf-8,htm"; - -// example.html -var example_default5 = "data:text/html;charset=utf-8,html"; - -// example.jpeg -var example_default6 = "data:image/jpeg,jpeg"; - -// example.jpg -var example_default7 = "data:image/jpeg,jpg"; - -// example.js -var example_default8 = "data:text/javascript;charset=utf-8,js"; - -// example.json -var example_default9 = "data:application/json,json"; - -// example.mjs -var example_default10 = "data:text/javascript;charset=utf-8,mjs"; - -// example.otf -var example_default11 = "data:font/otf,otf"; - -// example.pdf -var example_default12 = "data:application/pdf,pdf"; +TestManglePropsImportExportBundled +---------- /out/entry-esm.js ---------- +// cjs.js +var require_cjs = __commonJS({ + "cjs.js"(exports) { + exports.a = "foo"; + } +}); -// example.png -var example_default13 = "data:image/png,png"; +// esm.js +var esm_exports = {}; +__export(esm_exports, { + esm_foo_: () => esm_foo_ +}); +var esm_foo_ = "foo"; -// example.sfnt -var example_default14 = "data:font/sfnt,sfnt"; +// entry-esm.js +var import_cjs = __toESM(require_cjs()); +var cjs = __toESM(require_cjs()); +var bar_ = [ + esm_foo_, + import_cjs.cjs_foo_, + esm_exports.b, + cjs.a +]; +export { + bar_ +}; -// example.svg -var example_default15 = "data:image/svg+xml,svg"; +---------- /out/entry-cjs.js ---------- +// esm.js +var esm_exports = {}; +__export(esm_exports, { + esm_foo_: () => esm_foo_ +}); +var esm_foo_; +var init_esm = __esm({ + "esm.js"() { + esm_foo_ = "foo"; + } +}); -// example.ttf -var example_default16 = "data:font/ttf,ttf"; +// cjs.js +var require_cjs = __commonJS({ + "cjs.js"(exports) { + exports.a = "foo"; + } +}); -// example.wasm -var example_default17 = "data:application/wasm,wasm"; +// entry-cjs.js +var require_entry_cjs = __commonJS({ + "entry-cjs.js"(exports) { + var { b: esm_foo_2 } = (init_esm(), __toCommonJS(esm_exports)); + var { a: cjs_foo_ } = require_cjs(); + exports.c = [ + esm_foo_2, + cjs_foo_ + ]; + } +}); +export default require_entry_cjs(); -// example.webp -var example_default18 = "data:image/webp,webp"; +================================================================================ +TestManglePropsJSXPreserve +---------- /out.jsx ---------- +let Foo = { + a(props) { + return <>{props.b}; + }, + c: "hello, world" +}; +export default ; -// example.woff -var example_default19 = "data:font/woff,woff"; +================================================================================ +TestManglePropsJSXTransform +---------- /out.js ---------- +let Foo = { + b(props) { + return /* @__PURE__ */ Foo.a(Foo.d, null, props.c); + }, + e: "hello, world", + a(...args) { + console.log("createElement", ...args); + }, + d(...args) { + console.log("Fragment", ...args); + } +}; +export default /* @__PURE__ */ Foo.a(Foo.b, { c: Foo.e }); -// example.woff2 -var example_default20 = "data:font/woff2,woff2"; +================================================================================ +TestManglePropsJSXTransformNamespace +---------- /out.js ---------- +export default [ + /* @__PURE__ */ React.createElement(KEEP_THIS_, null), + /* @__PURE__ */ React.createElement("KEEP:THIS_", null), + /* @__PURE__ */ React.createElement("foo", { "KEEP:THIS_": true }) +]; -// example.xml -var example_default21 = "data:text/xml;charset=utf-8,xml"; -export { - example_default as css, - example_default2 as eot, - example_default3 as gif, - example_default4 as htm, - example_default5 as html, - example_default6 as jpeg, - example_default7 as jpg, - example_default8 as js, - example_default9 as json, - example_default10 as mjs, - example_default11 as otf, - example_default12 as pdf, - example_default13 as png, - example_default14 as sfnt, - example_default15 as svg, - example_default16 as ttf, - example_default17 as wasm, - example_default18 as webp, - example_default19 as woff, - example_default20 as woff2, - example_default21 as xml -}; +================================================================================ +TestManglePropsKeywordPropertyMinify +---------- /out/entry.js ---------- +class Foo{static t={get s(){return 123}}} ================================================================================ -TestLoaderDataURLTextCSS ----------- /out/entry.css ---------- -/* */ -body { - color: red; +TestManglePropsLoweredClassFields +---------- /out.js ---------- +class Foo { + constructor() { + __publicField(this, "a", 123); + } } - -/* */ -body { - background: blue; +__publicField(Foo, "b", 234); +Foo.b = new Foo().a; + +================================================================================ +TestManglePropsLoweredOptionalChain +---------- /out.js ---------- +export default function(x) { + var _a; + x.a; + (_a = x.a) == null ? void 0 : _a.call(x); + x == null ? void 0 : x.a; + x == null ? void 0 : x.a(); + x == null ? void 0 : x.a.b; + x == null ? void 0 : x.a.b(); + x == null ? void 0 : x["foo_"].b; + x == null ? void 0 : x.a["bar_"]; } -/* */ -body { - color: red; +================================================================================ +TestManglePropsMinify +---------- /out/entry1.js ---------- +export function shouldMangle_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX() { + let X = { + X: 0, + Y() { + } + }, { X: Y } = X; + ({ X: Y } = X); + class t { + X = 0; + Y() { + } + static X = 0; + static Y() { + } + } + return { X: Y, t }; } - -/* */ -body { - background: blue; +export function shouldNotMangle_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY() { + let X = { + bar_: 0, + baz_() { + } + }, { bar_: Y } = X; + ({ bar_: Y } = X); + class t { + bar_ = 0; + baz_() { + } + static bar_ = 0; + static baz_() { + } + } + return { bar_: Y, foo_: t }; } -/* entry.css */ +---------- /out/entry2.js ---------- +export default { + a: 0, + baz_: 1 +}; ================================================================================ -TestLoaderDataURLTextJavaScript ----------- /out/entry.js ---------- -// -console.log("123"); - -// -console.log(234); - -// -console.log(123); - -// -console.log(234); +TestManglePropsNoShorthand +---------- /out.js ---------- +export let yyyyy = ({ y }) => ({ y: y }); ================================================================================ -TestLoaderDataURLTextJavaScriptPlusCharacter ----------- /out/entry.js ---------- -// -console.log(1 + 2); +TestManglePropsOptionalChain +---------- /out.js ---------- +export default function(x) { + x.a; + x.a?.(); + x?.a; + x?.a(); + x?.a.b; + x?.a.b(); + x?.["foo_"].b; + x?.a["bar_"]; +} ================================================================================ -TestLoaderDataURLUnknownMIME ----------- /out/entry.js ---------- -// entry.js -import a from "data:some/thing;what,someData%31%32%33"; -import b from "data:other/thing;stuff;base64,c29tZURhdGEyMzQ="; -console.log(a, b); +TestManglePropsShorthand +---------- /out.js ---------- +export let yyyyy = ({ y }) => ({ y }); ================================================================================ -TestLoaderFileWithQueryParameter ----------- /out/file-UEHVHXRQ.txt ---------- -This is some text ----------- /out/entry.js ---------- -// file.txt?foo -var file_default = "./file-UEHVHXRQ.txt?foo"; - -// file.txt?bar -var file_default2 = "./file-UEHVHXRQ.txt?bar"; - -// entry.js -console.log(file_default, file_default2); +TestManglePropsSuperCall +---------- /out.js ---------- +class Foo { +} +class Bar extends Foo { + constructor() { + super(); + } +} ================================================================================ -TestLoaderFromExtensionWithQueryParameter ----------- /out/entry.js ---------- -// file.abc?query.xyz -var file_default = "This should not be base64 encoded"; +TestManglePropsTypeScriptFeatures +---------- /out/parameter-properties.js ---------- +class Foo { + constructor(KEEP_FIELD, MANGLE_FIELD_) { + this.KEEP_FIELD = KEEP_FIELD; + this.a = MANGLE_FIELD_; + } +} +let foo = new Foo(); +console.log(foo.KEEP_FIELD, foo.a); + +---------- /out/namespace-exports.js ---------- +var ns; +((ns2) => { + ns2.b = 1; + ns2.c = 2; + ns2.d = 3; + ({ i: { a: ns2.a } } = 4); + function MANGLE_FUNCTION_() { + } + ns2.g = MANGLE_FUNCTION_; + class MANGLE_CLASS_ { + } + ns2.h = MANGLE_CLASS_; + let MANGLE_NAMESPACE_; + ((MANGLE_NAMESPACE_2) => { + ; + })(MANGLE_NAMESPACE_ = ns2.e || (ns2.e = {})); + let MANGLE_ENUM_; + ((MANGLE_ENUM_2) => { + })(MANGLE_ENUM_ = ns2.f || (ns2.f = {})); + console.log({ + VAR: ns2.b, + LET: ns2.c, + CONST: ns2.d, + DESTRUCTURING: ns2.a, + FUNCTION: MANGLE_FUNCTION_, + CLASS: MANGLE_CLASS_, + NAMESPACE: MANGLE_NAMESPACE_, + ENUM: MANGLE_ENUM_ + }); +})(ns || (ns = {})); +console.log({ + VAR: ns.b, + LET: ns.c, + CONST: ns.d, + DESTRUCTURING: ns.a, + FUNCTION: ns.g, + CLASS: ns.h, + NAMESPACE: ns.e, + ENUM: ns.f +}); +((ns2) => { + console.log({ + VAR: ns2.b, + LET: ns2.c, + CONST: ns2.d, + DESTRUCTURING: ns2.a, + FUNCTION: ns2.g, + CLASS: ns2.h, + NAMESPACE: ns2.e, + ENUM: ns2.f + }); +})(ns || (ns = {})); + +---------- /out/enum-values.js ---------- +var TopLevelNumber = /* @__PURE__ */ ((TopLevelNumber2) => { + TopLevelNumber2[TopLevelNumber2["foo_"] = 0] = "foo_"; + return TopLevelNumber2; +})(TopLevelNumber || {}); +var TopLevelString = /* @__PURE__ */ ((TopLevelString2) => { + TopLevelString2["bar_"] = ""; + return TopLevelString2; +})(TopLevelString || {}); +console.log({ + foo: TopLevelNumber.a, + bar: TopLevelString.b +}); +function fn() { + let NestedNumber; + ((NestedNumber2) => { + NestedNumber2[NestedNumber2["foo_"] = 0] = "foo_"; + })(NestedNumber || (NestedNumber = {})); + let NestedString; + ((NestedString2) => { + NestedString2["bar_"] = ""; + })(NestedString || (NestedString = {})); + console.log({ + foo: TopLevelNumber.a, + bar: TopLevelString.b + }); +} -// entry.js -console.log(file_default); +================================================================================ +TestMangleQuotedProps +---------- /out/keep.js ---------- +foo("_keepThisProperty"); +foo((x, "_keepThisProperty")); +foo(x ? "_keepThisProperty" : "_keepThisPropertyToo"); +x[foo("_keepThisProperty")]; +x?.[foo("_keepThisProperty")]; +({ [foo("_keepThisProperty")]: x }); +(class { + [foo("_keepThisProperty")] = x; +}); +var { [foo("_keepThisProperty")]: x } = y; +foo("_keepThisProperty") in x; + +---------- /out/mangle.js ---------- +x.a; +x?.a; +x[y ? "a" : z]; +x?.[y ? "a" : z]; +x[y ? z : "a"]; +x?.[y ? z : "a"]; +x[y, "a"]; +x?.[y, "a"]; +({ a: x }); +({ ["a"]: x }); +({ [(y, "a")]: x }); +(class { + a = x; +}); +(class { + ["a"] = x; +}); +(class { + [(y, "a")] = x; +}); +var { a: x } = y; +var { ["a"]: x } = y; +var { [(z, "a")]: x } = y; +"a" in x; +(y ? "a" : z) in x; +(y ? z : "a") in x; +(y, "a") in x; + +================================================================================ +TestMangleQuotedPropsMinifySyntax +---------- /out/keep.js ---------- +foo("_keepThisProperty"), foo("_keepThisProperty"), foo(x ? "_keepThisProperty" : "_keepThisPropertyToo"), x[foo("_keepThisProperty")], x?.[foo("_keepThisProperty")], foo("_keepThisProperty") + "", class { + [foo("_keepThisProperty")] = x; +}; +var { [foo("_keepThisProperty")]: x } = y; +foo("_keepThisProperty") in x; + +---------- /out/mangle.js ---------- +x.a, x?.a, x[y ? "a" : z], x?.[y ? "a" : z], x[y ? z : "a"], x?.[y ? z : "a"], x[y, "a"], x?.[y, "a"], "a" + "", (y, "a") + "", class { + a = x; +}, class { + ["a"] = x; +}, class { + [(y, "a")] = x; +}; +var { a: x } = y, { ["a"]: x } = y, { [(z, "a")]: x } = y; +"a" in x, (y ? "a" : z) in x, (y ? z : "a") in x, y, "a" in x; ================================================================================ TestManyEntryPoints @@ -2519,66 +2821,717 @@ var shared_default = 123; console.log(shared_default); ================================================================================ -TestMinifiedBundleCommonJS ----------- /out.js ---------- -var t=e(r=>{r.foo=function(){return 123}});var n=e((l,c)=>{c.exports={test:!0}});var{foo:f}=t();console.log(f(),n()); - -================================================================================ -TestMinifiedBundleES6 ----------- /out.js ---------- -function o(){return 123}o();console.log(o()); +TestMetafileNoBundle +---------- /out/entry.js ---------- +import a from "pkg"; +import b from "./file"; +console.log( + a, + b, + require("pkg2"), + require("./file2"), + import("./dynamic") +); +let exported; -================================================================================ -TestMinifiedBundleEndingWithImportantSemicolon ----------- /out.js ---------- -(()=>{while(foo());})(); +---------- /out/entry.css ---------- +@import "pkg"; +@import "./file"; +a { + background: url(pkg2); +} +a { + background: url(./file2); +} +---------- metafile.json ---------- +{ + "inputs": { + "project/entry.js": { + "bytes": 191, + "imports": [] + }, + "project/entry.css": { + "bytes": 112, + "imports": [] + } + }, + "outputs": { + "out/entry.js": { + "imports": [ + { + "path": "pkg", + "kind": "import-statement", + "external": true + }, + { + "path": "./file", + "kind": "import-statement", + "external": true + }, + { + "path": "pkg2", + "kind": "require-call", + "external": true + }, + { + "path": "./file2", + "kind": "require-call", + "external": true + }, + { + "path": "./dynamic", + "kind": "dynamic-import", + "external": true + } + ], + "exports": [ + "exported" + ], + "entryPoint": "project/entry.js", + "inputs": { + "project/entry.js": { + "bytesInOutput": 148 + } + }, + "bytes": 148 + }, + "out/entry.css": { + "imports": [ + { + "path": "pkg", + "kind": "import-rule", + "external": true + }, + { + "path": "./file", + "kind": "import-rule", + "external": true + }, + { + "path": "pkg2", + "kind": "url-token", + "external": true + }, + { + "path": "./file2", + "kind": "url-token", + "external": true + } + ], + "entryPoint": "project/entry.css", + "inputs": { + "project/entry.css": { + "bytesInOutput": 65 + } + }, + "bytes": 98 + } + } +} ================================================================================ -TestMinifiedDynamicImportWithExpressionCJS ----------- /out.js ---------- -import("foo");import(foo()); +TestMetafileVariousCases +---------- /out/file-NVISQQTV.file ---------- +file +---------- /out/copy-O3Y5SCJE.copy ---------- +copy +---------- /out/entry.js ---------- +import { + __commonJS, + __require +} from "./chunk-3MN5TIYV.js"; -================================================================================ -TestMinifiedExportsAndModuleFormatCommonJS ----------- /out.js ---------- -// foo/test.js -var o = {}; -p(o, { - foo: () => l +// project/cjs.js +var require_cjs = __commonJS({ + "project/cjs.js"(exports, module) { + module.exports = 4; + } }); -var l = 123; -// bar/test.js -var r = {}; -p(r, { - bar: () => m -}); -var m = 123; +// project/entry.js +import a from "extern-esm"; -// entry.js -console.log(exports, module.exports, o, r); +// project/esm.js +var esm_default = 1; -================================================================================ -TestMinifyArguments ----------- /out.js ---------- -(() => { - // entry.js - function e(n = arguments) { - let t; - } - function u(n = arguments) { - let t; - } - function a(n = arguments) { - let t; - } - e(); - u(); - a(); -})(); +// +var json_2_default = 2; -================================================================================ -TestMinifyNestedLabelsNoBundle +// project/file.file +var file_default = "./file-NVISQQTV.file"; + +// project/entry.js +import e from "./copy-O3Y5SCJE.copy"; +console.log( + a, + esm_default, + json_2_default, + file_default, + e, + __require("extern-cjs"), + require_cjs(), + import("./dynamic-4QVDQQPM.js") +); +var exported; +export { + exported +}; + +---------- /out/dynamic-4QVDQQPM.js ---------- +import "./chunk-3MN5TIYV.js"; + +// project/dynamic.js +var dynamic_default = 5; +export { + dynamic_default as default +}; + +---------- /out/chunk-3MN5TIYV.js ---------- +export { + __require, + __commonJS +}; + +---------- /out/entry.css ---------- +@import "extern.css"; + +/* project/entry.css */ +a { + background: url(data:image/svg+xml,); +} +b { + background: url(./file-NVISQQTV.file); +} +c { + background: url(./copy-O3Y5SCJE.copy); +} +d { + background: url(extern.png); +} +---------- metafile.json ---------- +{ + "inputs": { + "project/esm.js": { + "bytes": 16, + "imports": [] + }, + "": { + "bytes": 1, + "imports": [] + }, + "project/file.file": { + "bytes": 4, + "imports": [] + }, + "project/copy.copy": { + "bytes": 4, + "imports": [] + }, + "project/cjs.js": { + "bytes": 18, + "imports": [] + }, + "project/dynamic.js": { + "bytes": 16, + "imports": [] + }, + "project/entry.js": { + "bytes": 333, + "imports": [ + { + "path": "extern-esm", + "kind": "import-statement", + "external": true + }, + { + "path": "project/esm.js", + "kind": "import-statement" + }, + { + "path": "", + "kind": "import-statement" + }, + { + "path": "project/file.file", + "kind": "import-statement" + }, + { + "path": "project/copy.copy", + "kind": "import-statement" + }, + { + "path": "extern-cjs", + "kind": "require-call", + "external": true + }, + { + "path": "project/cjs.js", + "kind": "require-call" + }, + { + "path": "project/dynamic.js", + "kind": "dynamic-import" + } + ] + }, + "project/inline.svg": { + "bytes": 6, + "imports": [] + }, + "project/entry.css": { + "bytes": 180, + "imports": [ + { + "path": "extern.css", + "kind": "import-rule", + "external": true + }, + { + "path": "project/inline.svg", + "kind": "url-token" + }, + { + "path": "project/file.file", + "kind": "url-token" + }, + { + "path": "project/copy.copy", + "kind": "url-token" + }, + { + "path": "extern.png", + "kind": "url-token", + "external": true + } + ] + } + }, + "outputs": { + "out/file-NVISQQTV.file": { + "imports": [], + "exports": [], + "inputs": { + "project/file.file": { + "bytesInOutput": 4 + } + }, + "bytes": 4 + }, + "out/copy-O3Y5SCJE.copy": { + "imports": [], + "exports": [], + "inputs": { + "project/copy.copy": { + "bytesInOutput": 4 + } + }, + "bytes": 4 + }, + "out/entry.js": { + "imports": [ + { + "path": "out/chunk-3MN5TIYV.js", + "kind": "import-statement" + }, + { + "path": "extern-esm", + "kind": "import-statement", + "external": true + }, + { + "path": "out/file-NVISQQTV.file", + "kind": "file-loader" + }, + { + "path": "out/copy-O3Y5SCJE.copy", + "kind": "import-statement" + }, + { + "path": "extern-cjs", + "kind": "require-call", + "external": true + }, + { + "path": "out/dynamic-4QVDQQPM.js", + "kind": "dynamic-import" + } + ], + "exports": [ + "exported" + ], + "entryPoint": "project/entry.js", + "inputs": { + "project/cjs.js": { + "bytesInOutput": 101 + }, + "project/entry.js": { + "bytesInOutput": 242 + }, + "project/esm.js": { + "bytesInOutput": 21 + }, + "": { + "bytesInOutput": 24 + }, + "project/file.file": { + "bytesInOutput": 48 + } + }, + "bytes": 642 + }, + "out/dynamic-4QVDQQPM.js": { + "imports": [ + { + "path": "out/chunk-3MN5TIYV.js", + "kind": "import-statement" + } + ], + "exports": [ + "default" + ], + "entryPoint": "project/dynamic.js", + "inputs": { + "project/dynamic.js": { + "bytesInOutput": 25 + } + }, + "bytes": 119 + }, + "out/chunk-3MN5TIYV.js": { + "imports": [], + "exports": [ + "__commonJS", + "__require" + ], + "inputs": {}, + "bytes": 38 + }, + "out/entry.css": { + "imports": [ + { + "path": "extern.css", + "kind": "import-rule", + "external": true + }, + { + "path": "data:image/svg+xml,", + "kind": "url-token" + }, + { + "path": "out/file-NVISQQTV.file", + "kind": "url-token" + }, + { + "path": "out/copy-O3Y5SCJE.copy", + "kind": "url-token" + }, + { + "path": "extern.png", + "kind": "url-token", + "external": true + } + ], + "entryPoint": "project/entry.css", + "inputs": { + "project/entry.css": { + "bytesInOutput": 193 + } + }, + "bytes": 230 + } + } +} + +================================================================================ +TestMetafileVeryLongExternalPaths +---------- /out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file ---------- + +---------- /out/bytesInOutput should be at least 99 (1).js ---------- +// project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file +var __default = "./111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file"; + +// project/bytesInOutput should be at least 99 (1).js +console.log(__default); + +---------- /out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy ---------- + +---------- /out/bytesInOutput should be at least 99 (2).js ---------- +// project/bytesInOutput should be at least 99 (2).js +import a from "./222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy"; +console.log(a); + +---------- /out/bytesInOutput should be at least 99 (3).js ---------- +// project/bytesInOutput should be at least 99 (3).js +import("./333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js").then(console.log); + +---------- /out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js ---------- + +---------- /out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file ---------- + +---------- /out/bytesInOutput should be at least 99.css ---------- +/* project/bytesInOutput should be at least 99.css */ +a { + background: url(./444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file); +} +---------- metafile.json ---------- +{ + "inputs": { + "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": { + "bytes": 0, + "imports": [] + }, + "project/bytesInOutput should be at least 99 (1).js": { + "bytes": 150, + "imports": [ + { + "path": "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file", + "kind": "import-statement" + } + ] + }, + "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy": { + "bytes": 0, + "imports": [] + }, + "project/bytesInOutput should be at least 99 (2).js": { + "bytes": 150, + "imports": [ + { + "path": "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy", + "kind": "import-statement" + } + ] + }, + "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js": { + "bytes": 0, + "imports": [] + }, + "project/bytesInOutput should be at least 99 (3).js": { + "bytes": 141, + "imports": [ + { + "path": "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js", + "kind": "dynamic-import" + } + ] + }, + "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file": { + "bytes": 0, + "imports": [] + }, + "project/bytesInOutput should be at least 99.css": { + "bytes": 136, + "imports": [ + { + "path": "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file", + "kind": "url-token" + } + ] + } + }, + "outputs": { + "out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file": { + "imports": [], + "exports": [], + "inputs": { + "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": { + "bytesInOutput": 0 + } + }, + "bytes": 0 + }, + "out/bytesInOutput should be at least 99 (1).js": { + "imports": [ + { + "path": "out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file", + "kind": "file-loader" + } + ], + "exports": [], + "entryPoint": "project/bytesInOutput should be at least 99 (1).js", + "inputs": { + "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": { + "bytesInOutput": 45 + }, + "project/bytesInOutput should be at least 99 (1).js": { + "bytesInOutput": 24 + } + }, + "bytes": 330 + }, + "out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy": { + "imports": [], + "exports": [], + "inputs": { + "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy": { + "bytesInOutput": 0 + } + }, + "bytes": 0 + }, + "out/bytesInOutput should be at least 99 (2).js": { + "imports": [ + { + "path": "out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy", + "kind": "import-statement" + } + ], + "exports": [], + "entryPoint": "project/bytesInOutput should be at least 99 (2).js", + "inputs": { + "project/bytesInOutput should be at least 99 (2).js": { + "bytesInOutput": 59 + } + }, + "bytes": 203 + }, + "out/bytesInOutput should be at least 99 (3).js": { + "imports": [ + { + "path": "out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js", + "kind": "dynamic-import" + } + ], + "exports": [], + "entryPoint": "project/bytesInOutput should be at least 99 (3).js", + "inputs": { + "project/bytesInOutput should be at least 99 (3).js": { + "bytesInOutput": 55 + } + }, + "bytes": 197 + }, + "out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js": { + "imports": [], + "exports": [], + "entryPoint": "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js", + "inputs": { + "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js": { + "bytesInOutput": 0 + } + }, + "bytes": 0 + }, + "out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file": { + "imports": [], + "exports": [], + "inputs": { + "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file": { + "bytesInOutput": 0 + } + }, + "bytes": 0 + }, + "out/bytesInOutput should be at least 99.css": { + "imports": [ + { + "path": "out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file", + "kind": "url-token" + } + ], + "entryPoint": "project/bytesInOutput should be at least 99.css", + "inputs": { + "project/bytesInOutput should be at least 99.css": { + "bytesInOutput": 52 + } + }, + "bytes": 196 + } + } +} + +================================================================================ +TestMinifiedBundleCommonJS +---------- /out.js ---------- +var t=e(r=>{r.foo=function(){return 123}});var n=e((l,c)=>{c.exports={test:!0}});var{foo:f}=t();console.log(f(),n()); + +================================================================================ +TestMinifiedBundleES6 +---------- /out.js ---------- +function o(){return 123}o();console.log(o()); + +================================================================================ +TestMinifiedBundleEndingWithImportantSemicolon +---------- /out.js ---------- +(()=>{while(foo());})(); + +================================================================================ +TestMinifiedDynamicImportWithExpressionCJS +---------- /out.js ---------- +import("foo");import(foo()); + +================================================================================ +TestMinifiedExportsAndModuleFormatCommonJS +---------- /out.js ---------- +// foo/test.js +var o = {}; +p(o, { + foo: () => l +}); +var l = 123; + +// bar/test.js +var r = {}; +p(r, { + bar: () => m +}); +var m = 123; + +// entry.js +console.log(exports, module.exports, o, r); + +================================================================================ +TestMinifiedJSXPreserveWithObjectSpread +---------- /out.js ---------- +// entry.jsx +var obj = { + before, + [key]: value, + key: value, + after +}; +; +; + +================================================================================ +TestMinifyArguments +---------- /out.js ---------- +(() => { + // entry.js + function e(n = arguments) { + let t; + } + function u(n = arguments) { + let t; + } + function a(n = arguments) { + let t; + } + e(); + u(); + a(); +})(); + +================================================================================ +TestMinifyIdentifiersImportPathFrequencyAnalysis +---------- /out/import.js ---------- +var o=123;console.log(o,"no identifier in this file should be named W, X, Y, or Z"); + +---------- /out/require.js ---------- +var i=r((t,e)=>{e.exports=123});var s=i();console.log(s,"no identifier in this file should be named A, B, C, or D"); + +================================================================================ +TestMinifyNestedLabelsNoBundle ---------- /out.js ---------- n:{l:{a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{m:{o:{p:{nl(` `);q:{r:{s:{t:{u:{v:{w:{x:{y:{z:{A:{B:{C:{D:{E:{F:{nl(` @@ -2675,6 +3628,14 @@ var foo = 123; // b/entry.js console.log(foo); +================================================================================ +TestNamedFunctionExpressionArgumentCollision +---------- /out/entry.js ---------- +let x = function(foo) { + var foo; + return foo; +}; + ================================================================================ TestNestedCommonJS ---------- /out.js ---------- @@ -2751,6 +3712,21 @@ var require_foo = __commonJS({ // entry.js new (require_foo()).Foo(); +================================================================================ +TestNoWarnCommonJSExportsInESMPassThrough +---------- /out/cjs-in-esm.js ---------- +export let foo = 1; +exports.foo = 2; +module.exports = 3; + +---------- /out/import-in-cjs.js ---------- +import { foo } from "bar"; +exports.foo = foo; +module.exports = foo; + +---------- /out/no-warnings-here.js ---------- +console.log(module, exports); + ================================================================================ TestNodeModules ---------- /Users/user/project/out.js ---------- @@ -2767,6 +3743,27 @@ var require_demo_pkg = __commonJS({ var import_demo_pkg = __toESM(require_demo_pkg()); console.log((0, import_demo_pkg.default)()); +================================================================================ +TestNonDeterminismIssue2537 +---------- /out.js ---------- +// entry.ts +function b(o, e) { + let r = "teun"; + if (o) { + let u = function(n) { + return n * 2; + }, t = function(n) { + return n / 2; + }; + var i = u, a = t; + r = u(e) + t(e); + } + return r; +} +export { + b as aap +}; + ================================================================================ TestOutbase ---------- /out/a/b/c.js ---------- @@ -2789,6 +3786,62 @@ TestOutputExtensionRemappingFile // entry.js console.log("test"); +================================================================================ +TestOutputForAssertTypeJSON +---------- /out/foo-FYKHFNL2.copy ---------- +{} +---------- /out/js-entry.js ---------- +// foo.json +var foo_default = {}; + +// js-entry.js +import copy from "./foo-FYKHFNL2.copy" assert { type: "json" }; +use(foo_default, copy, foo_default, void 0); +export { + foo_default as default +}; + +---------- /out/ts-entry.js ---------- +// foo.json +var foo_default = {}; + +// ts-entry.ts +import copy from "./foo-FYKHFNL2.copy" assert { type: "json" }; +use(foo_default, copy, foo_default, void 0); +export { + foo_default as default +}; + +================================================================================ +TestPackageAlias +---------- /out.js ---------- +// node_modules/alias1/index.js +console.log(1); + +// node_modules/alias2/foo.js +console.log(2); + +// node_modules/alias3/index.js +console.log(3); + +// node_modules/alias4/index.js +console.log(4); + +// node_modules/alias5/foo.js +console.log(5); + +// alias6/dir/index.js +console.log(6); + +// alias7/dir/foo/index.js +console.log(7); + +// alias8/dir/pkg8/index.js +console.log(8); + +// alias9/some/file.js +console.log(9); + ================================================================================ TestQuotedProperty ---------- /out/entry.js ---------- @@ -3204,6 +4257,14 @@ try { } var aliasedRequire; +================================================================================ +TestReserveProps +---------- /out.js ---------- +export default { + a: 0, + _bar_: 1 +}; + ================================================================================ TestRuntimeNameCollisionNoBundle ---------- /out.js ---------- @@ -3294,106 +4355,6 @@ switch (bar) { let a; } -================================================================================ -TestTSAbstractClassFieldUseAssign ----------- /out.js ---------- -const keepThis = Symbol("keepThis"); -class Foo { -} -keepThis; -(() => new Foo())(); - -================================================================================ -TestTSAbstractClassFieldUseDefine ----------- /out.js ---------- -const keepThisToo = Symbol("keepThisToo"); -class Foo { - keepThis; - [keepThisToo]; -} -(() => new Foo())(); - -================================================================================ -TestTSComputedClassFieldUseDefineFalse ----------- /out.js ---------- -var _a, _b, _c; -class Foo { - constructor() { - this[_a] = s; - this[_c] = z; - } -} -q, _a = r, _b = x, _c = y; -__decorateClass([ - dec -], Foo.prototype, _b, 2); -__decorateClass([ - dec -], Foo.prototype, _c, 2); -new Foo(); - -================================================================================ -TestTSComputedClassFieldUseDefineTrue ----------- /out.js ---------- -var _a, _b; -class Foo { - [q]; - [r] = s; - [_a = x]; - [_b = y] = z; -} -__decorateClass([ - dec -], Foo.prototype, _a, 2); -__decorateClass([ - dec -], Foo.prototype, _b, 2); -new Foo(); - -================================================================================ -TestTSComputedClassFieldUseDefineTrueLower ----------- /out.js ---------- -var _a, _b, _c, _d; -class Foo { - constructor() { - __publicField(this, _a); - __publicField(this, _b, s); - __publicField(this, _c); - __publicField(this, _d, z); - } -} -_a = q, _b = r, _c = x, _d = y; -__decorateClass([ - dec -], Foo.prototype, _c, 2); -__decorateClass([ - dec -], Foo.prototype, _d, 2); -new Foo(); - -================================================================================ -TestTSImportCTS ----------- /out.js ---------- -// required.cjs -var require_required = __commonJS({ - "required.cjs"() { - console.log("works"); - } -}); - -// entry.ts -require_required(); - -================================================================================ -TestTSImportMTS ----------- /out.js ---------- -// imported.mts -console.log("works"); - -================================================================================ -TestTSSideEffectsFalseWarningTypeDeclarations ----------- /out.js ---------- - ================================================================================ TestThisInsideFunction ---------- /out.js ---------- @@ -3442,203 +4403,6 @@ if (nested) { } var bar2; -================================================================================ -TestThisInsideFunctionTS ----------- /out.js ---------- -// entry.ts -function foo(x = this) { - console.log(this); -} -var objFoo = { - foo(x = this) { - console.log(this); - } -}; -var _Foo = class { - constructor() { - this.x = this; - } - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } -}; -var Foo = _Foo; -Foo.y = _Foo.z; -new Foo(foo(objFoo)); -if (nested) { - let bar = function(x = this) { - console.log(this); - }; - bar2 = bar; - const objBar = { - foo(x = this) { - console.log(this); - } - }; - const _Bar = class { - constructor() { - this.x = this; - } - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } - }; - let Bar = _Bar; - Bar.y = _Bar.z; - new Bar(bar(objBar)); -} -var bar2; - -================================================================================ -TestThisInsideFunctionTSNoBundle ----------- /out.js ---------- -function foo(x = this) { - console.log(this); -} -const objFoo = { - foo(x = this) { - console.log(this); - } -}; -const _Foo = class { - constructor() { - this.x = this; - } - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } -}; -let Foo = _Foo; -Foo.y = _Foo.z; -new Foo(foo(objFoo)); -if (nested) { - let bar2 = function(x = this) { - console.log(this); - }; - var bar = bar2; - const objBar = { - foo(x = this) { - console.log(this); - } - }; - const _Bar = class { - constructor() { - this.x = this; - } - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } - }; - let Bar = _Bar; - Bar.y = _Bar.z; - new Bar(bar2(objBar)); -} - -================================================================================ -TestThisInsideFunctionTSNoBundleUseDefineForClassFields ----------- /out.js ---------- -function foo(x = this) { - console.log(this); -} -const objFoo = { - foo(x = this) { - console.log(this); - } -}; -class Foo { - x = this; - static y = this.z; - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } -} -new Foo(foo(objFoo)); -if (nested) { - let bar2 = function(x = this) { - console.log(this); - }; - var bar = bar2; - const objBar = { - foo(x = this) { - console.log(this); - } - }; - class Bar { - x = this; - static y = this.z; - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } - } - new Bar(bar2(objBar)); -} - -================================================================================ -TestThisInsideFunctionTSUseDefineForClassFields ----------- /out.js ---------- -// entry.ts -function foo(x = this) { - console.log(this); -} -var objFoo = { - foo(x = this) { - console.log(this); - } -}; -var _Foo = class { - x = this; - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } -}; -var Foo = _Foo; -__publicField(Foo, "y", _Foo.z); -new Foo(foo(objFoo)); -if (nested) { - let bar = function(x = this) { - console.log(this); - }; - bar2 = bar; - const objBar = { - foo(x = this) { - console.log(this); - } - }; - class Bar { - x = this; - static y = this.z; - foo(x = this) { - console.log(this); - } - static bar(x = this) { - console.log(this); - } - } - new Bar(bar(objBar)); -} -var bar2; - ================================================================================ TestThisOutsideFunction ---------- /out.js ---------- @@ -3943,6 +4707,31 @@ var import_es6_ns_export_namespace = __toESM(require_es6_ns_export_namespace()); var import_es6_ns_export_class = __toESM(require_es6_ns_export_class()); var import_es6_ns_export_abstract_class = __toESM(require_es6_ns_export_abstract_class()); +================================================================================ +TestToESMWrapperOmission +---------- /out/entry.js ---------- +var entry_exports = {}; +module.exports = __toCommonJS(entry_exports); +var import_a_nowrap = require("a_nowrap"); +var import_b_nowrap = require("b_nowrap"); +__reExport(entry_exports, require("c_nowrap"), module.exports); +var d = __toESM(require("d_WRAP")); +var import_e_WRAP = __toESM(require("e_WRAP")); +var import_f_WRAP = __toESM(require("f_WRAP")); +var import_g_WRAP = __toESM(require("g_WRAP")); +var h = __toESM(require("h_WRAP")); +var i = __toESM(require("i_WRAP")); +var j = __toESM(require("j_WRAP")); +(0, import_b_nowrap.b)(); +x = d.x; +(0, import_e_WRAP.default)(); +(0, import_f_WRAP.default)(); +(0, import_g_WRAP.__esModule)(); +x = h; +i.x(); +j.x``; +x = Promise.resolve().then(() => __toESM(require("k_WRAP"))); + ================================================================================ TestTopLevelAwaitAllowedImportWithSplitting ---------- /out/entry.js ---------- @@ -4094,6 +4883,304 @@ TestUseStrictDirectiveMinifyNoBundle ---------- /out.js ---------- "use strict";a,b; +================================================================================ +TestVarRelocatingBundle +---------- /out/top-level.js ---------- +// top-level.js +for (; 0; ) + ; +var b; +for ({ c, x: [d] } = {}; 0; ) + ; +var c; +var d; +for (e of []) + ; +var e; +for ({ f, x: [g] } of []) + ; +var f; +var g; +for (h in {}) + ; +var h; +i = 1; +for (i in {}) + ; +var i; +for ({ j, x: [k] } in {}) + ; +var j; +var k; + +---------- /out/nested.js ---------- +// nested.js +if (true) { + let l = function() { + }; + l2 = l; + for (; 0; ) + ; + for ({ c, x: [d] } = {}; 0; ) + ; + for (e of []) + ; + for ({ f, x: [g] } of []) + ; + for (h in {}) + ; + i = 1; + for (i in {}) + ; + for ({ j, x: [k] } in {}) + ; +} +var a; +var b; +var c; +var d; +var e; +var f; +var g; +var h; +var i; +var j; +var k; +var l2; + +---------- /out/let.js ---------- +// let.js +if (true) { + let a; + for (let b; 0; ) + ; + for (let { c, x: [d] } = {}; 0; ) + ; + for (let e of []) + ; + for (let { f, x: [g] } of []) + ; + for (let h in {}) + ; + for (let { j, x: [k] } in {}) + ; +} + +---------- /out/function.js ---------- +// function.js +function x() { + var a; + for (var b; 0; ) + ; + for (var { c, x: [d] } = {}; 0; ) + ; + for (var e of []) + ; + for (var { f, x: [g] } of []) + ; + for (var h in {}) + ; + i = 1; + for (var i in {}) + ; + for (var { j, x: [k] } in {}) + ; + function l() { + } +} +x(); + +---------- /out/function-nested.js ---------- +// function-nested.js +function x() { + if (true) { + let l2 = function() { + }; + var l = l2; + var a; + for (var b; 0; ) + ; + for (var { c, x: [d] } = {}; 0; ) + ; + for (var e of []) + ; + for (var { f, x: [g] } of []) + ; + for (var h in {}) + ; + i = 1; + for (var i in {}) + ; + for (var { j, x: [k] } in {}) + ; + } +} +x(); + +================================================================================ +TestVarRelocatingNoBundle +---------- /out/top-level.js ---------- +var a; +for (var b; 0; ) + ; +for (var { c, x: [d] } = {}; 0; ) + ; +for (var e of []) + ; +for (var { f, x: [g] } of []) + ; +for (var h in {}) + ; +i = 1; +for (var i in {}) + ; +for (var { j, x: [k] } in {}) + ; +function l() { +} + +---------- /out/nested.js ---------- +if (true) { + let l = function() { + }; + var l2 = l; + var a; + for (var b; 0; ) + ; + for (var { c, x: [d] } = {}; 0; ) + ; + for (var e of []) + ; + for (var { f, x: [g] } of []) + ; + for (var h in {}) + ; + i = 1; + for (var i in {}) + ; + for (var { j, x: [k] } in {}) + ; +} + +---------- /out/let.js ---------- +if (true) { + let a; + for (let b; 0; ) + ; + for (let { c, x: [d] } = {}; 0; ) + ; + for (let e of []) + ; + for (let { f, x: [g] } of []) + ; + for (let h in {}) + ; + for (let { j, x: [k] } in {}) + ; +} + +---------- /out/function.js ---------- +function x() { + var a; + for (var b; 0; ) + ; + for (var { c, x: [d] } = {}; 0; ) + ; + for (var e of []) + ; + for (var { f, x: [g] } of []) + ; + for (var h in {}) + ; + i = 1; + for (var i in {}) + ; + for (var { j, x: [k] } in {}) + ; + function l() { + } +} +x(); + +---------- /out/function-nested.js ---------- +function x() { + if (true) { + let l2 = function() { + }; + var l = l2; + var a; + for (var b; 0; ) + ; + for (var { c, x: [d] } = {}; 0; ) + ; + for (var e of []) + ; + for (var { f, x: [g] } of []) + ; + for (var h in {}) + ; + i = 1; + for (var i in {}) + ; + for (var { j, x: [k] } in {}) + ; + } +} +x(); + +================================================================================ +TestWarnCommonJSExportsInESMBundle +---------- /out/cjs-in-esm.js ---------- +// cjs-in-esm.js +var cjs_in_esm_exports = {}; +__export(cjs_in_esm_exports, { + foo: () => foo +}); +module.exports = __toCommonJS(cjs_in_esm_exports); +var foo = 1; +exports.foo = 2; +module.exports = 3; + +---------- /out/import-in-cjs.js ---------- +// import-in-cjs.js +var import_bar = require("bar"); +exports.foo = import_bar.foo; +module.exports = import_bar.foo; + +---------- /out/no-warnings-here.js ---------- +// no-warnings-here.js +console.log(module, exports); + +================================================================================ +TestWarnCommonJSExportsInESMConvert +---------- /out/cjs-in-esm.js ---------- +var cjs_in_esm_exports = {}; +__export(cjs_in_esm_exports, { + foo: () => foo +}); +module.exports = __toCommonJS(cjs_in_esm_exports); +let foo = 1; +exports.foo = 2; +module.exports = 3; + +---------- /out/cjs-in-esm2.js ---------- +var cjs_in_esm2_exports = {}; +__export(cjs_in_esm2_exports, { + foo: () => foo +}); +module.exports = __toCommonJS(cjs_in_esm2_exports); +let foo = 1; +module.exports.bar = 3; + +---------- /out/import-in-cjs.js ---------- +var import_bar = require("bar"); +exports.foo = import_bar.foo; +module.exports = import_bar.foo; +module.exports.bar = import_bar.foo; + +---------- /out/no-warnings-here.js ---------- +console.log(module, exports); + ================================================================================ TestWarningsInsideNodeModules ---------- /out.js ---------- diff --git a/internal/bundler/snapshots/snapshots_loader.txt b/internal/bundler/snapshots/snapshots_loader.txt index fb273dc6117..0120551da16 100644 --- a/internal/bundler/snapshots/snapshots_loader.txt +++ b/internal/bundler/snapshots/snapshots_loader.txt @@ -1,20 +1,3 @@ -TestAmbiguousReexportMsg ----------- /out/entry.js ---------- -// a.js -var a = 1; - -// b.js -var b = 3; - -// c.js -var c = 4; -export { - a, - b, - c -}; - -================================================================================ TestAutoDetectMimeTypeFromExtension ---------- /out.js ---------- // test.svg @@ -28,67 +11,11 @@ var require_test = __commonJS({ console.log(require_test()); ================================================================================ -TestEntryNamesChunkNamesExtPlaceholder ----------- /out/main/js/entry1-L7KI5G7A.js ---------- -import "../../common/js/chunk-XHGYOYUR.js"; - -// src/entries/entry1.js -console.log("entry1"); - ----------- /out/main/js/entry2-KTHKWVT2.js ---------- -import "../../common/js/chunk-XHGYOYUR.js"; - -// src/entries/entry2.js -console.log("entry2"); - ----------- /out/common/js/chunk-XHGYOYUR.js ---------- -// src/lib/shared.js -console.log("shared"); - ----------- /out/main/css/entry1-3JZGIUSL.css ---------- -/* src/entries/entry1.css */ -a:after { - content: "entry1"; -} - ----------- /out/main/css/entry2-NXZBPPIA.css ---------- -/* src/entries/entry2.css */ -a:after { - content: "entry2"; -} - -================================================================================ -TestExternalPackages +TestJSXAutomaticNoNameCollision ---------- /out.js ---------- -// project/entry.js -import "pkg1"; - -// project/file.js -console.log("file"); - -// project/node_modules/pkg2/index.js -console.log("pkg2"); - -// project/libs/pkg3.js -console.log("pkg3"); - -================================================================================ -TestIndirectRequireMessage ----------- /out/array.js ---------- - ----------- /out/assign.js ---------- -// assign.js -__require = x; - ----------- /out/dot.js ---------- -// dot.js -var x = __require.cache; - ----------- /out/ident.js ---------- - ----------- /out/index.js ---------- -// index.js -var x = __require[cache]; +var import_react = require("react"); +var import_react2 = require("@remix-run/react"); +const x = /* @__PURE__ */ (0, import_react.createElement)(import_react2.Link, { ...y, key: z }); ================================================================================ TestJSXPreserveCapitalLetter @@ -143,6 +70,79 @@ var y_default = "eQ=="; var x_b64 = require_x(); console.log(x_b64, y_default); +================================================================================ +TestLoaderCopyWithBundleEntryPoint +---------- /out/assets/some.file ---------- +stuff +---------- /out/src/entry.js ---------- +// Users/user/project/src/entry.js +import x from "../assets/some.file"; +console.log(x); + +---------- /out/src/entry.css ---------- +/* Users/user/project/src/entry.css */ +body { + background: url(../assets/some.file); +} + +================================================================================ +TestLoaderCopyWithBundleFromCSS +---------- /out/some-BYATPJRB.file ---------- +stuff +---------- /out/src/entry.css ---------- +/* Users/user/project/src/entry.css */ +body { + background: url(../some-BYATPJRB.file); +} + +================================================================================ +TestLoaderCopyWithBundleFromJS +---------- /out/some-BYATPJRB.file ---------- +stuff +---------- /out/src/entry.js ---------- +// Users/user/project/src/entry.js +import x from "../some-BYATPJRB.file"; +console.log(x); + +================================================================================ +TestLoaderCopyWithFormat +---------- /out/src/entry.js ---------- +(() => { + console.log("entry"); +})(); + +---------- /out/assets/some.file ---------- +stuff +================================================================================ +TestLoaderCopyWithTransform +---------- /out/src/entry.js ---------- +console.log("entry"); + +---------- /out/assets/some.file ---------- +stuff +================================================================================ +TestLoaderDataURLApplicationJSON +---------- /out/entry.js ---------- +// +var json_31_32_33_default = "123"; + +// +var json_base64_eyJ3b3JrcyI6dHJ1ZX0_default = { works: true }; + +// +var json_charset_UTF_8_31_32_33_default = 123; + +// +var json_charset_UTF_8_base64_eyJ3b3JrcyI6dHJ1ZX0_default = { works: true }; + +// entry.js +console.log([ + json_31_32_33_default, + json_base64_eyJ3b3JrcyI6dHJ1ZX0_default, + json_charset_UTF_8_31_32_33_default, + json_charset_UTF_8_base64_eyJ3b3JrcyI6dHJ1ZX0_default +]); + ================================================================================ TestLoaderDataURLBase64InvalidUTF8 ---------- /out.js ---------- @@ -201,6 +201,149 @@ var percents_default = "data:text/plain;charset=utf-8,%0A%, %3, %2533, %25333%0A // entry.js console.log(percents_default); +================================================================================ +TestLoaderDataURLExtensionBasedMIME +---------- /out/entry.js ---------- +// example.css +var example_default = "data:text/css;charset=utf-8,css"; + +// example.eot +var example_default2 = "data:application/vnd.ms-fontobject,eot"; + +// example.gif +var example_default3 = "data:image/gif,gif"; + +// example.htm +var example_default4 = "data:text/html;charset=utf-8,htm"; + +// example.html +var example_default5 = "data:text/html;charset=utf-8,html"; + +// example.jpeg +var example_default6 = "data:image/jpeg,jpeg"; + +// example.jpg +var example_default7 = "data:image/jpeg,jpg"; + +// example.js +var example_default8 = "data:text/javascript;charset=utf-8,js"; + +// example.json +var example_default9 = "data:application/json,json"; + +// example.mjs +var example_default10 = "data:text/javascript;charset=utf-8,mjs"; + +// example.otf +var example_default11 = "data:font/otf,otf"; + +// example.pdf +var example_default12 = "data:application/pdf,pdf"; + +// example.png +var example_default13 = "data:image/png,png"; + +// example.sfnt +var example_default14 = "data:font/sfnt,sfnt"; + +// example.svg +var example_default15 = "data:image/svg+xml,svg"; + +// example.ttf +var example_default16 = "data:font/ttf,ttf"; + +// example.wasm +var example_default17 = "data:application/wasm,wasm"; + +// example.webp +var example_default18 = "data:image/webp,webp"; + +// example.woff +var example_default19 = "data:font/woff,woff"; + +// example.woff2 +var example_default20 = "data:font/woff2,woff2"; + +// example.xml +var example_default21 = "data:text/xml;charset=utf-8,xml"; +export { + example_default as css, + example_default2 as eot, + example_default3 as gif, + example_default4 as htm, + example_default5 as html, + example_default6 as jpeg, + example_default7 as jpg, + example_default8 as js, + example_default9 as json, + example_default10 as mjs, + example_default11 as otf, + example_default12 as pdf, + example_default13 as png, + example_default14 as sfnt, + example_default15 as svg, + example_default16 as ttf, + example_default17 as wasm, + example_default18 as webp, + example_default19 as woff, + example_default20 as woff2, + example_default21 as xml +}; + +================================================================================ +TestLoaderDataURLTextCSS +---------- /out/entry.css ---------- +/* */ +body { + color: red; +} + +/* */ +body { + background: blue; +} + +/* */ +body { + color: red; +} + +/* */ +body { + background: blue; +} + +/* entry.css */ + +================================================================================ +TestLoaderDataURLTextJavaScript +---------- /out/entry.js ---------- +// +console.log("123"); + +// +console.log(234); + +// +console.log(123); + +// +console.log(234); + +================================================================================ +TestLoaderDataURLTextJavaScriptPlusCharacter +---------- /out/entry.js ---------- +// +console.log(1 + 2); + +================================================================================ +TestLoaderDataURLUnknownMIME +---------- /out/entry.js ---------- +// entry.js +import a from "data:some/thing;what,someData%31%32%33"; +import b from "data:other/thing;stuff;base64,c29tZURhdGEyMzQ="; +console.log(a, b); + ================================================================================ TestLoaderFile ---------- /out/test-IPILGNO5.svg ---------- @@ -400,6 +543,29 @@ var image_default = "../image-LSAMBFUD.png"; // src/entries/entry.js console.log(image_default); +================================================================================ +TestLoaderFileWithQueryParameter +---------- /out/file-UEHVHXRQ.txt ---------- +This is some text +---------- /out/entry.js ---------- +// file.txt?foo +var file_default = "./file-UEHVHXRQ.txt?foo"; + +// file.txt?bar +var file_default2 = "./file-UEHVHXRQ.txt?bar"; + +// entry.js +console.log(file_default, file_default2); + +================================================================================ +TestLoaderFromExtensionWithQueryParameter +---------- /out/entry.js ---------- +// file.abc?query.xyz +var file_default = "This should not be base64 encoded"; + +// entry.js +console.log(file_default); + ================================================================================ TestLoaderJSONCommonJSAndES6 ---------- /out.js ---------- @@ -516,1219 +682,6 @@ var y_default = "y"; var x_txt = require_x(); console.log(x_txt, y_default); -================================================================================ -TestMangleNoQuotedProps ----------- /out/entry.js ---------- -x["_doNotMangleThis"]; -x?.["_doNotMangleThis"]; -x[y ? "_doNotMangleThis" : z]; -x?.[y ? "_doNotMangleThis" : z]; -x[y ? z : "_doNotMangleThis"]; -x?.[y ? z : "_doNotMangleThis"]; -({ "_doNotMangleThis": x }); -(class { - "_doNotMangleThis" = x; -}); -var { "_doNotMangleThis": x } = y; -"_doNotMangleThis" in x; -(y ? "_doNotMangleThis" : z) in x; -(y ? z : "_doNotMangleThis") in x; - -================================================================================ -TestMangleNoQuotedPropsMinifySyntax ----------- /out/entry.js ---------- -x._doNotMangleThis, x?._doNotMangleThis, x[y ? "_doNotMangleThis" : z], x?.[y ? "_doNotMangleThis" : z], x[y ? z : "_doNotMangleThis"], x?.[y ? z : "_doNotMangleThis"], class { - _doNotMangleThis = x; -}; -var { _doNotMangleThis: x } = y; -"_doNotMangleThis" in x, (y ? "_doNotMangleThis" : z) in x, (y ? z : "_doNotMangleThis") in x; - -================================================================================ -TestMangleProps ----------- /out/entry1.js ---------- -export function shouldMangle() { - let foo = { - a: 0, - b() { - } - }; - let { a: bar_ } = foo; - ({ a: bar_ } = foo); - class foo_ { - a = 0; - b() { - } - static a = 0; - static b() { - } - } - return { a: bar_, c: foo_ }; -} -export function shouldNotMangle() { - let foo = { - "bar_": 0, - "baz_"() { - } - }; - let { "bar_": bar_ } = foo; - ({ "bar_": bar_ } = foo); - class foo_ { - "bar_" = 0; - "baz_"() { - } - static "bar_" = 0; - static "baz_"() { - } - } - return { "bar_": bar_, "foo_": foo_ }; -} - ----------- /out/entry2.js ---------- -export default { - a: 0, - "baz_": 1 -}; - -================================================================================ -TestManglePropsAvoidCollisions ----------- /out.js ---------- -export default { - c: 0, - d: 1, - a: 2, - b: 3, - __proto__: {} -}; - -================================================================================ -TestManglePropsImportExport ----------- /out/esm.js ---------- -export let foo_ = 123; -import { bar_ } from "xyz"; - ----------- /out/cjs.js ---------- -exports.a = 123; -let bar_ = require("xyz").b; - -================================================================================ -TestManglePropsImportExportBundled ----------- /out/entry-esm.js ---------- -// cjs.js -var require_cjs = __commonJS({ - "cjs.js"(exports) { - exports.a = "foo"; - } -}); - -// esm.js -var esm_exports = {}; -__export(esm_exports, { - esm_foo_: () => esm_foo_ -}); -var esm_foo_ = "foo"; - -// entry-esm.js -var import_cjs = __toESM(require_cjs()); -var cjs = __toESM(require_cjs()); -var bar_ = [ - esm_foo_, - import_cjs.cjs_foo_, - esm_exports.b, - cjs.a -]; -export { - bar_ -}; - ----------- /out/entry-cjs.js ---------- -// esm.js -var esm_exports = {}; -__export(esm_exports, { - esm_foo_: () => esm_foo_ -}); -var esm_foo_; -var init_esm = __esm({ - "esm.js"() { - esm_foo_ = "foo"; - } -}); - -// cjs.js -var require_cjs = __commonJS({ - "cjs.js"(exports) { - exports.a = "foo"; - } -}); - -// entry-cjs.js -var require_entry_cjs = __commonJS({ - "entry-cjs.js"(exports) { - var { b: esm_foo_2 } = (init_esm(), __toCommonJS(esm_exports)); - var { a: cjs_foo_ } = require_cjs(); - exports.c = [ - esm_foo_2, - cjs_foo_ - ]; - } -}); -export default require_entry_cjs(); - -================================================================================ -TestManglePropsJSXPreserve ----------- /out.jsx ---------- -let Foo = { - a(props) { - return <>{props.b}; - }, - c: "hello, world" -}; -export default ; - -================================================================================ -TestManglePropsJSXTransform ----------- /out.js ---------- -let Foo = { - b(props) { - return /* @__PURE__ */ Foo.a(Foo.d, null, props.c); - }, - e: "hello, world", - a(...args) { - console.log("createElement", ...args); - }, - d(...args) { - console.log("Fragment", ...args); - } -}; -export default /* @__PURE__ */ Foo.a(Foo.b, { c: Foo.e }); - -================================================================================ -TestManglePropsJSXTransformNamespace ----------- /out.js ---------- -export default [ - /* @__PURE__ */ React.createElement(KEEP_THIS_, null), - /* @__PURE__ */ React.createElement("KEEP:THIS_", null), - /* @__PURE__ */ React.createElement("foo", { "KEEP:THIS_": true }) -]; - -================================================================================ -TestManglePropsKeywordPropertyMinify ----------- /out/entry.js ---------- -class Foo{static t={get s(){return 123}}} - -================================================================================ -TestManglePropsLoweredClassFields ----------- /out.js ---------- -class Foo { - constructor() { - __publicField(this, "a", 123); - } -} -__publicField(Foo, "b", 234); -Foo.b = new Foo().a; - -================================================================================ -TestManglePropsLoweredOptionalChain ----------- /out.js ---------- -export default function(x) { - var _a; - x.a; - (_a = x.a) == null ? void 0 : _a.call(x); - x == null ? void 0 : x.a; - x == null ? void 0 : x.a(); - x == null ? void 0 : x.a.b; - x == null ? void 0 : x.a.b(); - x == null ? void 0 : x["foo_"].b; - x == null ? void 0 : x.a["bar_"]; -} - -================================================================================ -TestManglePropsMinify ----------- /out/entry1.js ---------- -export function shouldMangle_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX() { - let X = { - X: 0, - Y() { - } - }, { X: Y } = X; - ({ X: Y } = X); - class t { - X = 0; - Y() { - } - static X = 0; - static Y() { - } - } - return { X: Y, t }; -} -export function shouldNotMangle_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY() { - let X = { - bar_: 0, - baz_() { - } - }, { bar_: Y } = X; - ({ bar_: Y } = X); - class t { - bar_ = 0; - baz_() { - } - static bar_ = 0; - static baz_() { - } - } - return { bar_: Y, foo_: t }; -} - ----------- /out/entry2.js ---------- -export default { - a: 0, - baz_: 1 -}; - -================================================================================ -TestManglePropsNoShorthand ----------- /out.js ---------- -export let yyyyy = ({ y }) => ({ y: y }); - -================================================================================ -TestManglePropsOptionalChain ----------- /out.js ---------- -export default function(x) { - x.a; - x.a?.(); - x?.a; - x?.a(); - x?.a.b; - x?.a.b(); - x?.["foo_"].b; - x?.a["bar_"]; -} - -================================================================================ -TestManglePropsShorthand ----------- /out.js ---------- -export let yyyyy = ({ y }) => ({ y }); - -================================================================================ -TestManglePropsSuperCall ----------- /out.js ---------- -class Foo { -} -class Bar extends Foo { - constructor() { - super(); - } -} - -================================================================================ -TestManglePropsTypeScriptFeatures ----------- /out/parameter-properties.js ---------- -class Foo { - constructor(KEEP_FIELD, MANGLE_FIELD_) { - this.KEEP_FIELD = KEEP_FIELD; - this.a = MANGLE_FIELD_; - } -} -let foo = new Foo(); -console.log(foo.KEEP_FIELD, foo.a); - ----------- /out/namespace-exports.js ---------- -var ns; -((ns2) => { - ns2.b = 1; - ns2.c = 2; - ns2.d = 3; - ({ i: { a: ns2.a } } = 4); - function MANGLE_FUNCTION_() { - } - ns2.g = MANGLE_FUNCTION_; - class MANGLE_CLASS_ { - } - ns2.h = MANGLE_CLASS_; - let MANGLE_NAMESPACE_; - ((MANGLE_NAMESPACE_2) => { - ; - })(MANGLE_NAMESPACE_ = ns2.e || (ns2.e = {})); - let MANGLE_ENUM_; - ((MANGLE_ENUM_2) => { - })(MANGLE_ENUM_ = ns2.f || (ns2.f = {})); - console.log({ - VAR: ns2.b, - LET: ns2.c, - CONST: ns2.d, - DESTRUCTURING: ns2.a, - FUNCTION: MANGLE_FUNCTION_, - CLASS: MANGLE_CLASS_, - NAMESPACE: MANGLE_NAMESPACE_, - ENUM: MANGLE_ENUM_ - }); -})(ns || (ns = {})); -console.log({ - VAR: ns.b, - LET: ns.c, - CONST: ns.d, - DESTRUCTURING: ns.a, - FUNCTION: ns.g, - CLASS: ns.h, - NAMESPACE: ns.e, - ENUM: ns.f -}); -((ns2) => { - console.log({ - VAR: ns2.b, - LET: ns2.c, - CONST: ns2.d, - DESTRUCTURING: ns2.a, - FUNCTION: ns2.g, - CLASS: ns2.h, - NAMESPACE: ns2.e, - ENUM: ns2.f - }); -})(ns || (ns = {})); - ----------- /out/enum-values.js ---------- -var TopLevelNumber = /* @__PURE__ */ ((TopLevelNumber2) => { - TopLevelNumber2[TopLevelNumber2["foo_"] = 0] = "foo_"; - return TopLevelNumber2; -})(TopLevelNumber || {}); -var TopLevelString = /* @__PURE__ */ ((TopLevelString2) => { - TopLevelString2["bar_"] = ""; - return TopLevelString2; -})(TopLevelString || {}); -console.log({ - foo: TopLevelNumber.a, - bar: TopLevelString.b -}); -function fn() { - let NestedNumber; - ((NestedNumber2) => { - NestedNumber2[NestedNumber2["foo_"] = 0] = "foo_"; - })(NestedNumber || (NestedNumber = {})); - let NestedString; - ((NestedString2) => { - NestedString2["bar_"] = ""; - })(NestedString || (NestedString = {})); - console.log({ - foo: TopLevelNumber.a, - bar: TopLevelString.b - }); -} - -================================================================================ -TestMangleQuotedProps ----------- /out/keep.js ---------- -foo("_keepThisProperty"); -foo((x, "_keepThisProperty")); -foo(x ? "_keepThisProperty" : "_keepThisPropertyToo"); -x[foo("_keepThisProperty")]; -x?.[foo("_keepThisProperty")]; -({ [foo("_keepThisProperty")]: x }); -(class { - [foo("_keepThisProperty")] = x; -}); -var { [foo("_keepThisProperty")]: x } = y; -foo("_keepThisProperty") in x; - ----------- /out/mangle.js ---------- -x.a; -x?.a; -x[y ? "a" : z]; -x?.[y ? "a" : z]; -x[y ? z : "a"]; -x?.[y ? z : "a"]; -x[y, "a"]; -x?.[y, "a"]; -({ a: x }); -({ ["a"]: x }); -({ [(y, "a")]: x }); -(class { - a = x; -}); -(class { - ["a"] = x; -}); -(class { - [(y, "a")] = x; -}); -var { a: x } = y; -var { ["a"]: x } = y; -var { [(z, "a")]: x } = y; -"a" in x; -(y ? "a" : z) in x; -(y ? z : "a") in x; -(y, "a") in x; - -================================================================================ -TestMangleQuotedPropsMinifySyntax ----------- /out/keep.js ---------- -foo("_keepThisProperty"), foo("_keepThisProperty"), foo(x ? "_keepThisProperty" : "_keepThisPropertyToo"), x[foo("_keepThisProperty")], x?.[foo("_keepThisProperty")], foo("_keepThisProperty") + "", class { - [foo("_keepThisProperty")] = x; -}; -var { [foo("_keepThisProperty")]: x } = y; -foo("_keepThisProperty") in x; - ----------- /out/mangle.js ---------- -x.a, x?.a, x[y ? "a" : z], x?.[y ? "a" : z], x[y ? z : "a"], x?.[y ? z : "a"], x[y, "a"], x?.[y, "a"], "a" + "", (y, "a") + "", class { - a = x; -}, class { - ["a"] = x; -}, class { - [(y, "a")] = x; -}; -var { a: x } = y, { ["a"]: x } = y, { [(z, "a")]: x } = y; -"a" in x, (y ? "a" : z) in x, (y ? z : "a") in x, y, "a" in x; - -================================================================================ -TestMetafileNoBundle ----------- /out/entry.js ---------- -import a from "pkg"; -import b from "./file"; -console.log( - a, - b, - require("pkg2"), - require("./file2"), - import("./dynamic") -); -let exported; - ----------- /out/entry.css ---------- -@import "pkg"; -@import "./file"; -a { - background: url(pkg2); -} -a { - background: url(./file2); -} ----------- metafile.json ---------- -{ - "inputs": { - "project/entry.js": { - "bytes": 191, - "imports": [] - }, - "project/entry.css": { - "bytes": 112, - "imports": [] - } - }, - "outputs": { - "out/entry.js": { - "imports": [ - { - "path": "pkg", - "kind": "import-statement", - "external": true - }, - { - "path": "./file", - "kind": "import-statement", - "external": true - }, - { - "path": "pkg2", - "kind": "require-call", - "external": true - }, - { - "path": "./file2", - "kind": "require-call", - "external": true - }, - { - "path": "./dynamic", - "kind": "dynamic-import", - "external": true - } - ], - "exports": [ - "exported" - ], - "entryPoint": "project/entry.js", - "inputs": { - "project/entry.js": { - "bytesInOutput": 148 - } - }, - "bytes": 148 - }, - "out/entry.css": { - "imports": [ - { - "path": "pkg", - "kind": "import-rule", - "external": true - }, - { - "path": "./file", - "kind": "import-rule", - "external": true - }, - { - "path": "pkg2", - "kind": "url-token", - "external": true - }, - { - "path": "./file2", - "kind": "url-token", - "external": true - } - ], - "entryPoint": "project/entry.css", - "inputs": { - "project/entry.css": { - "bytesInOutput": 65 - } - }, - "bytes": 98 - } - } -} - -================================================================================ -TestMetafileVariousCases ----------- /out/file-NVISQQTV.file ---------- -file ----------- /out/copy-O3Y5SCJE.copy ---------- -copy ----------- /out/entry.js ---------- -import { - __commonJS, - __require -} from "./chunk-3MN5TIYV.js"; - -// project/cjs.js -var require_cjs = __commonJS({ - "project/cjs.js"(exports, module) { - module.exports = 4; - } -}); - -// project/entry.js -import a from "extern-esm"; - -// project/esm.js -var esm_default = 1; - -// -var json_2_default = 2; - -// project/file.file -var file_default = "./file-NVISQQTV.file"; - -// project/entry.js -import e from "./copy-O3Y5SCJE.copy"; -console.log( - a, - esm_default, - json_2_default, - file_default, - e, - __require("extern-cjs"), - require_cjs(), - import("./dynamic-4QVDQQPM.js") -); -var exported; -export { - exported -}; - ----------- /out/dynamic-4QVDQQPM.js ---------- -import "./chunk-3MN5TIYV.js"; - -// project/dynamic.js -var dynamic_default = 5; -export { - dynamic_default as default -}; - ----------- /out/chunk-3MN5TIYV.js ---------- -export { - __require, - __commonJS -}; - ----------- /out/entry.css ---------- -@import "extern.css"; - -/* project/entry.css */ -a { - background: url(data:image/svg+xml,); -} -b { - background: url(./file-NVISQQTV.file); -} -c { - background: url(./copy-O3Y5SCJE.copy); -} -d { - background: url(extern.png); -} ----------- metafile.json ---------- -{ - "inputs": { - "project/esm.js": { - "bytes": 16, - "imports": [] - }, - "": { - "bytes": 1, - "imports": [] - }, - "project/file.file": { - "bytes": 4, - "imports": [] - }, - "project/copy.copy": { - "bytes": 4, - "imports": [] - }, - "project/cjs.js": { - "bytes": 18, - "imports": [] - }, - "project/dynamic.js": { - "bytes": 16, - "imports": [] - }, - "project/entry.js": { - "bytes": 333, - "imports": [ - { - "path": "extern-esm", - "kind": "import-statement", - "external": true - }, - { - "path": "project/esm.js", - "kind": "import-statement" - }, - { - "path": "", - "kind": "import-statement" - }, - { - "path": "project/file.file", - "kind": "import-statement" - }, - { - "path": "project/copy.copy", - "kind": "import-statement" - }, - { - "path": "extern-cjs", - "kind": "require-call", - "external": true - }, - { - "path": "project/cjs.js", - "kind": "require-call" - }, - { - "path": "project/dynamic.js", - "kind": "dynamic-import" - } - ] - }, - "project/inline.svg": { - "bytes": 6, - "imports": [] - }, - "project/entry.css": { - "bytes": 180, - "imports": [ - { - "path": "extern.css", - "kind": "import-rule", - "external": true - }, - { - "path": "project/inline.svg", - "kind": "url-token" - }, - { - "path": "project/file.file", - "kind": "url-token" - }, - { - "path": "project/copy.copy", - "kind": "url-token" - }, - { - "path": "extern.png", - "kind": "url-token", - "external": true - } - ] - } - }, - "outputs": { - "out/file-NVISQQTV.file": { - "imports": [], - "exports": [], - "inputs": { - "project/file.file": { - "bytesInOutput": 4 - } - }, - "bytes": 4 - }, - "out/copy-O3Y5SCJE.copy": { - "imports": [], - "exports": [], - "inputs": { - "project/copy.copy": { - "bytesInOutput": 4 - } - }, - "bytes": 4 - }, - "out/entry.js": { - "imports": [ - { - "path": "out/chunk-3MN5TIYV.js", - "kind": "import-statement" - }, - { - "path": "extern-esm", - "kind": "import-statement", - "external": true - }, - { - "path": "out/file-NVISQQTV.file", - "kind": "file-loader" - }, - { - "path": "out/copy-O3Y5SCJE.copy", - "kind": "import-statement" - }, - { - "path": "extern-cjs", - "kind": "require-call", - "external": true - }, - { - "path": "out/dynamic-4QVDQQPM.js", - "kind": "dynamic-import" - } - ], - "exports": [ - "exported" - ], - "entryPoint": "project/entry.js", - "inputs": { - "project/cjs.js": { - "bytesInOutput": 101 - }, - "project/entry.js": { - "bytesInOutput": 242 - }, - "project/esm.js": { - "bytesInOutput": 21 - }, - "": { - "bytesInOutput": 24 - }, - "project/file.file": { - "bytesInOutput": 48 - } - }, - "bytes": 642 - }, - "out/dynamic-4QVDQQPM.js": { - "imports": [ - { - "path": "out/chunk-3MN5TIYV.js", - "kind": "import-statement" - } - ], - "exports": [ - "default" - ], - "entryPoint": "project/dynamic.js", - "inputs": { - "project/dynamic.js": { - "bytesInOutput": 25 - } - }, - "bytes": 119 - }, - "out/chunk-3MN5TIYV.js": { - "imports": [], - "exports": [ - "__commonJS", - "__require" - ], - "inputs": {}, - "bytes": 38 - }, - "out/entry.css": { - "imports": [ - { - "path": "extern.css", - "kind": "import-rule", - "external": true - }, - { - "path": "data:image/svg+xml,", - "kind": "url-token" - }, - { - "path": "out/file-NVISQQTV.file", - "kind": "url-token" - }, - { - "path": "out/copy-O3Y5SCJE.copy", - "kind": "url-token" - }, - { - "path": "extern.png", - "kind": "url-token", - "external": true - } - ], - "entryPoint": "project/entry.css", - "inputs": { - "project/entry.css": { - "bytesInOutput": 193 - } - }, - "bytes": 230 - } - } -} - -================================================================================ -TestMetafileVeryLongExternalPaths ----------- /out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file ---------- - ----------- /out/bytesInOutput should be at least 99 (1).js ---------- -// project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file -var __default = "./111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file"; - -// project/bytesInOutput should be at least 99 (1).js -console.log(__default); - ----------- /out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy ---------- - ----------- /out/bytesInOutput should be at least 99 (2).js ---------- -// project/bytesInOutput should be at least 99 (2).js -import a from "./222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy"; -console.log(a); - ----------- /out/bytesInOutput should be at least 99 (3).js ---------- -// project/bytesInOutput should be at least 99 (3).js -import("./333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js").then(console.log); - ----------- /out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js ---------- - ----------- /out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file ---------- - ----------- /out/bytesInOutput should be at least 99.css ---------- -/* project/bytesInOutput should be at least 99.css */ -a { - background: url(./444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file); -} ----------- metafile.json ---------- -{ - "inputs": { - "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": { - "bytes": 0, - "imports": [] - }, - "project/bytesInOutput should be at least 99 (1).js": { - "bytes": 150, - "imports": [ - { - "path": "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file", - "kind": "import-statement" - } - ] - }, - "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy": { - "bytes": 0, - "imports": [] - }, - "project/bytesInOutput should be at least 99 (2).js": { - "bytes": 150, - "imports": [ - { - "path": "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy", - "kind": "import-statement" - } - ] - }, - "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js": { - "bytes": 0, - "imports": [] - }, - "project/bytesInOutput should be at least 99 (3).js": { - "bytes": 141, - "imports": [ - { - "path": "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js", - "kind": "dynamic-import" - } - ] - }, - "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file": { - "bytes": 0, - "imports": [] - }, - "project/bytesInOutput should be at least 99.css": { - "bytes": 136, - "imports": [ - { - "path": "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file", - "kind": "url-token" - } - ] - } - }, - "outputs": { - "out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file": { - "imports": [], - "exports": [], - "inputs": { - "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": { - "bytesInOutput": 0 - } - }, - "bytes": 0 - }, - "out/bytesInOutput should be at least 99 (1).js": { - "imports": [ - { - "path": "out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file", - "kind": "file-loader" - } - ], - "exports": [], - "entryPoint": "project/bytesInOutput should be at least 99 (1).js", - "inputs": { - "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": { - "bytesInOutput": 45 - }, - "project/bytesInOutput should be at least 99 (1).js": { - "bytesInOutput": 24 - } - }, - "bytes": 330 - }, - "out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy": { - "imports": [], - "exports": [], - "inputs": { - "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy": { - "bytesInOutput": 0 - } - }, - "bytes": 0 - }, - "out/bytesInOutput should be at least 99 (2).js": { - "imports": [ - { - "path": "out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy", - "kind": "import-statement" - } - ], - "exports": [], - "entryPoint": "project/bytesInOutput should be at least 99 (2).js", - "inputs": { - "project/bytesInOutput should be at least 99 (2).js": { - "bytesInOutput": 59 - } - }, - "bytes": 203 - }, - "out/bytesInOutput should be at least 99 (3).js": { - "imports": [ - { - "path": "out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js", - "kind": "dynamic-import" - } - ], - "exports": [], - "entryPoint": "project/bytesInOutput should be at least 99 (3).js", - "inputs": { - "project/bytesInOutput should be at least 99 (3).js": { - "bytesInOutput": 55 - } - }, - "bytes": 197 - }, - "out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js": { - "imports": [], - "exports": [], - "entryPoint": "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js", - "inputs": { - "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js": { - "bytesInOutput": 0 - } - }, - "bytes": 0 - }, - "out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file": { - "imports": [], - "exports": [], - "inputs": { - "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file": { - "bytesInOutput": 0 - } - }, - "bytes": 0 - }, - "out/bytesInOutput should be at least 99.css": { - "imports": [ - { - "path": "out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file", - "kind": "url-token" - } - ], - "entryPoint": "project/bytesInOutput should be at least 99.css", - "inputs": { - "project/bytesInOutput should be at least 99.css": { - "bytesInOutput": 52 - } - }, - "bytes": 196 - } - } -} - -================================================================================ -TestMinifiedJSXPreserveWithObjectSpread ----------- /out.js ---------- -// entry.jsx -var obj = { - before, - [key]: value, - key: value, - after -}; -; -; - -================================================================================ -TestMinifyIdentifiersImportPathFrequencyAnalysis ----------- /out/import.js ---------- -var o=123;console.log(o,"no identifier in this file should be named W, X, Y, or Z"); - ----------- /out/require.js ---------- -var i=r((t,e)=>{e.exports=123});var s=i();console.log(s,"no identifier in this file should be named A, B, C, or D"); - -================================================================================ -TestNamedFunctionExpressionArgumentCollision ----------- /out/entry.js ---------- -let x = function(foo) { - var foo; - return foo; -}; - -================================================================================ -TestNoWarnCommonJSExportsInESMPassThrough ----------- /out/cjs-in-esm.js ---------- -export let foo = 1; -exports.foo = 2; -module.exports = 3; - ----------- /out/import-in-cjs.js ---------- -import { foo } from "bar"; -exports.foo = foo; -module.exports = foo; - ----------- /out/no-warnings-here.js ---------- -console.log(module, exports); - -================================================================================ -TestNonDeterminismIssue2537 ----------- /out.js ---------- -// entry.ts -function b(o, e) { - let r = "teun"; - if (o) { - let u = function(n) { - return n * 2; - }, t = function(n) { - return n / 2; - }; - var i = u, a = t; - r = u(e) + t(e); - } - return r; -} -export { - b as aap -}; - -================================================================================ -TestOutputForAssertTypeJSON ----------- /out/foo-FYKHFNL2.copy ---------- -{} ----------- /out/js-entry.js ---------- -// foo.json -var foo_default = {}; - -// js-entry.js -import copy from "./foo-FYKHFNL2.copy" assert { type: "json" }; -use(foo_default, copy, foo_default, void 0); -export { - foo_default as default -}; - ----------- /out/ts-entry.js ---------- -// foo.json -var foo_default = {}; - -// ts-entry.ts -import copy from "./foo-FYKHFNL2.copy" assert { type: "json" }; -use(foo_default, copy, foo_default, void 0); -export { - foo_default as default -}; - -================================================================================ -TestPackageAlias ----------- /out.js ---------- -// node_modules/alias1/index.js -console.log(1); - -// node_modules/alias2/foo.js -console.log(2); - -// node_modules/alias3/index.js -console.log(3); - -// node_modules/alias4/index.js -console.log(4); - -// node_modules/alias5/foo.js -console.log(5); - -// alias6/dir/index.js -console.log(6); - -// alias7/dir/foo/index.js -console.log(7); - -// alias8/dir/pkg8/index.js -console.log(8); - -// alias9/some/file.js -console.log(9); - ================================================================================ TestRequireCustomExtensionBase64 ---------- /out.js ---------- @@ -1787,89 +740,3 @@ var require_test = __commonJS({ // entry.js console.log(require_test()); - -================================================================================ -TestReserveProps ----------- /out.js ---------- -export default { - a: 0, - _bar_: 1 -}; - -================================================================================ -TestToESMWrapperOmission ----------- /out/entry.js ---------- -var entry_exports = {}; -module.exports = __toCommonJS(entry_exports); -var import_a_nowrap = require("a_nowrap"); -var import_b_nowrap = require("b_nowrap"); -__reExport(entry_exports, require("c_nowrap"), module.exports); -var d = __toESM(require("d_WRAP")); -var import_e_WRAP = __toESM(require("e_WRAP")); -var import_f_WRAP = __toESM(require("f_WRAP")); -var import_g_WRAP = __toESM(require("g_WRAP")); -var h = __toESM(require("h_WRAP")); -var i = __toESM(require("i_WRAP")); -var j = __toESM(require("j_WRAP")); -(0, import_b_nowrap.b)(); -x = d.x; -(0, import_e_WRAP.default)(); -(0, import_f_WRAP.default)(); -(0, import_g_WRAP.__esModule)(); -x = h; -i.x(); -j.x``; -x = Promise.resolve().then(() => __toESM(require("k_WRAP"))); - -================================================================================ -TestWarnCommonJSExportsInESMBundle ----------- /out/cjs-in-esm.js ---------- -// cjs-in-esm.js -var cjs_in_esm_exports = {}; -__export(cjs_in_esm_exports, { - foo: () => foo -}); -module.exports = __toCommonJS(cjs_in_esm_exports); -var foo = 1; -exports.foo = 2; -module.exports = 3; - ----------- /out/import-in-cjs.js ---------- -// import-in-cjs.js -var import_bar = require("bar"); -exports.foo = import_bar.foo; -module.exports = import_bar.foo; - ----------- /out/no-warnings-here.js ---------- -// no-warnings-here.js -console.log(module, exports); - -================================================================================ -TestWarnCommonJSExportsInESMConvert ----------- /out/cjs-in-esm.js ---------- -var cjs_in_esm_exports = {}; -__export(cjs_in_esm_exports, { - foo: () => foo -}); -module.exports = __toCommonJS(cjs_in_esm_exports); -let foo = 1; -exports.foo = 2; -module.exports = 3; - ----------- /out/cjs-in-esm2.js ---------- -var cjs_in_esm2_exports = {}; -__export(cjs_in_esm2_exports, { - foo: () => foo -}); -module.exports = __toCommonJS(cjs_in_esm2_exports); -let foo = 1; -module.exports.bar = 3; - ----------- /out/import-in-cjs.js ---------- -var import_bar = require("bar"); -exports.foo = import_bar.foo; -module.exports = import_bar.foo; -module.exports.bar = import_bar.foo; - ----------- /out/no-warnings-here.js ---------- -console.log(module, exports); diff --git a/internal/bundler/snapshots/snapshots_packagejson.txt b/internal/bundler/snapshots/snapshots_packagejson.txt index 6755f448ee4..2879cb2f0e1 100644 --- a/internal/bundler/snapshots/snapshots_packagejson.txt +++ b/internal/bundler/snapshots/snapshots_packagejson.txt @@ -1,3 +1,9 @@ +TestCommonJSVariableInESMTypeModule +---------- /out.js ---------- +// entry.js +module.exports = null; + +================================================================================ TestPackageJsonBadMain ---------- /Users/user/project/out.js ---------- // Users/user/project/node_modules/demo-pkg/index.js diff --git a/internal/bundler/snapshots/snapshots_splitting.txt b/internal/bundler/snapshots/snapshots_splitting.txt index ff32ebd7291..008e87b1ae3 100644 --- a/internal/bundler/snapshots/snapshots_splitting.txt +++ b/internal/bundler/snapshots/snapshots_splitting.txt @@ -1,9 +1,3 @@ -TestBundlingFilesOutsideOfOutbase ----------- /out/_.._/_.._/_.._/src/entry.js ---------- -// src/entry.js -console.log("test"); - -================================================================================ TestSplittingAssignToLocal ---------- /out/a.js ---------- import { @@ -578,248 +572,3 @@ export { a, b }; - -================================================================================ -TestVarRelocatingBundle ----------- /out/top-level.js ---------- -// top-level.js -for (; 0; ) - ; -var b; -for ({ c, x: [d] } = {}; 0; ) - ; -var c; -var d; -for (e of []) - ; -var e; -for ({ f, x: [g] } of []) - ; -var f; -var g; -for (h in {}) - ; -var h; -i = 1; -for (i in {}) - ; -var i; -for ({ j, x: [k] } in {}) - ; -var j; -var k; - ----------- /out/nested.js ---------- -// nested.js -if (true) { - let l = function() { - }; - l2 = l; - for (; 0; ) - ; - for ({ c, x: [d] } = {}; 0; ) - ; - for (e of []) - ; - for ({ f, x: [g] } of []) - ; - for (h in {}) - ; - i = 1; - for (i in {}) - ; - for ({ j, x: [k] } in {}) - ; -} -var a; -var b; -var c; -var d; -var e; -var f; -var g; -var h; -var i; -var j; -var k; -var l2; - ----------- /out/let.js ---------- -// let.js -if (true) { - let a; - for (let b; 0; ) - ; - for (let { c, x: [d] } = {}; 0; ) - ; - for (let e of []) - ; - for (let { f, x: [g] } of []) - ; - for (let h in {}) - ; - for (let { j, x: [k] } in {}) - ; -} - ----------- /out/function.js ---------- -// function.js -function x() { - var a; - for (var b; 0; ) - ; - for (var { c, x: [d] } = {}; 0; ) - ; - for (var e of []) - ; - for (var { f, x: [g] } of []) - ; - for (var h in {}) - ; - i = 1; - for (var i in {}) - ; - for (var { j, x: [k] } in {}) - ; - function l() { - } -} -x(); - ----------- /out/function-nested.js ---------- -// function-nested.js -function x() { - if (true) { - let l2 = function() { - }; - var l = l2; - var a; - for (var b; 0; ) - ; - for (var { c, x: [d] } = {}; 0; ) - ; - for (var e of []) - ; - for (var { f, x: [g] } of []) - ; - for (var h in {}) - ; - i = 1; - for (var i in {}) - ; - for (var { j, x: [k] } in {}) - ; - } -} -x(); - -================================================================================ -TestVarRelocatingNoBundle ----------- /out/top-level.js ---------- -var a; -for (var b; 0; ) - ; -for (var { c, x: [d] } = {}; 0; ) - ; -for (var e of []) - ; -for (var { f, x: [g] } of []) - ; -for (var h in {}) - ; -i = 1; -for (var i in {}) - ; -for (var { j, x: [k] } in {}) - ; -function l() { -} - ----------- /out/nested.js ---------- -if (true) { - let l = function() { - }; - var l2 = l; - var a; - for (var b; 0; ) - ; - for (var { c, x: [d] } = {}; 0; ) - ; - for (var e of []) - ; - for (var { f, x: [g] } of []) - ; - for (var h in {}) - ; - i = 1; - for (var i in {}) - ; - for (var { j, x: [k] } in {}) - ; -} - ----------- /out/let.js ---------- -if (true) { - let a; - for (let b; 0; ) - ; - for (let { c, x: [d] } = {}; 0; ) - ; - for (let e of []) - ; - for (let { f, x: [g] } of []) - ; - for (let h in {}) - ; - for (let { j, x: [k] } in {}) - ; -} - ----------- /out/function.js ---------- -function x() { - var a; - for (var b; 0; ) - ; - for (var { c, x: [d] } = {}; 0; ) - ; - for (var e of []) - ; - for (var { f, x: [g] } of []) - ; - for (var h in {}) - ; - i = 1; - for (var i in {}) - ; - for (var { j, x: [k] } in {}) - ; - function l() { - } -} -x(); - ----------- /out/function-nested.js ---------- -function x() { - if (true) { - let l2 = function() { - }; - var l = l2; - var a; - for (var b; 0; ) - ; - for (var { c, x: [d] } = {}; 0; ) - ; - for (var e of []) - ; - for (var { f, x: [g] } of []) - ; - for (var h in {}) - ; - i = 1; - for (var i in {}) - ; - for (var { j, x: [k] } in {}) - ; - } -} -x(); diff --git a/internal/bundler/snapshots/snapshots_ts.txt b/internal/bundler/snapshots/snapshots_ts.txt index 337175276b8..83cf33dab9b 100644 --- a/internal/bundler/snapshots/snapshots_ts.txt +++ b/internal/bundler/snapshots/snapshots_ts.txt @@ -1,9 +1,3 @@ -TestCommonJSVariableInESMTypeModule ----------- /out.js ---------- -// entry.js -module.exports = null; - -================================================================================ TestExportTypeIssue379 ---------- /out.js ---------- // a.ts @@ -37,12 +31,89 @@ var foo4 = 123; // entry.ts console.log(a_exports, b_exports, c_exports, d_exports); +================================================================================ +TestTSAbstractClassFieldUseAssign +---------- /out.js ---------- +const keepThis = Symbol("keepThis"); +class Foo { +} +keepThis; +(() => new Foo())(); + +================================================================================ +TestTSAbstractClassFieldUseDefine +---------- /out.js ---------- +const keepThisToo = Symbol("keepThisToo"); +class Foo { + keepThis; + [keepThisToo]; +} +(() => new Foo())(); + ================================================================================ TestTSCommonJSVariableInESMTypeModule ---------- /out.js ---------- // entry.ts module.exports = null; +================================================================================ +TestTSComputedClassFieldUseDefineFalse +---------- /out.js ---------- +var _a, _b, _c; +class Foo { + constructor() { + this[_a] = s; + this[_c] = z; + } +} +q, _a = r, _b = x, _c = y; +__decorateClass([ + dec +], Foo.prototype, _b, 2); +__decorateClass([ + dec +], Foo.prototype, _c, 2); +new Foo(); + +================================================================================ +TestTSComputedClassFieldUseDefineTrue +---------- /out.js ---------- +var _a, _b; +class Foo { + [q]; + [r] = s; + [_a = x]; + [_b = y] = z; +} +__decorateClass([ + dec +], Foo.prototype, _a, 2); +__decorateClass([ + dec +], Foo.prototype, _b, 2); +new Foo(); + +================================================================================ +TestTSComputedClassFieldUseDefineTrueLower +---------- /out.js ---------- +var _a, _b, _c, _d; +class Foo { + constructor() { + __publicField(this, _a); + __publicField(this, _b, s); + __publicField(this, _c); + __publicField(this, _d, z); + } +} +_a = q, _b = r, _c = x, _d = y; +__decorateClass([ + dec +], Foo.prototype, _c, 2); +__decorateClass([ + dec +], Foo.prototype, _d, 2); +new Foo(); + ================================================================================ TestTSConstEnumComments ---------- /out.js ---------- @@ -545,6 +616,19 @@ console.log("correct"); // order-jsx.ts console.log("correct"); +================================================================================ +TestTSImportCTS +---------- /out.js ---------- +// required.cjs +var require_required = __commonJS({ + "required.cjs"() { + console.log("works"); + } +}); + +// entry.ts +require_required(); + ================================================================================ TestTSImportEmptyNamespace ---------- /out.js ---------- @@ -590,6 +674,12 @@ import { foo } from "pkg"; const used = foo.used; export { used }; +================================================================================ +TestTSImportMTS +---------- /out.js ---------- +// imported.mts +console.log("works"); + ================================================================================ TestTSImportMissingUnusedES6 ---------- /out.js ---------- @@ -884,6 +974,10 @@ export var x; x2.z = x2.y; })(x || (x = {})); +================================================================================ +TestTSSideEffectsFalseWarningTypeDeclarations +---------- /out.js ---------- + ================================================================================ TestTSThisIsUndefinedWarning ---------- /out/warning1.js ---------- @@ -921,6 +1015,203 @@ export { foo }; +================================================================================ +TestThisInsideFunctionTS +---------- /out.js ---------- +// entry.ts +function foo(x = this) { + console.log(this); +} +var objFoo = { + foo(x = this) { + console.log(this); + } +}; +var _Foo = class { + constructor() { + this.x = this; + } + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } +}; +var Foo = _Foo; +Foo.y = _Foo.z; +new Foo(foo(objFoo)); +if (nested) { + let bar = function(x = this) { + console.log(this); + }; + bar2 = bar; + const objBar = { + foo(x = this) { + console.log(this); + } + }; + const _Bar = class { + constructor() { + this.x = this; + } + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } + }; + let Bar = _Bar; + Bar.y = _Bar.z; + new Bar(bar(objBar)); +} +var bar2; + +================================================================================ +TestThisInsideFunctionTSNoBundle +---------- /out.js ---------- +function foo(x = this) { + console.log(this); +} +const objFoo = { + foo(x = this) { + console.log(this); + } +}; +const _Foo = class { + constructor() { + this.x = this; + } + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } +}; +let Foo = _Foo; +Foo.y = _Foo.z; +new Foo(foo(objFoo)); +if (nested) { + let bar2 = function(x = this) { + console.log(this); + }; + var bar = bar2; + const objBar = { + foo(x = this) { + console.log(this); + } + }; + const _Bar = class { + constructor() { + this.x = this; + } + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } + }; + let Bar = _Bar; + Bar.y = _Bar.z; + new Bar(bar2(objBar)); +} + +================================================================================ +TestThisInsideFunctionTSNoBundleUseDefineForClassFields +---------- /out.js ---------- +function foo(x = this) { + console.log(this); +} +const objFoo = { + foo(x = this) { + console.log(this); + } +}; +class Foo { + x = this; + static y = this.z; + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } +} +new Foo(foo(objFoo)); +if (nested) { + let bar2 = function(x = this) { + console.log(this); + }; + var bar = bar2; + const objBar = { + foo(x = this) { + console.log(this); + } + }; + class Bar { + x = this; + static y = this.z; + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } + } + new Bar(bar2(objBar)); +} + +================================================================================ +TestThisInsideFunctionTSUseDefineForClassFields +---------- /out.js ---------- +// entry.ts +function foo(x = this) { + console.log(this); +} +var objFoo = { + foo(x = this) { + console.log(this); + } +}; +var _Foo = class { + x = this; + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } +}; +var Foo = _Foo; +__publicField(Foo, "y", _Foo.z); +new Foo(foo(objFoo)); +if (nested) { + let bar = function(x = this) { + console.log(this); + }; + bar2 = bar; + const objBar = { + foo(x = this) { + console.log(this); + } + }; + class Bar { + x = this; + static y = this.z; + foo(x = this) { + console.log(this); + } + static bar(x = this) { + console.log(this); + } + } + new Bar(bar(objBar)); +} +var bar2; + ================================================================================ TestTypeScriptDecoratorScopeIssue2147 ---------- /out.js ----------