Skip to content

Commit

Permalink
metafile coverage for paths between output files
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Dec 14, 2022
1 parent 7bf440d commit eb0e118
Show file tree
Hide file tree
Showing 2 changed files with 241 additions and 0 deletions.
43 changes: 43 additions & 0 deletions internal/bundler/bundler_default_test.go
Expand Up @@ -7214,3 +7214,46 @@ func TestMetafileNoBundle(t *testing.T) {
},
})
}

func TestMetafileVeryLongExternalPaths(t *testing.T) {
loader_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'
console.log(a)
`,
"/project/bytesInOutput should be at least 99 (2).js": `
import a from './` + strings.Repeat("2", 99) + `.copy'
console.log(a)
`,
"/project/bytesInOutput should be at least 99 (3).js": `
import('./` + strings.Repeat("3", 99) + `.js').then(console.log)
`,
"/project/bytesInOutput should be at least 99.css": `
a { background: url(` + strings.Repeat("4", 99) + `.file) }
`,
"/project/" + strings.Repeat("1", 99) + ".file": ``,
"/project/" + strings.Repeat("2", 99) + ".copy": ``,
"/project/" + strings.Repeat("3", 99) + ".js": ``,
"/project/" + strings.Repeat("4", 99) + ".file": ``,
},
entryPaths: []string{
"/project/bytesInOutput should be at least 99 (1).js",
"/project/bytesInOutput should be at least 99 (2).js",
"/project/bytesInOutput should be at least 99 (3).js",
"/project/bytesInOutput should be at least 99.css",
},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputDir: "/out",
NeedsMetafile: true,
ExtensionToLoader: map[string]config.Loader{
".js": config.LoaderJS,
".css": config.LoaderCSS,
".file": config.LoaderFile,
".copy": config.LoaderCopy,
},
CodeSplitting: true,
},
})
}
198 changes: 198 additions & 0 deletions internal/bundler/snapshots/snapshots_loader.txt
Expand Up @@ -1400,6 +1400,204 @@ d {
}
}

================================================================================
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 ----------
Expand Down

0 comments on commit eb0e118

Please sign in to comment.