Skip to content

Commit eb0e118

Browse files
committed
metafile coverage for paths between output files
1 parent 7bf440d commit eb0e118

File tree

2 files changed

+241
-0
lines changed

2 files changed

+241
-0
lines changed

internal/bundler/bundler_default_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7214,3 +7214,46 @@ func TestMetafileNoBundle(t *testing.T) {
72147214
},
72157215
})
72167216
}
7217+
7218+
func TestMetafileVeryLongExternalPaths(t *testing.T) {
7219+
loader_suite.expectBundled(t, bundled{
7220+
files: map[string]string{
7221+
"/project/bytesInOutput should be at least 99 (1).js": `
7222+
import a from './` + strings.Repeat("1", 99) + `.file'
7223+
console.log(a)
7224+
`,
7225+
"/project/bytesInOutput should be at least 99 (2).js": `
7226+
import a from './` + strings.Repeat("2", 99) + `.copy'
7227+
console.log(a)
7228+
`,
7229+
"/project/bytesInOutput should be at least 99 (3).js": `
7230+
import('./` + strings.Repeat("3", 99) + `.js').then(console.log)
7231+
`,
7232+
"/project/bytesInOutput should be at least 99.css": `
7233+
a { background: url(` + strings.Repeat("4", 99) + `.file) }
7234+
`,
7235+
"/project/" + strings.Repeat("1", 99) + ".file": ``,
7236+
"/project/" + strings.Repeat("2", 99) + ".copy": ``,
7237+
"/project/" + strings.Repeat("3", 99) + ".js": ``,
7238+
"/project/" + strings.Repeat("4", 99) + ".file": ``,
7239+
},
7240+
entryPaths: []string{
7241+
"/project/bytesInOutput should be at least 99 (1).js",
7242+
"/project/bytesInOutput should be at least 99 (2).js",
7243+
"/project/bytesInOutput should be at least 99 (3).js",
7244+
"/project/bytesInOutput should be at least 99.css",
7245+
},
7246+
options: config.Options{
7247+
Mode: config.ModeBundle,
7248+
AbsOutputDir: "/out",
7249+
NeedsMetafile: true,
7250+
ExtensionToLoader: map[string]config.Loader{
7251+
".js": config.LoaderJS,
7252+
".css": config.LoaderCSS,
7253+
".file": config.LoaderFile,
7254+
".copy": config.LoaderCopy,
7255+
},
7256+
CodeSplitting: true,
7257+
},
7258+
})
7259+
}

internal/bundler/snapshots/snapshots_loader.txt

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,204 @@ d {
14001400
}
14011401
}
14021402

1403+
================================================================================
1404+
TestMetafileVeryLongExternalPaths
1405+
---------- /out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file ----------
1406+
1407+
---------- /out/bytesInOutput should be at least 99 (1).js ----------
1408+
// project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file
1409+
var __default = "./111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file";
1410+
1411+
// project/bytesInOutput should be at least 99 (1).js
1412+
console.log(__default);
1413+
1414+
---------- /out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy ----------
1415+
1416+
---------- /out/bytesInOutput should be at least 99 (2).js ----------
1417+
// project/bytesInOutput should be at least 99 (2).js
1418+
import a from "./222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy";
1419+
console.log(a);
1420+
1421+
---------- /out/bytesInOutput should be at least 99 (3).js ----------
1422+
// project/bytesInOutput should be at least 99 (3).js
1423+
import("./333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js").then(console.log);
1424+
1425+
---------- /out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js ----------
1426+
1427+
---------- /out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file ----------
1428+
1429+
---------- /out/bytesInOutput should be at least 99.css ----------
1430+
/* project/bytesInOutput should be at least 99.css */
1431+
a {
1432+
background: url(./444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file);
1433+
}
1434+
---------- metafile.json ----------
1435+
{
1436+
"inputs": {
1437+
"project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": {
1438+
"bytes": 0,
1439+
"imports": []
1440+
},
1441+
"project/bytesInOutput should be at least 99 (1).js": {
1442+
"bytes": 150,
1443+
"imports": [
1444+
{
1445+
"path": "project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file",
1446+
"kind": "import-statement"
1447+
}
1448+
]
1449+
},
1450+
"project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy": {
1451+
"bytes": 0,
1452+
"imports": []
1453+
},
1454+
"project/bytesInOutput should be at least 99 (2).js": {
1455+
"bytes": 150,
1456+
"imports": [
1457+
{
1458+
"path": "project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy",
1459+
"kind": "import-statement"
1460+
}
1461+
]
1462+
},
1463+
"project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js": {
1464+
"bytes": 0,
1465+
"imports": []
1466+
},
1467+
"project/bytesInOutput should be at least 99 (3).js": {
1468+
"bytes": 141,
1469+
"imports": [
1470+
{
1471+
"path": "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js",
1472+
"kind": "dynamic-import"
1473+
}
1474+
]
1475+
},
1476+
"project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file": {
1477+
"bytes": 0,
1478+
"imports": []
1479+
},
1480+
"project/bytesInOutput should be at least 99.css": {
1481+
"bytes": 136,
1482+
"imports": [
1483+
{
1484+
"path": "project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file",
1485+
"kind": "url-token"
1486+
}
1487+
]
1488+
}
1489+
},
1490+
"outputs": {
1491+
"out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file": {
1492+
"imports": [],
1493+
"exports": [],
1494+
"inputs": {
1495+
"project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": {
1496+
"bytesInOutput": 0
1497+
}
1498+
},
1499+
"bytes": 0
1500+
},
1501+
"out/bytesInOutput should be at least 99 (1).js": {
1502+
"imports": [
1503+
{
1504+
"path": "out/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-55DNWN2R.file",
1505+
"kind": "file-loader"
1506+
}
1507+
],
1508+
"exports": [],
1509+
"entryPoint": "project/bytesInOutput should be at least 99 (1).js",
1510+
"inputs": {
1511+
"project/111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.file": {
1512+
"bytesInOutput": 45
1513+
},
1514+
"project/bytesInOutput should be at least 99 (1).js": {
1515+
"bytesInOutput": 24
1516+
}
1517+
},
1518+
"bytes": 330
1519+
},
1520+
"out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy": {
1521+
"imports": [],
1522+
"exports": [],
1523+
"inputs": {
1524+
"project/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222.copy": {
1525+
"bytesInOutput": 0
1526+
}
1527+
},
1528+
"bytes": 0
1529+
},
1530+
"out/bytesInOutput should be at least 99 (2).js": {
1531+
"imports": [
1532+
{
1533+
"path": "out/222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222-55DNWN2R.copy",
1534+
"kind": "import-statement"
1535+
}
1536+
],
1537+
"exports": [],
1538+
"entryPoint": "project/bytesInOutput should be at least 99 (2).js",
1539+
"inputs": {
1540+
"project/bytesInOutput should be at least 99 (2).js": {
1541+
"bytesInOutput": 59
1542+
}
1543+
},
1544+
"bytes": 203
1545+
},
1546+
"out/bytesInOutput should be at least 99 (3).js": {
1547+
"imports": [
1548+
{
1549+
"path": "out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js",
1550+
"kind": "dynamic-import"
1551+
}
1552+
],
1553+
"exports": [],
1554+
"entryPoint": "project/bytesInOutput should be at least 99 (3).js",
1555+
"inputs": {
1556+
"project/bytesInOutput should be at least 99 (3).js": {
1557+
"bytesInOutput": 55
1558+
}
1559+
},
1560+
"bytes": 197
1561+
},
1562+
"out/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333-DH3FVEAA.js": {
1563+
"imports": [],
1564+
"exports": [],
1565+
"entryPoint": "project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js",
1566+
"inputs": {
1567+
"project/333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.js": {
1568+
"bytesInOutput": 0
1569+
}
1570+
},
1571+
"bytes": 0
1572+
},
1573+
"out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file": {
1574+
"imports": [],
1575+
"exports": [],
1576+
"inputs": {
1577+
"project/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444.file": {
1578+
"bytesInOutput": 0
1579+
}
1580+
},
1581+
"bytes": 0
1582+
},
1583+
"out/bytesInOutput should be at least 99.css": {
1584+
"imports": [
1585+
{
1586+
"path": "out/444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444-55DNWN2R.file",
1587+
"kind": "url-token"
1588+
}
1589+
],
1590+
"entryPoint": "project/bytesInOutput should be at least 99.css",
1591+
"inputs": {
1592+
"project/bytesInOutput should be at least 99.css": {
1593+
"bytesInOutput": 52
1594+
}
1595+
},
1596+
"bytes": 196
1597+
}
1598+
}
1599+
}
1600+
14031601
================================================================================
14041602
TestMinifiedJSXPreserveWithObjectSpread
14051603
---------- /out.js ----------

0 commit comments

Comments
 (0)