@qwik.dev/core 2.0.0-alpha.8 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.wasm.cjs +27 -27
- package/bindings/qwik.wasm.mjs +27 -27
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/index.cjs +3 -3
- package/dist/build/index.d.ts +22 -22
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +6 -6
- package/dist/core-internal.d.ts +4447 -3941
- package/dist/core.cjs +7974 -7742
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +7960 -7738
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +3839 -3777
- package/dist/core.prod.mjs +4183 -4168
- package/dist/insights/index.qwik.cjs +1 -4260
- package/dist/insights/index.qwik.mjs +63 -4251
- package/dist/insights/vite/index.cjs +1 -82
- package/dist/insights/vite/index.mjs +65 -37
- package/dist/insights/vite.d.ts +22 -0
- package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +599 -370
- package/dist/optimizer.d.ts +779 -707
- package/dist/optimizer.mjs +595 -414
- package/dist/preloader.cjs +269 -0
- package/dist/preloader.mjs +198 -0
- package/dist/qwikloader.debug.js +242 -222
- package/dist/qwikloader.js +1 -3
- package/dist/server.cjs +676 -574
- package/dist/server.d.ts +504 -402
- package/dist/server.mjs +647 -549
- package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +0 -2
- package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
- package/dist/starters/adapters/bun/src/entry.bun.ts +3 -2
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
- package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
- package/dist/starters/adapters/deno/src/entry.deno.ts +3 -2
- package/dist/starters/adapters/express/src/entry.express.tsx +5 -2
- package/dist/starters/adapters/fastify/src/entry.fastify.tsx +2 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +9 -1
- package/dist/starters/adapters/firebase/firebase.json +12 -1
- package/dist/starters/adapters/firebase/functions/index.js +2 -3
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
- package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -2
- package/dist/starters/adapters/static/README.md +4 -0
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
- package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
- package/dist/starters/features/partytown/package.json +4 -4
- package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
- package/dist/starters/features/postcss/postcss.config.js +1 -1
- package/dist/starters/features/service-worker/package.json +13 -0
- package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +4 -3
- package/dist/starters/features/tailwind/src/global.css +1 -1
- package/dist/starters/features/tailwind-v3/.vscode/settings.json +3 -0
- package/dist/starters/features/tailwind-v3/package.json +21 -0
- package/dist/starters/features/tailwind-v3/postcss.config.cjs +6 -0
- package/dist/starters/features/tailwind-v3/src/global.css +7 -0
- package/dist/starters/features/tailwind-v3/tailwind.config.js +8 -0
- package/dist/testing/index.cjs +8390 -8048
- package/dist/testing/index.d.ts +141 -140
- package/dist/testing/index.mjs +8378 -8044
- package/dist/testing/package.json +1 -1
- package/package.json +19 -11
- package/public.d.ts +10 -0
- package/server.d.ts +1 -0
- package/dist/insights/index.d.ts +0 -1
- package/dist/insights/vite/index.d.ts +0 -1
- package/dist/insights/vite/insights-plugin.d.ts +0 -10
- package/dist/prefetch/index.cjs +0 -4
- package/dist/prefetch/index.d.ts +0 -2
- package/dist/prefetch/index.mjs +0 -3
- package/dist/prefetch/package.json +0 -8
- package/dist/qwik-prefetch.debug.js +0 -244
- package/dist/qwik-prefetch.js +0 -1
package/dist/optimizer.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/optimizer 2.0.0-
|
|
3
|
+
* @qwik.dev/core/optimizer 2.0.0-beta.1-dev+495e8d9
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -1249,6 +1249,20 @@ function createPath(opts = {}) {
|
|
|
1249
1249
|
}
|
|
1250
1250
|
|
|
1251
1251
|
var QWIK_BINDING_MAP = {
|
|
1252
|
+
darwin: {
|
|
1253
|
+
arm64: [ {
|
|
1254
|
+
platform: "darwin",
|
|
1255
|
+
arch: "arm64",
|
|
1256
|
+
abi: null,
|
|
1257
|
+
platformArchABI: "qwik.darwin-arm64.node"
|
|
1258
|
+
} ],
|
|
1259
|
+
x64: [ {
|
|
1260
|
+
platform: "darwin",
|
|
1261
|
+
arch: "x64",
|
|
1262
|
+
abi: null,
|
|
1263
|
+
platformArchABI: "qwik.darwin-x64.node"
|
|
1264
|
+
} ]
|
|
1265
|
+
},
|
|
1252
1266
|
win32: {
|
|
1253
1267
|
x64: [ {
|
|
1254
1268
|
platform: "win32",
|
|
@@ -1256,11 +1270,19 @@ var QWIK_BINDING_MAP = {
|
|
|
1256
1270
|
abi: "msvc",
|
|
1257
1271
|
platformArchABI: "qwik.win32-x64-msvc.node"
|
|
1258
1272
|
} ]
|
|
1273
|
+
},
|
|
1274
|
+
linux: {
|
|
1275
|
+
x64: [ {
|
|
1276
|
+
platform: "linux",
|
|
1277
|
+
arch: "x64",
|
|
1278
|
+
abi: "gnu",
|
|
1279
|
+
platformArchABI: "qwik.linux-x64-gnu.node"
|
|
1280
|
+
} ]
|
|
1259
1281
|
}
|
|
1260
1282
|
};
|
|
1261
1283
|
|
|
1262
1284
|
var versions = {
|
|
1263
|
-
qwik: "2.0.0-
|
|
1285
|
+
qwik: "2.0.0-beta.1-dev+495e8d9"
|
|
1264
1286
|
};
|
|
1265
1287
|
|
|
1266
1288
|
async function getSystem() {
|
|
@@ -1402,13 +1424,13 @@ function prioritizeSymbolNames(manifest) {
|
|
|
1402
1424
|
return Object.keys(symbols).sort(((symbolNameA, symbolNameB) => {
|
|
1403
1425
|
const a = symbols[symbolNameA];
|
|
1404
1426
|
const b = symbols[symbolNameB];
|
|
1405
|
-
if ("
|
|
1427
|
+
if ("eventHandler" === a.ctxKind && "eventHandler" !== b.ctxKind) {
|
|
1406
1428
|
return -1;
|
|
1407
1429
|
}
|
|
1408
|
-
if ("
|
|
1430
|
+
if ("eventHandler" !== a.ctxKind && "eventHandler" === b.ctxKind) {
|
|
1409
1431
|
return 1;
|
|
1410
1432
|
}
|
|
1411
|
-
if ("
|
|
1433
|
+
if ("eventHandler" === a.ctxKind && "eventHandler" === b.ctxKind) {
|
|
1412
1434
|
const aIndex = EVENT_PRIORITY.indexOf(a.ctxName.toLowerCase());
|
|
1413
1435
|
const bIndex = EVENT_PRIORITY.indexOf(b.ctxName.toLowerCase());
|
|
1414
1436
|
if (aIndex > -1 && bIndex > -1) {
|
|
@@ -1518,23 +1540,138 @@ function getValidManifest(manifest) {
|
|
|
1518
1540
|
return;
|
|
1519
1541
|
}
|
|
1520
1542
|
|
|
1521
|
-
|
|
1543
|
+
var getBundleInteractivity = (bundle, manifest) => {
|
|
1544
|
+
let maxScore = 0;
|
|
1545
|
+
if (bundle.symbols) {
|
|
1546
|
+
for (const symbolName of bundle.symbols) {
|
|
1547
|
+
let score = 1;
|
|
1548
|
+
const symbol = manifest.symbols[symbolName];
|
|
1549
|
+
if (symbol) {
|
|
1550
|
+
if ("function" === symbol.ctxKind) {
|
|
1551
|
+
/(component|useStyles|useStylesScoped)/i.test(symbol.ctxName) ? score += 1 : /(useComputed|useTask|useVisibleTask|useOn)/i.test(symbol.ctxName) && (score += 2);
|
|
1552
|
+
} else {
|
|
1553
|
+
score += 1;
|
|
1554
|
+
/(click|mouse|pointer|touch|key|scroll|gesture|wheel)/i.test(symbol.ctxName) && (score += 3);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
maxScore = Math.max(maxScore, score);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
return maxScore;
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
function computeTotals(graph) {
|
|
1564
|
+
let index = 0;
|
|
1565
|
+
const stack = [];
|
|
1566
|
+
const sccList = [];
|
|
1567
|
+
const idx = new Map;
|
|
1568
|
+
const low = new Map;
|
|
1569
|
+
const onStack = new Set;
|
|
1570
|
+
function strongConnect(v) {
|
|
1571
|
+
idx.set(v, index);
|
|
1572
|
+
low.set(v, index);
|
|
1573
|
+
index++;
|
|
1574
|
+
stack.push(v);
|
|
1575
|
+
onStack.add(v);
|
|
1576
|
+
const children = graph[v].imports || [];
|
|
1577
|
+
for (const w of children) {
|
|
1578
|
+
if (idx.has(w)) {
|
|
1579
|
+
onStack.has(w) && low.set(v, Math.min(low.get(v), idx.get(w)));
|
|
1580
|
+
} else {
|
|
1581
|
+
strongConnect(w);
|
|
1582
|
+
low.set(v, Math.min(low.get(v), low.get(w)));
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
if (low.get(v) === idx.get(v)) {
|
|
1586
|
+
const comp = [];
|
|
1587
|
+
let x;
|
|
1588
|
+
do {
|
|
1589
|
+
x = stack.pop();
|
|
1590
|
+
onStack.delete(x);
|
|
1591
|
+
comp.push(x);
|
|
1592
|
+
} while (x !== v);
|
|
1593
|
+
sccList.push(comp);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
for (const v of Object.keys(graph)) {
|
|
1597
|
+
idx.has(v) || strongConnect(v);
|
|
1598
|
+
}
|
|
1599
|
+
const sccIndex = new Map;
|
|
1600
|
+
sccList.forEach(((comp, i) => {
|
|
1601
|
+
for (const v of comp) {
|
|
1602
|
+
sccIndex.set(v, i);
|
|
1603
|
+
}
|
|
1604
|
+
}));
|
|
1605
|
+
const sccDAG = Array.from({
|
|
1606
|
+
length: sccList.length
|
|
1607
|
+
}, (() => new Set));
|
|
1608
|
+
for (const v of Object.keys(graph)) {
|
|
1609
|
+
const i = sccIndex.get(v);
|
|
1610
|
+
for (const w of graph[v].imports || []) {
|
|
1611
|
+
const j = sccIndex.get(w);
|
|
1612
|
+
i !== j && sccDAG[i].add(j);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
const visited = new Set;
|
|
1616
|
+
const order = [];
|
|
1617
|
+
function dfsSCC(u) {
|
|
1618
|
+
visited.add(u);
|
|
1619
|
+
for (const v of sccDAG[u]) {
|
|
1620
|
+
visited.has(v) || dfsSCC(v);
|
|
1621
|
+
}
|
|
1622
|
+
order.push(u);
|
|
1623
|
+
}
|
|
1624
|
+
for (let i = 0; i < sccList.length; i++) {
|
|
1625
|
+
visited.has(i) || dfsSCC(i);
|
|
1626
|
+
}
|
|
1627
|
+
order.reverse();
|
|
1628
|
+
const sccTotals = new Array(sccList.length).fill(0);
|
|
1629
|
+
for (let i = 0; i < sccList.length; i++) {
|
|
1630
|
+
let sumSize = 0;
|
|
1631
|
+
for (const nodeId of sccList[i]) {
|
|
1632
|
+
sumSize += graph[nodeId].size;
|
|
1633
|
+
}
|
|
1634
|
+
sccTotals[i] = sumSize;
|
|
1635
|
+
}
|
|
1636
|
+
for (let k = order.length - 1; k >= 0; k--) {
|
|
1637
|
+
const sccId = order[k];
|
|
1638
|
+
let total = sccTotals[sccId];
|
|
1639
|
+
for (const child of sccDAG[sccId]) {
|
|
1640
|
+
total += sccTotals[child];
|
|
1641
|
+
}
|
|
1642
|
+
sccTotals[sccId] = total;
|
|
1643
|
+
}
|
|
1644
|
+
for (let i = 0; i < sccList.length; i++) {
|
|
1645
|
+
const total = sccTotals[i];
|
|
1646
|
+
for (const nodeId of sccList[i]) {
|
|
1647
|
+
graph[nodeId].total = total;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
function generateManifestFromBundles(path, segments, injections, outputBundles, opts, debug, canonPath) {
|
|
1522
1653
|
var _a;
|
|
1523
1654
|
const manifest = {
|
|
1524
|
-
manifestHash: "",
|
|
1525
|
-
symbols: {},
|
|
1526
|
-
mapping: {},
|
|
1527
|
-
bundles: {},
|
|
1528
|
-
injections: injections,
|
|
1529
1655
|
version: "1",
|
|
1656
|
+
manifestHash: "",
|
|
1530
1657
|
options: {
|
|
1531
1658
|
target: opts.target,
|
|
1532
1659
|
buildMode: opts.buildMode,
|
|
1533
|
-
entryStrategy: opts.entryStrategy
|
|
1534
|
-
|
|
1660
|
+
entryStrategy: opts.entryStrategy && {
|
|
1661
|
+
type: opts.entryStrategy.type
|
|
1662
|
+
}
|
|
1663
|
+
},
|
|
1664
|
+
core: void 0,
|
|
1665
|
+
preloader: void 0,
|
|
1666
|
+
qwikLoader: void 0,
|
|
1667
|
+
bundleGraphAsset: void 0,
|
|
1668
|
+
injections: injections,
|
|
1669
|
+
mapping: {},
|
|
1670
|
+
bundles: {},
|
|
1671
|
+
assets: {},
|
|
1672
|
+
symbols: {},
|
|
1673
|
+
bundleGraph: void 0
|
|
1535
1674
|
};
|
|
1536
|
-
const buildPath = path.resolve(opts.rootDir, opts.outDir, "build");
|
|
1537
|
-
const canonPath = p => path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
|
|
1538
1675
|
const getBundleName = name => {
|
|
1539
1676
|
const bundle = outputBundles[name];
|
|
1540
1677
|
if (!bundle) {
|
|
@@ -1543,24 +1680,24 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
|
|
|
1543
1680
|
}
|
|
1544
1681
|
return canonPath(bundle.fileName);
|
|
1545
1682
|
};
|
|
1683
|
+
let qwikHandlersName;
|
|
1546
1684
|
const qrlNames = new Set(segments.map((h => h.name)));
|
|
1547
|
-
for (const symbol of extraSymbols) {
|
|
1548
|
-
qrlNames.add(symbol);
|
|
1549
|
-
}
|
|
1550
|
-
const taskNames = new Set(segments.filter((h => /use[a-zA-Z]*Task(_\d+)?$/.test(h.displayName))).map((h => h.name)));
|
|
1551
1685
|
for (const outputBundle of Object.values(outputBundles)) {
|
|
1552
|
-
if ("
|
|
1686
|
+
if ("asset" === outputBundle.type) {
|
|
1687
|
+
outputBundle.fileName.endsWith("js.map") || (manifest.assets[outputBundle.fileName] = {
|
|
1688
|
+
name: outputBundle.names[0],
|
|
1689
|
+
size: outputBundle.source.length
|
|
1690
|
+
});
|
|
1553
1691
|
continue;
|
|
1554
1692
|
}
|
|
1555
1693
|
const bundleFileName = canonPath(outputBundle.fileName);
|
|
1694
|
+
const size = outputBundle.code.length;
|
|
1556
1695
|
const bundle = {
|
|
1557
|
-
size:
|
|
1696
|
+
size: size,
|
|
1697
|
+
total: -1
|
|
1558
1698
|
};
|
|
1559
1699
|
for (const symbol of outputBundle.exports) {
|
|
1560
|
-
|
|
1561
|
-
taskNames.has(symbol) && (bundle.isTask = true);
|
|
1562
|
-
manifest.mapping[symbol] = bundleFileName;
|
|
1563
|
-
}
|
|
1700
|
+
qrlNames.has(symbol) && (manifest.mapping[symbol] && 1 === outputBundle.exports.length || (manifest.mapping[symbol] = bundleFileName));
|
|
1564
1701
|
}
|
|
1565
1702
|
const bundleImports = outputBundle.imports.filter((i => outputBundle.code.includes(path.basename(i)))).map((i => getBundleName(i))).filter(Boolean);
|
|
1566
1703
|
bundleImports.length > 0 && (bundle.imports = bundleImports);
|
|
@@ -1568,7 +1705,13 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
|
|
|
1568
1705
|
bundleDynamicImports.length > 0 && (bundle.dynamicImports = bundleDynamicImports);
|
|
1569
1706
|
const ids = outputBundle.moduleIds || Object.keys(outputBundle.modules);
|
|
1570
1707
|
const modulePaths = ids.filter((m => !m.startsWith("\0"))).map((m => path.relative(opts.rootDir, m)));
|
|
1571
|
-
modulePaths.length > 0
|
|
1708
|
+
if (modulePaths.length > 0) {
|
|
1709
|
+
bundle.origins = modulePaths;
|
|
1710
|
+
modulePaths.some((m => /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(m))) && (manifest.preloader = bundleFileName);
|
|
1711
|
+
modulePaths.some((m => /[/\\](core|qwik)[/\\]dist[/\\]core(.min|.prod)?\.[cm]js$/.test(m))) && (manifest.core = bundleFileName);
|
|
1712
|
+
modulePaths.some((m => /[/\\](core|qwik)[/\\](dist[/\\])?qwikloader(\.debug)?\.[^/]*js$/.test(m))) && (manifest.qwikLoader = bundleFileName);
|
|
1713
|
+
modulePaths.some((m => /[/\\](core|qwik)[/\\]handlers\.[cm]js$/.test(m))) && (qwikHandlersName = bundleFileName);
|
|
1714
|
+
}
|
|
1572
1715
|
manifest.bundles[bundleFileName] = bundle;
|
|
1573
1716
|
}
|
|
1574
1717
|
for (const segment of segments) {
|
|
@@ -1580,33 +1723,182 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
|
|
|
1580
1723
|
}
|
|
1581
1724
|
((_a = manifest.bundles[bundle]).symbols || (_a.symbols = [])).push(symbol);
|
|
1582
1725
|
manifest.symbols[symbol] = {
|
|
1583
|
-
origin: segment.origin,
|
|
1584
1726
|
displayName: segment.displayName,
|
|
1585
|
-
canonicalFilename: segment.canonicalFilename,
|
|
1586
1727
|
hash: segment.hash,
|
|
1587
1728
|
ctxKind: segment.ctxKind,
|
|
1588
1729
|
ctxName: segment.ctxName,
|
|
1589
1730
|
captures: segment.captures,
|
|
1731
|
+
canonicalFilename: segment.canonicalFilename,
|
|
1590
1732
|
parent: segment.parent,
|
|
1591
|
-
|
|
1733
|
+
origin: segment.origin,
|
|
1734
|
+
loc: segment.loc,
|
|
1735
|
+
paramNames: segment.paramNames,
|
|
1736
|
+
captureNames: segment.captureNames
|
|
1592
1737
|
};
|
|
1593
1738
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1739
|
+
if (qwikHandlersName) {
|
|
1740
|
+
for (const symbol of extraSymbols) {
|
|
1741
|
+
manifest.symbols[symbol] = {
|
|
1742
|
+
origin: "Qwik core",
|
|
1743
|
+
displayName: symbol,
|
|
1744
|
+
canonicalFilename: "",
|
|
1745
|
+
hash: symbol,
|
|
1746
|
+
ctxKind: "function",
|
|
1747
|
+
ctxName: symbol,
|
|
1748
|
+
captures: false,
|
|
1749
|
+
parent: null,
|
|
1750
|
+
loc: [ 0, 0 ]
|
|
1751
|
+
};
|
|
1752
|
+
manifest.mapping[symbol] = qwikHandlersName;
|
|
1753
|
+
}
|
|
1754
|
+
} else {
|
|
1755
|
+
console.error("Qwik core bundle not found, is Qwik actually used in this project?");
|
|
1606
1756
|
}
|
|
1757
|
+
for (const bundle of Object.values(manifest.bundles)) {
|
|
1758
|
+
const interactivityScore = getBundleInteractivity(bundle, manifest);
|
|
1759
|
+
bundle.interactivity = interactivityScore;
|
|
1760
|
+
}
|
|
1761
|
+
computeTotals(manifest.bundles);
|
|
1607
1762
|
return updateSortAndPriorities(manifest);
|
|
1608
1763
|
}
|
|
1609
1764
|
|
|
1765
|
+
var minimumSpeed = 300;
|
|
1766
|
+
|
|
1767
|
+
var slowSize = .5 / (1024 * minimumSpeed / 8);
|
|
1768
|
+
|
|
1769
|
+
var getSymbolHash = symbolName => {
|
|
1770
|
+
const index = symbolName.lastIndexOf("_");
|
|
1771
|
+
if (index > -1) {
|
|
1772
|
+
return symbolName.slice(index + 1);
|
|
1773
|
+
}
|
|
1774
|
+
return symbolName;
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
function convertManifestToBundleGraph(manifest, bundleGraphAdders) {
|
|
1778
|
+
const bundleGraph = [];
|
|
1779
|
+
if (!manifest.bundles) {
|
|
1780
|
+
return [];
|
|
1781
|
+
}
|
|
1782
|
+
const graph = {
|
|
1783
|
+
...manifest.bundles
|
|
1784
|
+
};
|
|
1785
|
+
for (const [symbol, bundleName] of Object.entries(manifest.mapping)) {
|
|
1786
|
+
if (symbol.startsWith("_") && symbol.length < 10) {
|
|
1787
|
+
continue;
|
|
1788
|
+
}
|
|
1789
|
+
const hash = getSymbolHash(symbol);
|
|
1790
|
+
hash && (graph[hash] = {
|
|
1791
|
+
dynamicImports: [ bundleName ]
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
if (bundleGraphAdders) {
|
|
1795
|
+
const combined = {
|
|
1796
|
+
...manifest,
|
|
1797
|
+
bundles: graph
|
|
1798
|
+
};
|
|
1799
|
+
for (const adder of bundleGraphAdders) {
|
|
1800
|
+
const result = adder(combined);
|
|
1801
|
+
result && Object.assign(graph, result);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
for (const bundleName of Object.keys(graph)) {
|
|
1805
|
+
const bundle = graph[bundleName];
|
|
1806
|
+
const imports = bundle.imports?.filter((dep => graph[dep])) || [];
|
|
1807
|
+
const dynamicImports = bundle.dynamicImports?.filter((dep => graph[dep] && (graph[dep].symbols || graph[dep].origins?.some((o => !o.includes("node_modules")))))) || [];
|
|
1808
|
+
graph[bundleName] = {
|
|
1809
|
+
...bundle,
|
|
1810
|
+
imports: imports,
|
|
1811
|
+
dynamicImports: dynamicImports
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
const notUsed = new Set(Object.keys(graph));
|
|
1815
|
+
for (const bundleName of Object.keys(graph)) {
|
|
1816
|
+
for (const dep of graph[bundleName].imports) {
|
|
1817
|
+
notUsed.delete(dep);
|
|
1818
|
+
}
|
|
1819
|
+
for (const dep of graph[bundleName].dynamicImports) {
|
|
1820
|
+
notUsed.delete(dep);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
for (const bundleName of notUsed) {
|
|
1824
|
+
const bundle = graph[bundleName];
|
|
1825
|
+
bundle.imports?.length || bundle.dynamicImports?.length || delete graph[bundleName];
|
|
1826
|
+
}
|
|
1827
|
+
const names = Object.keys(graph);
|
|
1828
|
+
const map = new Map;
|
|
1829
|
+
const clearTransitiveDeps = (parentDeps, bundleName, seen = new Set) => {
|
|
1830
|
+
const bundle = graph[bundleName];
|
|
1831
|
+
for (const dep of bundle.imports) {
|
|
1832
|
+
parentDeps.has(dep) && parentDeps.delete(dep);
|
|
1833
|
+
if (!seen.has(dep)) {
|
|
1834
|
+
seen.add(dep);
|
|
1835
|
+
clearTransitiveDeps(parentDeps, dep, seen);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
for (const bundleName of names) {
|
|
1840
|
+
const bundle = graph[bundleName];
|
|
1841
|
+
const deps = new Set(bundle.imports);
|
|
1842
|
+
for (const depName of deps) {
|
|
1843
|
+
clearTransitiveDeps(deps, depName);
|
|
1844
|
+
}
|
|
1845
|
+
const dynDeps = new Set(bundle.dynamicImports);
|
|
1846
|
+
const depProbability = new Map;
|
|
1847
|
+
for (const depName of dynDeps) {
|
|
1848
|
+
clearTransitiveDeps(dynDeps, depName);
|
|
1849
|
+
const dep = graph[depName];
|
|
1850
|
+
let probability = .5;
|
|
1851
|
+
probability += .08 * (dep.interactivity || 0);
|
|
1852
|
+
if (bundle.origins && dep.origins) {
|
|
1853
|
+
for (const origin of bundle.origins) {
|
|
1854
|
+
if (dep.origins.some((o => o.startsWith(origin)))) {
|
|
1855
|
+
probability += .25;
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
dep.total > slowSize && (probability += probability > .5 ? .02 : -.02);
|
|
1861
|
+
dep.total < 1e3 && (probability += .15);
|
|
1862
|
+
depProbability.set(depName, Math.min(probability, .99));
|
|
1863
|
+
}
|
|
1864
|
+
if (dynDeps.size > 0) {
|
|
1865
|
+
const sorted = Array.from(dynDeps).sort(((a, b) => depProbability.get(b) - depProbability.get(a)));
|
|
1866
|
+
let lastProbability = -1;
|
|
1867
|
+
for (const depName of sorted) {
|
|
1868
|
+
if (depProbability.get(depName) !== lastProbability) {
|
|
1869
|
+
lastProbability = depProbability.get(depName);
|
|
1870
|
+
deps.add(-Math.round(10 * lastProbability));
|
|
1871
|
+
}
|
|
1872
|
+
deps.add(depName);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
const index = bundleGraph.length;
|
|
1876
|
+
bundleGraph.push(bundleName);
|
|
1877
|
+
for (let i = 0; i < deps.size; i++) {
|
|
1878
|
+
bundleGraph.push(null);
|
|
1879
|
+
}
|
|
1880
|
+
map.set(bundleName, {
|
|
1881
|
+
index: index,
|
|
1882
|
+
deps: deps
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
for (const bundleName of names) {
|
|
1886
|
+
const bundle = map.get(bundleName);
|
|
1887
|
+
let {index: index, deps: deps} = bundle;
|
|
1888
|
+
index++;
|
|
1889
|
+
for (const depName of deps) {
|
|
1890
|
+
if ("number" === typeof depName) {
|
|
1891
|
+
bundleGraph[index++] = depName;
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
const dep = map.get(depName);
|
|
1895
|
+
const depIndex = dep.index;
|
|
1896
|
+
bundleGraph[index++] = depIndex;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
return bundleGraph;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1610
1902
|
async function createLinter(sys, rootDir, tsconfigFileNames) {
|
|
1611
1903
|
const module = await sys.dynamicImport("eslint");
|
|
1612
1904
|
let eslint = new module.ESLint({
|
|
@@ -1617,23 +1909,16 @@ async function createLinter(sys, rootDir, tsconfigFileNames) {
|
|
|
1617
1909
|
if (invalidEslintConfig) {
|
|
1618
1910
|
const options = {
|
|
1619
1911
|
cache: true,
|
|
1620
|
-
useEslintrc: false,
|
|
1621
1912
|
overrideConfig: {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
tsconfigRootDir: rootDir,
|
|
1632
|
-
project: tsconfigFileNames,
|
|
1633
|
-
ecmaVersion: 2021,
|
|
1634
|
-
sourceType: "module",
|
|
1635
|
-
ecmaFeatures: {
|
|
1636
|
-
jsx: true
|
|
1913
|
+
languageOptions: {
|
|
1914
|
+
parserOptions: {
|
|
1915
|
+
tsconfigRootDir: rootDir,
|
|
1916
|
+
project: tsconfigFileNames,
|
|
1917
|
+
ecmaVersion: 2021,
|
|
1918
|
+
sourceType: "module",
|
|
1919
|
+
ecmaFeatures: {
|
|
1920
|
+
jsx: true
|
|
1921
|
+
}
|
|
1637
1922
|
}
|
|
1638
1923
|
}
|
|
1639
1924
|
}
|
|
@@ -1813,6 +2098,17 @@ function isWin(os) {
|
|
|
1813
2098
|
return "win32" === os;
|
|
1814
2099
|
}
|
|
1815
2100
|
|
|
2101
|
+
function parseId(originalId) {
|
|
2102
|
+
const [pathId, query] = originalId.split("?");
|
|
2103
|
+
const queryStr = query || "";
|
|
2104
|
+
return {
|
|
2105
|
+
originalId: originalId,
|
|
2106
|
+
pathId: pathId,
|
|
2107
|
+
query: queryStr ? `?${query}` : "",
|
|
2108
|
+
params: new URLSearchParams(queryStr)
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2111
|
+
|
|
1816
2112
|
var REG_CTX_NAME = [ "server" ];
|
|
1817
2113
|
|
|
1818
2114
|
var SERVER_STRIP_EXPORTS = [ "onGet", "onPost", "onPut", "onRequest", "onDelete", "onHead", "onOptions", "onPatch", "onStaticGenerate" ];
|
|
@@ -1825,18 +2121,18 @@ var ExperimentalFeatures = (ExperimentalFeatures2 => {
|
|
|
1825
2121
|
ExperimentalFeatures2.preventNavigate = "preventNavigate";
|
|
1826
2122
|
ExperimentalFeatures2.valibot = "valibot";
|
|
1827
2123
|
ExperimentalFeatures2.noSPA = "noSPA";
|
|
2124
|
+
ExperimentalFeatures2.enableRequestRewrite = "enableRequestRewrite";
|
|
1828
2125
|
ExperimentalFeatures2.webWorker = "webWorker";
|
|
1829
2126
|
ExperimentalFeatures2.insights = "insights";
|
|
1830
2127
|
return ExperimentalFeatures2;
|
|
1831
2128
|
})(ExperimentalFeatures || {});
|
|
1832
2129
|
|
|
1833
|
-
function
|
|
2130
|
+
function createQwikPlugin(optimizerOptions = {}) {
|
|
1834
2131
|
const id = `${Math.round(899 * Math.random()) + 100}`;
|
|
1835
2132
|
const clientResults = new Map;
|
|
1836
2133
|
const clientTransformedOutputs = new Map;
|
|
1837
2134
|
const serverTransformedOutputs = new Map;
|
|
1838
2135
|
const parentIds = new Map;
|
|
1839
|
-
const npmChunks = new Map;
|
|
1840
2136
|
let internalOptimizer = null;
|
|
1841
2137
|
let linter;
|
|
1842
2138
|
let diagnosticsCallback = () => {};
|
|
@@ -1848,7 +2144,7 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1848
2144
|
rootDir: null,
|
|
1849
2145
|
tsconfigFileNames: [ "./tsconfig.json" ],
|
|
1850
2146
|
input: null,
|
|
1851
|
-
outDir:
|
|
2147
|
+
outDir: "",
|
|
1852
2148
|
assetsDir: null,
|
|
1853
2149
|
resolveQwikBuild: true,
|
|
1854
2150
|
entryStrategy: null,
|
|
@@ -1856,7 +2152,6 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1856
2152
|
srcInputs: null,
|
|
1857
2153
|
sourcemap: !!optimizerOptions.sourcemap,
|
|
1858
2154
|
manifestInput: null,
|
|
1859
|
-
insightsManifest: null,
|
|
1860
2155
|
manifestOutput: null,
|
|
1861
2156
|
transformedModuleOutput: null,
|
|
1862
2157
|
scope: null,
|
|
@@ -1864,8 +2159,8 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1864
2159
|
imageDevTools: true,
|
|
1865
2160
|
clickToSource: [ "Alt" ]
|
|
1866
2161
|
},
|
|
1867
|
-
inlineStylesUpToBytes:
|
|
1868
|
-
lint:
|
|
2162
|
+
inlineStylesUpToBytes: 2e4,
|
|
2163
|
+
lint: false,
|
|
1869
2164
|
experimental: void 0
|
|
1870
2165
|
};
|
|
1871
2166
|
let lazyNormalizePath;
|
|
@@ -1899,8 +2194,8 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1899
2194
|
const path = optimizer2.sys.path;
|
|
1900
2195
|
opts.debug = !!updatedOpts.debug;
|
|
1901
2196
|
updatedOpts.assetsDir && (opts.assetsDir = updatedOpts.assetsDir);
|
|
1902
|
-
"ssr" === updatedOpts.target || "client" === updatedOpts.target || "lib" === updatedOpts.target || "test" === updatedOpts.target ? opts.target = updatedOpts.target : opts.target = "client";
|
|
1903
|
-
"lib" === opts.target ? opts.buildMode = "development" : "production" === updatedOpts.buildMode || "development" === updatedOpts.buildMode ? opts.buildMode = updatedOpts.buildMode : opts.buildMode = "development";
|
|
2197
|
+
"ssr" === updatedOpts.target || "client" === updatedOpts.target || "lib" === updatedOpts.target || "test" === updatedOpts.target ? opts.target = updatedOpts.target : opts.target || (opts.target = "client");
|
|
2198
|
+
"lib" === opts.target ? opts.buildMode = "development" : "production" === updatedOpts.buildMode || "development" === updatedOpts.buildMode ? opts.buildMode = updatedOpts.buildMode : opts.buildMode || (opts.buildMode = "development");
|
|
1904
2199
|
updatedOpts.entryStrategy && "object" === typeof updatedOpts.entryStrategy && (opts.entryStrategy = {
|
|
1905
2200
|
...updatedOpts.entryStrategy
|
|
1906
2201
|
});
|
|
@@ -1914,7 +2209,7 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1914
2209
|
type: "segment"
|
|
1915
2210
|
});
|
|
1916
2211
|
"string" === typeof updatedOpts.rootDir && (opts.rootDir = updatedOpts.rootDir);
|
|
1917
|
-
"string" !== typeof opts.rootDir && (opts.rootDir = optimizer2.sys.cwd());
|
|
2212
|
+
"string" !== typeof opts.rootDir && (opts.rootDir || (opts.rootDir = optimizer2.sys.cwd()));
|
|
1918
2213
|
opts.rootDir = normalizePath(path.resolve(optimizer2.sys.cwd(), opts.rootDir));
|
|
1919
2214
|
let srcDir = normalizePath(path.resolve(opts.rootDir, SRC_DIR_DEFAULT));
|
|
1920
2215
|
if ("string" === typeof updatedOpts.srcDir) {
|
|
@@ -1925,7 +2220,7 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1925
2220
|
opts.srcInputs = [ ...updatedOpts.srcInputs ];
|
|
1926
2221
|
opts.srcDir = null;
|
|
1927
2222
|
} else {
|
|
1928
|
-
opts.srcDir = srcDir;
|
|
2223
|
+
opts.srcDir || (opts.srcDir = srcDir);
|
|
1929
2224
|
}
|
|
1930
2225
|
Array.isArray(updatedOpts.tsconfigFileNames) && updatedOpts.tsconfigFileNames.length > 0 && (opts.tsconfigFileNames = updatedOpts.tsconfigFileNames);
|
|
1931
2226
|
Array.isArray(opts.srcInputs) ? opts.srcInputs.forEach((i => {
|
|
@@ -1937,9 +2232,9 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1937
2232
|
} else if ("string" === typeof updatedOpts.input) {
|
|
1938
2233
|
opts.input = [ updatedOpts.input ];
|
|
1939
2234
|
} else if ("ssr" === opts.target) {
|
|
1940
|
-
opts.input = [ path.resolve(srcDir, "entry.ssr") ];
|
|
2235
|
+
opts.input || (opts.input = [ path.resolve(srcDir, "entry.ssr") ]);
|
|
1941
2236
|
} else if ("client" === opts.target) {
|
|
1942
|
-
opts.input = [ path.resolve(srcDir, "root") ];
|
|
2237
|
+
opts.input || (opts.input = [ path.resolve(srcDir, "root") ]);
|
|
1943
2238
|
} else if ("lib" === opts.target) {
|
|
1944
2239
|
if ("object" === typeof updatedOpts.input) {
|
|
1945
2240
|
for (const key in updatedOpts.input) {
|
|
@@ -1955,36 +2250,37 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1955
2250
|
};
|
|
1956
2251
|
}
|
|
1957
2252
|
} else {
|
|
1958
|
-
opts.input = [ path.resolve(srcDir, "index.ts") ];
|
|
2253
|
+
opts.input || (opts.input = [ path.resolve(srcDir, "index.ts") ]);
|
|
1959
2254
|
}
|
|
1960
2255
|
} else {
|
|
1961
|
-
opts.input = [];
|
|
2256
|
+
opts.input || (opts.input = []);
|
|
1962
2257
|
}
|
|
1963
|
-
opts.input
|
|
2258
|
+
Array.isArray(opts.input) && (opts.input = opts.input.reduce(((inputs, i) => {
|
|
1964
2259
|
let input = i;
|
|
1965
2260
|
i.startsWith("@") || i.startsWith("~") || i.startsWith("#") || (input = normalizePath(path.resolve(opts.rootDir, i)));
|
|
1966
2261
|
inputs.includes(input) || inputs.push(input);
|
|
1967
2262
|
return inputs;
|
|
1968
|
-
}), [])
|
|
1969
|
-
"string" === typeof updatedOpts.outDir ? opts.outDir = normalizePath(path.resolve(opts.rootDir, normalizePath(updatedOpts.outDir))) : "ssr" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, SSR_OUT_DIR)) : "lib" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, LIB_OUT_DIR)) : opts.outDir = normalizePath(path.resolve(opts.rootDir, CLIENT_OUT_DIR));
|
|
2263
|
+
}), []));
|
|
2264
|
+
"string" === typeof updatedOpts.outDir ? opts.outDir = normalizePath(path.resolve(opts.rootDir, normalizePath(updatedOpts.outDir))) : opts.outDir || ("ssr" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, SSR_OUT_DIR)) : "lib" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, LIB_OUT_DIR)) : opts.outDir = normalizePath(path.resolve(opts.rootDir, CLIENT_OUT_DIR)));
|
|
1970
2265
|
}
|
|
1971
2266
|
"function" === typeof updatedOpts.manifestOutput && (opts.manifestOutput = updatedOpts.manifestOutput);
|
|
1972
2267
|
const clientManifest = getValidManifest(updatedOpts.manifestInput);
|
|
1973
2268
|
clientManifest && (opts.manifestInput = clientManifest);
|
|
1974
2269
|
"function" === typeof updatedOpts.transformedModuleOutput && (opts.transformedModuleOutput = updatedOpts.transformedModuleOutput);
|
|
1975
|
-
opts.scope = updatedOpts.scope
|
|
2270
|
+
void 0 !== updatedOpts.scope && (opts.scope = updatedOpts.scope);
|
|
1976
2271
|
"boolean" === typeof updatedOpts.resolveQwikBuild && (opts.resolveQwikBuild = updatedOpts.resolveQwikBuild);
|
|
1977
2272
|
if ("object" === typeof updatedOpts.devTools) {
|
|
1978
2273
|
"imageDevTools" in updatedOpts.devTools && (opts.devTools.imageDevTools = updatedOpts.devTools.imageDevTools);
|
|
1979
2274
|
"clickToSource" in updatedOpts.devTools && (opts.devTools.clickToSource = updatedOpts.devTools.clickToSource);
|
|
1980
2275
|
}
|
|
1981
2276
|
opts.csr = !!updatedOpts.csr;
|
|
1982
|
-
opts.inlineStylesUpToBytes = optimizerOptions.inlineStylesUpToBytes
|
|
1983
|
-
|
|
1984
|
-
"
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2277
|
+
"inlineStylesUpToBytes" in optimizerOptions && ("number" === typeof optimizerOptions.inlineStylesUpToBytes ? opts.inlineStylesUpToBytes = optimizerOptions.inlineStylesUpToBytes : ("number" !== typeof opts.inlineStylesUpToBytes || opts.inlineStylesUpToBytes < 0) && (opts.inlineStylesUpToBytes = 0));
|
|
2278
|
+
"boolean" === typeof updatedOpts.lint && (opts.lint = updatedOpts.lint);
|
|
2279
|
+
if ("experimental" in updatedOpts) {
|
|
2280
|
+
opts.experimental = void 0;
|
|
2281
|
+
for (const feature of updatedOpts.experimental ?? []) {
|
|
2282
|
+
ExperimentalFeatures[feature] ? (opts.experimental || (opts.experimental = {}))[feature] = true : console.error(`Qwik plugin: Unknown experimental feature: ${feature}`);
|
|
2283
|
+
}
|
|
1988
2284
|
}
|
|
1989
2285
|
return {
|
|
1990
2286
|
...opts
|
|
@@ -2037,7 +2333,16 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2037
2333
|
debug("transformedOutputs.clear()");
|
|
2038
2334
|
clientTransformedOutputs.clear();
|
|
2039
2335
|
serverTransformedOutputs.clear();
|
|
2040
|
-
|
|
2336
|
+
if ("client" === opts.target) {
|
|
2337
|
+
const ql = await _ctx.resolve("@qwik.dev/core/qwikloader.js", void 0, {
|
|
2338
|
+
skipSelf: true
|
|
2339
|
+
});
|
|
2340
|
+
ql && _ctx.emitFile({
|
|
2341
|
+
id: ql.id,
|
|
2342
|
+
type: "chunk",
|
|
2343
|
+
preserveSignature: "allow-extension"
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2041
2346
|
};
|
|
2042
2347
|
const getIsServer = viteOpts => devServer ? !!viteOpts?.ssr : "ssr" === opts.target || "test" === opts.target;
|
|
2043
2348
|
let resolveIdCount = 0;
|
|
@@ -2078,54 +2383,69 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2078
2383
|
id: QWIK_CLIENT_MANIFEST_ID,
|
|
2079
2384
|
moduleSideEffects: false
|
|
2080
2385
|
};
|
|
2081
|
-
} else if (pathId.endsWith(
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
shouldAddHandlers
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2386
|
+
} else if (devServer || isServer || !pathId.endsWith(QWIK_PRELOADER_ID)) {
|
|
2387
|
+
if (pathId.endsWith(QWIK_HANDLERS_ID)) {
|
|
2388
|
+
debug(`resolveId(${count})`, "Resolved", QWIK_HANDLERS_ID);
|
|
2389
|
+
result = {
|
|
2390
|
+
id: QWIK_HANDLERS_ID,
|
|
2391
|
+
moduleSideEffects: false
|
|
2392
|
+
};
|
|
2393
|
+
} else {
|
|
2394
|
+
if (!isServer && shouldAddHandlers && id2.endsWith("@qwik.dev/core")) {
|
|
2395
|
+
shouldAddHandlers = false;
|
|
2396
|
+
const key = await ctx.resolve("@qwik.dev/core/handlers.mjs", importerId, {
|
|
2397
|
+
skipSelf: true
|
|
2398
|
+
});
|
|
2399
|
+
if (!key) {
|
|
2400
|
+
throw new Error("Failed to resolve @qwik.dev/core/handlers.mjs");
|
|
2401
|
+
}
|
|
2402
|
+
ctx.emitFile({
|
|
2403
|
+
id: key.id,
|
|
2404
|
+
type: "chunk",
|
|
2405
|
+
preserveSignature: "allow-extension"
|
|
2406
|
+
});
|
|
2095
2407
|
}
|
|
2408
|
+
const qrlMatch = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(id2)?.groups;
|
|
2409
|
+
if (qrlMatch) {
|
|
2410
|
+
const {parent: parent, name: name, query: query} = qrlMatch;
|
|
2411
|
+
const resolvedParent = await ctx.resolve(parent, importerId, {
|
|
2412
|
+
skipSelf: true
|
|
2413
|
+
});
|
|
2414
|
+
if (resolvedParent) {
|
|
2415
|
+
const parentId = resolvedParent.id.split("?")[0];
|
|
2416
|
+
const isDevUrl = devServer && importerId?.endsWith(".html");
|
|
2417
|
+
const resolvedId = isDevUrl ? `${parentId}_${name}.js` : pathId;
|
|
2418
|
+
debug(`resolveId(${count})`, `resolved to QRL ${name} of ${parentId}`);
|
|
2419
|
+
parentIds.set(resolvedId, parentId);
|
|
2420
|
+
result = {
|
|
2421
|
+
id: resolvedId + query,
|
|
2422
|
+
moduleSideEffects: false
|
|
2423
|
+
};
|
|
2424
|
+
} else {
|
|
2425
|
+
console.error(`resolveId(${count})`, `QRL parent ${parent} does not exist!`);
|
|
2426
|
+
}
|
|
2427
|
+
} else if (importerId) {
|
|
2428
|
+
const importerParentId = parentIds.get(importerId);
|
|
2429
|
+
if (importerParentId) {
|
|
2430
|
+
debug(`resolveId(${count}) end`, `resolving via ${importerParentId}`);
|
|
2431
|
+
return ctx.resolve(id2, importerParentId, {
|
|
2432
|
+
skipSelf: true
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
} else {
|
|
2438
|
+
debug(`resolveId(${count})`, "Resolved", QWIK_PRELOADER_ID);
|
|
2439
|
+
const preloader = await ctx.resolve(QWIK_PRELOADER_ID, importerId, {
|
|
2440
|
+
skipSelf: true
|
|
2441
|
+
});
|
|
2442
|
+
if (preloader) {
|
|
2096
2443
|
ctx.emitFile({
|
|
2097
|
-
id:
|
|
2444
|
+
id: preloader.id,
|
|
2098
2445
|
type: "chunk",
|
|
2099
2446
|
preserveSignature: "allow-extension"
|
|
2100
2447
|
});
|
|
2101
|
-
|
|
2102
|
-
const qrlMatch = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(id2)?.groups;
|
|
2103
|
-
if (qrlMatch) {
|
|
2104
|
-
const {parent: parent, name: name, query: query} = qrlMatch;
|
|
2105
|
-
const resolvedParent = await ctx.resolve(parent, importerId, {
|
|
2106
|
-
skipSelf: true
|
|
2107
|
-
});
|
|
2108
|
-
if (resolvedParent) {
|
|
2109
|
-
const parentId = resolvedParent.id.split("?")[0];
|
|
2110
|
-
const isDevUrl = devServer && importerId?.endsWith(".html");
|
|
2111
|
-
const resolvedId = isDevUrl ? `${parentId}_${name}.js` : pathId;
|
|
2112
|
-
debug(`resolveId(${count})`, `resolved to QRL ${name} of ${parentId}`);
|
|
2113
|
-
parentIds.set(resolvedId, parentId);
|
|
2114
|
-
result = {
|
|
2115
|
-
id: resolvedId + query,
|
|
2116
|
-
moduleSideEffects: false
|
|
2117
|
-
};
|
|
2118
|
-
} else {
|
|
2119
|
-
console.error(`resolveId(${count})`, `QRL parent ${parent} does not exist!`);
|
|
2120
|
-
}
|
|
2121
|
-
} else if (importerId) {
|
|
2122
|
-
const importerParentId = parentIds.get(importerId);
|
|
2123
|
-
if (importerParentId) {
|
|
2124
|
-
debug(`resolveId(${count}) end`, `resolving via ${importerParentId}`);
|
|
2125
|
-
return ctx.resolve(id2, importerParentId, {
|
|
2126
|
-
skipSelf: true
|
|
2127
|
-
});
|
|
2128
|
-
}
|
|
2448
|
+
return preloader;
|
|
2129
2449
|
}
|
|
2130
2450
|
}
|
|
2131
2451
|
debug(`resolveId(${count}) end`, result?.id || result);
|
|
@@ -2307,12 +2627,18 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2307
2627
|
};
|
|
2308
2628
|
const createOutputAnalyzer = rollupBundle => {
|
|
2309
2629
|
const injections = [];
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2630
|
+
const outputAnalyzer = {
|
|
2631
|
+
addInjection: b => injections.push(b)
|
|
2632
|
+
};
|
|
2633
|
+
outputAnalyzer.generateManifest = async extra => {
|
|
2312
2634
|
const optimizer2 = getOptimizer();
|
|
2313
2635
|
const path = optimizer2.sys.path;
|
|
2636
|
+
const buildPath = path.resolve(opts.rootDir, opts.outDir, "build");
|
|
2637
|
+
const canonPath = p => path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
|
|
2638
|
+
outputAnalyzer.canonPath = canonPath;
|
|
2314
2639
|
const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h => !!h));
|
|
2315
|
-
const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug);
|
|
2640
|
+
const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug, canonPath);
|
|
2641
|
+
extra && Object.assign(manifest, extra);
|
|
2316
2642
|
for (const symbol of Object.values(manifest.symbols)) {
|
|
2317
2643
|
symbol.origin && (symbol.origin = normalizePath(symbol.origin));
|
|
2318
2644
|
}
|
|
@@ -2325,10 +2651,7 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2325
2651
|
manifest.manifestHash = hashCode(JSON.stringify(manifest));
|
|
2326
2652
|
return manifest;
|
|
2327
2653
|
};
|
|
2328
|
-
return
|
|
2329
|
-
addInjection: addInjection,
|
|
2330
|
-
generateManifest: generateManifest
|
|
2331
|
-
};
|
|
2654
|
+
return outputAnalyzer;
|
|
2332
2655
|
};
|
|
2333
2656
|
const getOptions = () => opts;
|
|
2334
2657
|
const getTransformedOutputs = () => Array.from(clientTransformedOutputs.values()).map((t => t[0]));
|
|
@@ -2348,7 +2671,18 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2348
2671
|
}
|
|
2349
2672
|
async function getQwikServerManifestModule(isServer) {
|
|
2350
2673
|
const manifest = isServer ? opts.manifestInput : null;
|
|
2351
|
-
|
|
2674
|
+
let serverManifest = null;
|
|
2675
|
+
manifest?.manifestHash && (serverManifest = {
|
|
2676
|
+
manifestHash: manifest.manifestHash,
|
|
2677
|
+
core: manifest.core,
|
|
2678
|
+
preloader: manifest.preloader,
|
|
2679
|
+
qwikLoader: manifest.qwikLoader,
|
|
2680
|
+
bundleGraphAsset: manifest.bundleGraphAsset,
|
|
2681
|
+
injections: manifest.injections,
|
|
2682
|
+
mapping: manifest.mapping,
|
|
2683
|
+
bundleGraph: manifest.bundleGraph
|
|
2684
|
+
});
|
|
2685
|
+
return `// @qwik-client-manifest\nexport const manifest = ${JSON.stringify(serverManifest)};\n`;
|
|
2352
2686
|
}
|
|
2353
2687
|
function setSourceMapSupport(sourcemap) {
|
|
2354
2688
|
opts.sourcemap = sourcemap;
|
|
@@ -2374,23 +2708,59 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2374
2708
|
}
|
|
2375
2709
|
}
|
|
2376
2710
|
function manualChunks(id2, {getModuleInfo: getModuleInfo}) {
|
|
2711
|
+
if ("client" === opts.target) {
|
|
2712
|
+
if (id2.endsWith("@qwik.dev/core/build") || /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(id2) || "\0vite/preload-helper.js" === id2) {
|
|
2713
|
+
return "qwik-preloader";
|
|
2714
|
+
}
|
|
2715
|
+
if (/[/\\](core|qwik)[/\\](handlers|dist[/\\]core(\.prod|\.min)?)\.[cm]js$/.test(id2)) {
|
|
2716
|
+
return "qwik-core";
|
|
2717
|
+
}
|
|
2718
|
+
if (/[/\\](core|qwik)[/\\]dist[/\\]qwikloader\.js$/.test(id2)) {
|
|
2719
|
+
return "qwik-loader";
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2377
2722
|
const module = getModuleInfo(id2);
|
|
2378
2723
|
const segment = module.meta.segment;
|
|
2379
2724
|
if (segment) {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
}
|
|
2386
|
-
const modulePath = id2.slice(moduleIndex + 12);
|
|
2387
|
-
const moduleName = id2.startsWith("@") ? modulePath.split("/").slice(0, 2).join("_") : modulePath.slice(0, modulePath.indexOf("/"));
|
|
2388
|
-
let size = module.code?.length || 0;
|
|
2389
|
-
size += npmChunks.get(moduleName) || 0;
|
|
2390
|
-
npmChunks.set(moduleName, size);
|
|
2391
|
-
if (size > 1e4) {
|
|
2392
|
-
return moduleName;
|
|
2725
|
+
const {hash: hash} = segment;
|
|
2726
|
+
const chunkName = opts.entryStrategy.manual?.[hash] || segment.entry;
|
|
2727
|
+
if (chunkName) {
|
|
2728
|
+
return chunkName;
|
|
2729
|
+
}
|
|
2393
2730
|
}
|
|
2731
|
+
return null;
|
|
2732
|
+
}
|
|
2733
|
+
async function generateManifest(ctx, rollupBundle, bundleGraphAdders, manifestExtra) {
|
|
2734
|
+
const outputAnalyzer = createOutputAnalyzer(rollupBundle);
|
|
2735
|
+
const manifest = await outputAnalyzer.generateManifest(manifestExtra);
|
|
2736
|
+
manifest.platform = {
|
|
2737
|
+
...manifestExtra?.platform,
|
|
2738
|
+
rollup: ctx.meta?.rollupVersion || "",
|
|
2739
|
+
env: optimizer.sys.env,
|
|
2740
|
+
os: optimizer.sys.os
|
|
2741
|
+
};
|
|
2742
|
+
"node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
|
|
2743
|
+
const bundleGraph = convertManifestToBundleGraph(manifest, bundleGraphAdders);
|
|
2744
|
+
const bgAsset = ctx.emitFile({
|
|
2745
|
+
type: "asset",
|
|
2746
|
+
name: "bundle-graph.json",
|
|
2747
|
+
source: JSON.stringify(bundleGraph)
|
|
2748
|
+
});
|
|
2749
|
+
const bgPath = ctx.getFileName(bgAsset);
|
|
2750
|
+
manifest.bundleGraphAsset = bgPath;
|
|
2751
|
+
manifest.assets[bgPath] = {
|
|
2752
|
+
name: "bundle-graph.json",
|
|
2753
|
+
size: bundleGraph.length
|
|
2754
|
+
};
|
|
2755
|
+
const manifestStr = JSON.stringify(manifest, null, "\t");
|
|
2756
|
+
ctx.emitFile({
|
|
2757
|
+
fileName: Q_MANIFEST_FILENAME,
|
|
2758
|
+
type: "asset",
|
|
2759
|
+
source: manifestStr
|
|
2760
|
+
});
|
|
2761
|
+
"function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
|
|
2762
|
+
"function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(getTransformedOutputs());
|
|
2763
|
+
return manifestStr;
|
|
2394
2764
|
}
|
|
2395
2765
|
return {
|
|
2396
2766
|
buildStart: buildStart,
|
|
@@ -2414,14 +2784,15 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2414
2784
|
setSourceMapSupport: setSourceMapSupport,
|
|
2415
2785
|
configureServer: configureServer,
|
|
2416
2786
|
handleHotUpdate: handleHotUpdate,
|
|
2417
|
-
manualChunks: manualChunks
|
|
2787
|
+
manualChunks: manualChunks,
|
|
2788
|
+
generateManifest: generateManifest
|
|
2418
2789
|
};
|
|
2419
2790
|
}
|
|
2420
2791
|
|
|
2421
2792
|
var makeNormalizePath = sys => id => {
|
|
2422
2793
|
if ("string" === typeof id) {
|
|
2423
2794
|
if (isWin(sys.os)) {
|
|
2424
|
-
const isExtendedLengthPath =
|
|
2795
|
+
const isExtendedLengthPath = id.startsWith("\\\\?\\");
|
|
2425
2796
|
if (!isExtendedLengthPath) {
|
|
2426
2797
|
const hasNonAscii = /[^\u0000-\u0080]+/.test(id);
|
|
2427
2798
|
hasNonAscii || (id = id.replace(/\\/g, "/"));
|
|
@@ -2437,17 +2808,6 @@ function isAdditionalFile(mod) {
|
|
|
2437
2808
|
return mod.isEntry || mod.segment;
|
|
2438
2809
|
}
|
|
2439
2810
|
|
|
2440
|
-
function parseId(originalId) {
|
|
2441
|
-
const [pathId, query] = originalId.split("?");
|
|
2442
|
-
const queryStr = query || "";
|
|
2443
|
-
return {
|
|
2444
|
-
originalId: originalId,
|
|
2445
|
-
pathId: pathId,
|
|
2446
|
-
query: queryStr ? `?${query}` : "",
|
|
2447
|
-
params: new URLSearchParams(queryStr)
|
|
2448
|
-
};
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
2811
|
var TRANSFORM_EXTS = {
|
|
2452
2812
|
".jsx": true,
|
|
2453
2813
|
".ts": true,
|
|
@@ -2470,6 +2830,8 @@ var QWIK_CORE_SERVER = "@qwik.dev/core/server";
|
|
|
2470
2830
|
|
|
2471
2831
|
var QWIK_CLIENT_MANIFEST_ID = "@qwik-client-manifest";
|
|
2472
2832
|
|
|
2833
|
+
var QWIK_PRELOADER_ID = "@qwik.dev/core/preloader";
|
|
2834
|
+
|
|
2473
2835
|
var QWIK_HANDLERS_ID = "@qwik-handlers";
|
|
2474
2836
|
|
|
2475
2837
|
var SRC_DIR_DEFAULT = "src";
|
|
@@ -2483,7 +2845,7 @@ var LIB_OUT_DIR = "lib";
|
|
|
2483
2845
|
var Q_MANIFEST_FILENAME = "q-manifest.json";
|
|
2484
2846
|
|
|
2485
2847
|
function qwikRollup(qwikRollupOpts = {}) {
|
|
2486
|
-
const qwikPlugin =
|
|
2848
|
+
const qwikPlugin = createQwikPlugin(qwikRollupOpts.optimizerOptions);
|
|
2487
2849
|
const rollupPlugin = {
|
|
2488
2850
|
name: "rollup-plugin-qwik",
|
|
2489
2851
|
api: {
|
|
@@ -2521,7 +2883,7 @@ function qwikRollup(qwikRollupOpts = {}) {
|
|
|
2521
2883
|
inputOpts.input || (inputOpts.input = opts.input);
|
|
2522
2884
|
return inputOpts;
|
|
2523
2885
|
},
|
|
2524
|
-
outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin
|
|
2886
|
+
outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, false),
|
|
2525
2887
|
async buildStart() {
|
|
2526
2888
|
qwikPlugin.onDiagnostics(((diagnostics, optimizer, srcDir) => {
|
|
2527
2889
|
diagnostics.forEach((d => {
|
|
@@ -2551,56 +2913,54 @@ function qwikRollup(qwikRollupOpts = {}) {
|
|
|
2551
2913
|
},
|
|
2552
2914
|
async generateBundle(_, rollupBundle) {
|
|
2553
2915
|
const opts = qwikPlugin.getOptions();
|
|
2554
|
-
|
|
2555
|
-
const optimizer = qwikPlugin.getOptimizer();
|
|
2556
|
-
const outputAnalyzer = qwikPlugin.createOutputAnalyzer(rollupBundle);
|
|
2557
|
-
const manifest = await outputAnalyzer.generateManifest();
|
|
2558
|
-
manifest.platform = {
|
|
2559
|
-
...versions,
|
|
2560
|
-
rollup: this.meta?.rollupVersion || "",
|
|
2561
|
-
env: optimizer.sys.env,
|
|
2562
|
-
os: optimizer.sys.os
|
|
2563
|
-
};
|
|
2564
|
-
"node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
|
|
2565
|
-
"function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
|
|
2566
|
-
"function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(qwikPlugin.getTransformedOutputs());
|
|
2567
|
-
this.emitFile({
|
|
2568
|
-
type: "asset",
|
|
2569
|
-
fileName: Q_MANIFEST_FILENAME,
|
|
2570
|
-
source: JSON.stringify(manifest, null, 2)
|
|
2571
|
-
});
|
|
2572
|
-
}
|
|
2916
|
+
"client" === opts.target && await qwikPlugin.generateManifest(this, rollupBundle);
|
|
2573
2917
|
}
|
|
2574
2918
|
};
|
|
2575
2919
|
return rollupPlugin;
|
|
2576
2920
|
}
|
|
2577
2921
|
|
|
2578
|
-
function normalizeRollupOutputOptions(
|
|
2922
|
+
function normalizeRollupOutputOptions(qwikPlugin, rollupOutputOpts, useAssetsDir, outDir) {
|
|
2579
2923
|
if (Array.isArray(rollupOutputOpts)) {
|
|
2580
2924
|
rollupOutputOpts.length || rollupOutputOpts.push({});
|
|
2581
2925
|
return rollupOutputOpts.map((outputOptsObj => ({
|
|
2582
|
-
...normalizeRollupOutputOptionsObject(
|
|
2926
|
+
...normalizeRollupOutputOptionsObject(qwikPlugin, outputOptsObj, useAssetsDir),
|
|
2583
2927
|
dir: outDir || outputOptsObj.dir
|
|
2584
2928
|
})));
|
|
2585
2929
|
}
|
|
2586
2930
|
return {
|
|
2587
|
-
...normalizeRollupOutputOptionsObject(
|
|
2931
|
+
...normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, useAssetsDir),
|
|
2588
2932
|
dir: outDir || rollupOutputOpts?.dir
|
|
2589
2933
|
};
|
|
2590
2934
|
}
|
|
2591
2935
|
|
|
2592
|
-
function normalizeRollupOutputOptionsObject(
|
|
2936
|
+
function normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOptsObj, useAssetsDir) {
|
|
2593
2937
|
const outputOpts = {
|
|
2594
2938
|
...rollupOutputOptsObj
|
|
2595
2939
|
};
|
|
2940
|
+
const opts = qwikPlugin.getOptions();
|
|
2941
|
+
const optimizer = qwikPlugin.getOptimizer();
|
|
2942
|
+
const manualChunks = qwikPlugin.manualChunks;
|
|
2596
2943
|
if ("client" === opts.target) {
|
|
2597
2944
|
if (!outputOpts.assetFileNames) {
|
|
2598
2945
|
const assetFileNames = "assets/[hash]-[name].[ext]";
|
|
2599
2946
|
outputOpts.assetFileNames = useAssetsDir ? `${opts.assetsDir}/${assetFileNames}` : assetFileNames;
|
|
2600
2947
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2948
|
+
let fileName;
|
|
2949
|
+
fileName = "production" !== opts.buildMode || opts.debug ? chunkInfo => {
|
|
2950
|
+
if (chunkInfo.moduleIds?.some((id => id.endsWith("core.prod.mjs")))) {
|
|
2951
|
+
return "build/core.js";
|
|
2952
|
+
}
|
|
2953
|
+
if (chunkInfo.moduleIds?.some((id => id.endsWith("qwik-router/lib/index.qwik.mjs")))) {
|
|
2954
|
+
return "build/qwik-router.js";
|
|
2955
|
+
}
|
|
2956
|
+
const path = optimizer.sys.path;
|
|
2957
|
+
const relativePath = path.relative(optimizer.sys.cwd(), chunkInfo.name);
|
|
2958
|
+
const sanitized = relativePath.replace(/^(\.\.\/)+/, "").replace(/^\/+/, "").replace(/\//g, "-");
|
|
2959
|
+
return `build/${sanitized}.js`;
|
|
2960
|
+
} : "build/q-[hash].js";
|
|
2961
|
+
const getFilePath = fileNamePattern => "string" === typeof fileNamePattern ? useAssetsDir ? `${opts.assetsDir}/${fileNamePattern}` : fileNamePattern : useAssetsDir ? chunkInfo => `${opts.assetsDir}/${fileNamePattern(chunkInfo)}` : chunkInfo => fileNamePattern(chunkInfo);
|
|
2962
|
+
outputOpts.entryFileNames || (outputOpts.entryFileNames = getFilePath(fileName));
|
|
2963
|
+
outputOpts.chunkFileNames || (outputOpts.chunkFileNames = getFilePath(fileName));
|
|
2604
2964
|
} else {
|
|
2605
2965
|
"production" === opts.buildMode && (outputOpts.chunkFileNames || (outputOpts.chunkFileNames = "q-[hash].js"));
|
|
2606
2966
|
}
|
|
@@ -2619,11 +2979,11 @@ function normalizeRollupOutputOptionsObject(opts, rollupOutputOptsObj, useAssets
|
|
|
2619
2979
|
}
|
|
2620
2980
|
|
|
2621
2981
|
function createRollupError2(id, diagnostic) {
|
|
2622
|
-
const loc = diagnostic.highlights[0]
|
|
2982
|
+
const loc = diagnostic.highlights?.[0];
|
|
2623
2983
|
const err = Object.assign(new Error(diagnostic.message), {
|
|
2624
2984
|
id: id,
|
|
2625
2985
|
plugin: "qwik",
|
|
2626
|
-
loc: {
|
|
2986
|
+
loc: loc && {
|
|
2627
2987
|
column: loc.startCol,
|
|
2628
2988
|
line: loc.startLine
|
|
2629
2989
|
},
|
|
@@ -2632,9 +2992,9 @@ function createRollupError2(id, diagnostic) {
|
|
|
2632
2992
|
return err;
|
|
2633
2993
|
}
|
|
2634
2994
|
|
|
2635
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = '
|
|
2995
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]);let r;const s=(t,e)=>Array.from(t.querySelectorAll(e)),i=t=>{const e=[];return o.forEach((n=>e.push(...s(n,t)))),e},a=t=>{v(t),s(t,"[q\\\\:shadowroot]").forEach((t=>{const e=t.shadowRoot;e&&a(e)}))},c=t=>t&&"function"==typeof t.then;let l=!0;const f=(t,e,n=e.type)=>{let o=l;i("[on"+t+"\\\\:"+n+"]").forEach((r=>{o=!0,b(r,t,e,n)})),o||window[t.slice(1)].removeEventListener(n,"-window"===t?d:_)},p=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},u=(t,e)=>new CustomEvent(t,{detail:e}),b=async(e,n,o,r=o.type)=>{const s="on"+n+":"+r;e.hasAttribute("preventdefault:"+r)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+r)&&o.stopPropagation();const i=e._qc_,a=i&&i.li.filter((t=>t[0]===s));if(a&&a.length>0){for(const t of a){const n=t[1].getFn([e,o],(()=>e.isConnected))(o,e),r=o.cancelBubble;c(n)&&await n,r&&o.stopPropagation()}return}const l=e.getAttribute(s),f=e.qDispatchEvent;if(f)return f(o,n);if(l){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=n.getAttribute("q:version")||"unknown",i=n.getAttribute("q:manifest-hash")||"dev",a=new URL(r,t.baseURI);for(const f of l.split("\\n")){const l=new URL(f,a),u=l.href,b=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,w;const m=f.startsWith("#"),y={qBase:r,qManifest:i,qVersion:s,href:u,symbol:b,element:e,reqTime:h};if(m){const e=n.getAttribute("q:instance");_=(t["qFuncs_"+e]||[])[Number.parseInt(b)],_||(d="sync",w=Error("sym:"+b))}else{q("qsymbol",y);const t=l.href.split("#")[0];try{const e=import(t);p(n),_=(await e)[b],_||(d="no-symbol",w=Error(`${b} not in ${t}`))}catch(t){d||(d="async"),w=t}}if(!_){q("qerror",{importError:d,error:w,...y}),console.error(w);break}const v=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,l];const n=_(o,e);c(n)&&await n}catch(t){q("qerror",{error:t,...y})}finally{t.__q_context__=v}}}},q=(e,n)=>{t.dispatchEvent(u(e,n))},h=t=>t.replace(/([A-Z])/g,(t=>"-"+t.toLowerCase())),_=async t=>{let e=h(t.type),n=t.target;for(f("-document",t,e);n&&n.getAttribute;){const o=b(n,"",t,e);let r=t.cancelBubble;c(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute("stoppropagation:"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},d=t=>{f("-window",t,h(t.type))},w=()=>{var s;const c=t.readyState;if(!r&&("interactive"==c||"complete"==c)&&(o.forEach(a),r=1,q("qinit"),(null!=(s=e.requestIdleCallback)?s:e.setTimeout).bind(e)((()=>q("qidle"))),n.has("qvisible"))){const t=i("[on\\\\:qvisible]"),e=new IntersectionObserver((t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),b(n.target,"",u("qvisible",n)))}));t.forEach((t=>e.observe(t)))}},m=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})};let y;const v=(...t)=>{l=!0,clearTimeout(y),y=setTimeout((()=>l=!1),2e4);for(const r of t)"string"==typeof r?n.has(r)||(o.forEach((t=>m(t,r,_,!0))),m(e,r,d,!0),n.add(r)):o.has(r)||(n.forEach((t=>m(r,t,_,!0))),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?v(...r):v("click","input")),e.qwikevents={events:n,roots:o,push:v},m(t,"readystatechange",w),w()}';
|
|
2636
2996
|
|
|
2637
|
-
var QWIK_LOADER_DEFAULT_DEBUG = '(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = "__q_context__";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && "function" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if ("SCRIPT" === script.tagName && "qwik/json" === script.getAttribute("type")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n element.hasAttribute("preventdefault:" + eventName) && ev.preventDefault();\n element.hasAttribute("stoppropagation:" + eventName) && ev.stopPropagation();\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li => li[0] === attrName));\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([ element, ev ], (() => element.isConnected))(ev, element);\n const cancelBubble = ev.cancelBubble;\n isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sync handler error for symbol: " + symbol);\n }\n } else {\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri);\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent("qsymbol", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n emitEvent("qerror", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => "-" + a.toLowerCase()));\n const processDocumentEvent = async ev => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast("-window", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && ("interactive" == readyState || "complete" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).bind(win)((() => emitEvent("qidle")));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n }));\n results.forEach((el => observer.observe(el)));\n }\n }\n };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if ("string" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()';
|
|
2997
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nlet doNotClean = true;\nconst broadcast = (infix, ev, type = ev.type) => {\n let found = doNotClean;\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n found = true;\n dispatch(el, infix, ev, type);\n });\n if (!found) {\n window[infix.slice(1)].removeEventListener(\n type,\n infix === "-window" ? processWindowEvent : processDocumentEvent\n );\n }\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n if (element.hasAttribute("preventdefault:" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n emitEvent("qsymbol", eventData);\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z])/g, (a) => "-" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast("-window", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = (_a = win.requestIdleCallback) != null ? _a : win.setTimeout;\n riC.bind(win)(() => emitEvent("qidle"));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nlet cleanTimer;\nconst processEventOrNode = (...eventNames) => {\n doNotClean = true;\n clearTimeout(cleanTimer);\n cleanTimer = setTimeout(() => doNotClean = false, 2e4);\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n roots.forEach(\n (root) => addEventListener(root, eventNameOrNode, processDocumentEvent, true)\n );\n addEventListener(win, eventNameOrNode, processWindowEvent, true);\n events.add(eventNameOrNode);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach(\n (eventName) => addEventListener(eventNameOrNode, eventName, processDocumentEvent, true)\n );\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!("__q_context__" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode("click", "input");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
2638
2998
|
|
|
2639
2999
|
var import_bmp = __toESM(require_bmp(), 1);
|
|
2640
3000
|
|
|
@@ -2969,62 +3329,8 @@ var perf_warning_default = "<script>\n if (!window.__qwikViteLog) {\n window
|
|
|
2969
3329
|
|
|
2970
3330
|
var VITE_ERROR_OVERLAY_STYLES = "\nvite-error-overlay {\n --color-bright: rgba(255, 255, 255, 0.8);\n --color-yellow: rgba(255,246,85,0.8);\n --qwik-dark-blue: #006ce9;\n --qwik-light-blue: #3ec2f7;\n --qwik-light-purple: #ac7ff4;\n --qwik-dark-purple: #713fc2;\n --yellow: #fff; /* override vite yellow */\n --purple: var(--color-bright); /* override vite purple */\n --red: var(--qwik-light-blue); /* override vite red */\n\n --vertical-box-spacing: 15px;\n --box-padding: 20px;\n --box-margin: 0 0 var(--vertical-box-spacing) 0;\n --box-background: rgba(0, 0, 0, 0.5);\n --box-border-radius: 8px;\n}\n\nvite-error-overlay::part(backdrop) {\n background: rgb(2 11 17 / 60%);\n backdrop-filter: blur(20px) brightness(0.4) saturate(3);\n}\n\nvite-error-overlay::part(window) {\n background: transparent;\n border: none;\n box-shadow: none;\n box-sizing: border-box;\n margin: 50px auto;\n max-width: 1200px;\n padding: var(--box-padding);\n width: 90%;\n}\n\nvite-error-overlay::part(message) {\n display: flex;\n flex-direction: column;\n font-size: 1.6rem;\n line-height: 1.7;\n margin-bottom: 30px;\n}\n\nvite-error-overlay::part(plugin) {\n font-size: 0.8rem;\n font-weight: 100;\n}\n\nvite-error-overlay::part(file),\nvite-error-overlay::part(frame),\nvite-error-overlay::part(stack),\nvite-error-overlay::part(tip) {\n background: var(--box-background);\n border-left: 5px solid transparent;\n border-radius: var(--box-border-radius);\n margin: var(--box-margin);\n min-height: 50px;\n padding: var(--box-padding);\n position: relative;\n}\n\nvite-error-overlay::part(file) {\n border-left-color: rgb(25 182 246);\n color: var(--color-bright);\n}\n\nvite-error-overlay::part(frame) {\n border-left-color: var(--color-yellow);\n color: var(--color-yellow);\n}\n\nvite-error-overlay::part(stack) {\n border-left-color: #FF5722;\n}\n\n\nvite-error-overlay::part(tip) {\n border-top: none;\n border-left-color: rgb(172, 127, 244);\n}\n\nvite-error-overlay::part(file):before,\nvite-error-overlay::part(frame):before,\nvite-error-overlay::part(stack):before {\n border-bottom: 1px solid #222;\n color: var(--color-bright);\n display: block;\n margin-bottom: 15px;\n padding-bottom: 5px;\n padding-left: 30px; /* space for icon */\n font-size: .8rem;\n}\n\nvite-error-overlay::part(file):before {\n content: 'File';\n}\n\nvite-error-overlay::part(frame):before {\n content: 'Frame';\n}\n\nvite-error-overlay::part(stack):before {\n content: 'Stack Trace';\n}\n\nvite-error-overlay::part(file):after,\nvite-error-overlay::part(frame):after,\nvite-error-overlay::part(stack):after {\n content: '';\n display: block;\n height: 20px;\n position: absolute;\n left: var(--box-padding);\n top: var(--box-padding);\n width: 20px;\n}\n\nvite-error-overlay::part(file):after {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3EFile-Generic%3C/title%3E%3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cg id='File-Generic'%3E%3Crect id='Rectangle' fill-rule='nonzero' x='0' y='0' width='24' height='24'%3E%3C/rect%3E%3Cpath d='M4 5 C4 3.89543 4.89543 3 6 3 L15.1716 3 C15.702 3 16.2107 3.21071 16.5858 3.58579 L19.4142 6.41421 C19.7893 6.78929 20 7.29799 20 7.82843 L20 19 C20 20.1046 19.1046 21 18 21 L6 21 C4.89543 21 4 20.1046 4 19 L4 5 Z' id='Path' stroke='rgba(255,255,255,0.7)' stroke-width='1' stroke-linecap='round'%3E%3C/path%3E%3Cpath d='M15 4 L15 6 C15 7.10457 15.8954 8 17 8 L19 8' id='Path' stroke='rgba(255,255,255,0.7)' stroke-width='1' stroke-linecap='round'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");\n}\n\nvite-error-overlay::part(frame):after {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.6602 2.84952H19.1516C20.2555 2.84952 21.1504 3.74444 21.1504 4.84839V8.3398' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3Cpath d='M2.84949 8.33981L2.84949 4.8484C2.84949 3.74446 3.74441 2.84953 4.84836 2.84953L8.33977 2.84953' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3Cpath d='M21.1505 15.6602L21.1505 19.1516C21.1505 20.2555 20.2556 21.1505 19.1516 21.1505L15.6602 21.1505' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3Cpath d='M8.33984 21.1505L4.84843 21.1505C3.74449 21.1505 2.84956 20.2555 2.84956 19.1516L2.84956 15.6602' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3C/svg%3E\");\n}\n\nvite-error-overlay::part(stack):after {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.78 20H9.78C7.98 20 4.58 19.09 4.58 15.64C4.58 12.19 7.98 11.28 9.78 11.28H14.22C14.37 11.28 17.92 11.23 17.92 8.42C17.92 5.61 14.37 5.56 14.22 5.56H9.22C9.02109 5.56 8.83032 5.48098 8.68967 5.34033C8.54902 5.19968 8.47 5.00891 8.47 4.81C8.47 4.61109 8.54902 4.42032 8.68967 4.27967C8.83032 4.13902 9.02109 4.06 9.22 4.06H14.22C16.02 4.06 19.42 4.97 19.42 8.42C19.42 11.87 16.02 12.78 14.22 12.78H9.78C9.63 12.78 6.08 12.83 6.08 15.64C6.08 18.45 9.63 18.5 9.78 18.5H14.78C14.9789 18.5 15.1697 18.579 15.3103 18.7197C15.451 18.8603 15.53 19.0511 15.53 19.25C15.53 19.4489 15.451 19.6397 15.3103 19.7803C15.1697 19.921 14.9789 20 14.78 20Z' fill='rgba(255,255,255,0.7)'/%3E%3Cpath d='M6.44 8.31C5.74314 8.30407 5.06363 8.09202 4.48708 7.70056C3.91054 7.30909 3.46276 6.75573 3.20018 6.11021C2.93759 5.46469 2.87195 4.75589 3.01153 4.07312C3.1511 3.39036 3.48965 2.76418 3.9845 2.2735C4.47935 1.78281 5.10837 1.44958 5.79229 1.31579C6.47622 1.182 7.18444 1.25363 7.82771 1.52167C8.47099 1.78971 9.02054 2.24215 9.40711 2.82199C9.79368 3.40182 9.99998 4.08311 10 4.78C10 5.2461 9.90773 5.70759 9.72846 6.13783C9.54919 6.56808 9.28648 6.95856 8.95551 7.28675C8.62453 7.61494 8.23184 7.87433 7.80009 8.04995C7.36834 8.22558 6.90609 8.31396 6.44 8.31ZM6.44 2.75C6.04444 2.75 5.65776 2.86729 5.32886 3.08706C4.99996 3.30682 4.74362 3.61918 4.59224 3.98463C4.44087 4.35008 4.40126 4.75221 4.47843 5.14018C4.5556 5.52814 4.74609 5.8845 5.02579 6.16421C5.3055 6.44391 5.66186 6.6344 6.04982 6.71157C6.43779 6.78874 6.83992 6.74913 7.20537 6.59776C7.57082 6.44638 7.88318 6.19003 8.10294 5.86114C8.32271 5.53224 8.44 5.14556 8.44 4.75C8.44 4.48735 8.38827 4.22728 8.28776 3.98463C8.18725 3.74198 8.03993 3.5215 7.85422 3.33578C7.6685 3.15007 7.44802 3.00275 7.20537 2.90224C6.96272 2.80173 6.70265 2.75 6.44 2.75Z' fill='rgba(255,255,255,0.7)'/%3E%3Cpath d='M17.56 22.75C16.8614 22.752 16.1779 22.5466 15.5961 22.1599C15.0143 21.7733 14.5603 21.2227 14.2916 20.5778C14.0229 19.933 13.9515 19.2229 14.0866 18.5375C14.2217 17.8521 14.5571 17.2221 15.0504 16.7275C15.5437 16.2328 16.1726 15.8956 16.8577 15.7586C17.5427 15.6215 18.253 15.6909 18.8986 15.9577C19.5442 16.2246 20.0961 16.6771 20.4844 17.2578C20.8727 17.8385 21.08 18.5214 21.08 19.22C21.08 20.1545 20.7095 21.0508 20.0496 21.7125C19.3898 22.3743 18.4945 22.7473 17.56 22.75ZM17.56 17.19C17.1644 17.19 16.7778 17.3073 16.4489 17.5271C16.12 17.7468 15.8636 18.0592 15.7122 18.4246C15.5609 18.7901 15.5213 19.1922 15.5984 19.5802C15.6756 19.9681 15.8661 20.3245 16.1458 20.6042C16.4255 20.8839 16.7819 21.0744 17.1698 21.1516C17.5578 21.2287 17.9599 21.1891 18.3254 21.0377C18.6908 20.8864 19.0032 20.63 19.2229 20.3011C19.4427 19.9722 19.56 19.5856 19.56 19.19C19.56 18.6596 19.3493 18.1508 18.9742 17.7758C18.5991 17.4007 18.0904 17.19 17.56 17.19Z' fill='rgba(255,255,255,0.7)'/%3E%3C/svg%3E\");\n}\n\nvite-error-overlay::part(tip):before {\n content: \"Not sure how to solve this? Visit https://qwik.dev or connect with the community on Discord.\";\n display: block;\n margin-bottom: 1em;\n}\n";
|
|
2971
3331
|
|
|
2972
|
-
var qDev = false !== globalThis.qDev;
|
|
2973
|
-
|
|
2974
|
-
var qInspector = true === globalThis.qInspector;
|
|
2975
|
-
|
|
2976
|
-
var qSerialize = false !== globalThis.qSerialize;
|
|
2977
|
-
|
|
2978
|
-
var qDynamicPlatform = false !== globalThis.qDynamicPlatform;
|
|
2979
|
-
|
|
2980
|
-
var qTest = true === globalThis.qTest;
|
|
2981
|
-
|
|
2982
|
-
var qRuntimeQrl = true === globalThis.qRuntimeQrl;
|
|
2983
|
-
|
|
2984
3332
|
var SYNC_QRL = "<sync>";
|
|
2985
3333
|
|
|
2986
|
-
var START = "[34m";
|
|
2987
|
-
|
|
2988
|
-
var END = "[0m";
|
|
2989
|
-
|
|
2990
|
-
var VirtualTypeName = {
|
|
2991
|
-
V: START + "Virtual" + END,
|
|
2992
|
-
F: START + "Fragment" + END,
|
|
2993
|
-
S: START + "Signal" + END,
|
|
2994
|
-
A: START + "Awaited" + END,
|
|
2995
|
-
C: START + "Component" + END,
|
|
2996
|
-
I: START + "InlineComponent" + END,
|
|
2997
|
-
P: START + "Projection" + END
|
|
2998
|
-
};
|
|
2999
|
-
|
|
3000
|
-
var QStyleSelector = "style[q\\:style]";
|
|
3001
|
-
|
|
3002
|
-
var QStyleSSelector = "style[q\\:sstyle]";
|
|
3003
|
-
|
|
3004
|
-
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
3005
|
-
|
|
3006
|
-
var QContainerIsland = "q:container-island";
|
|
3007
|
-
|
|
3008
|
-
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
3009
|
-
|
|
3010
|
-
var QIgnore = "q:ignore";
|
|
3011
|
-
|
|
3012
|
-
var QIgnoreEnd = "/" + QIgnore;
|
|
3013
|
-
|
|
3014
|
-
var QContainerAttr = "q:container";
|
|
3015
|
-
|
|
3016
|
-
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
3017
|
-
|
|
3018
|
-
var QContainerSelector = "[q\\:container]:not([q\\:container=html]):not([q\\:container=text])";
|
|
3019
|
-
|
|
3020
|
-
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
3021
|
-
|
|
3022
|
-
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
3023
|
-
|
|
3024
|
-
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
3025
|
-
|
|
3026
|
-
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
3027
|
-
|
|
3028
3334
|
function getOrigin(req) {
|
|
3029
3335
|
const {PROTOCOL_HEADER: PROTOCOL_HEADER, HOST_HEADER: HOST_HEADER} = process.env;
|
|
3030
3336
|
const headers = req.headers;
|
|
@@ -3065,6 +3371,7 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3065
3371
|
return;
|
|
3066
3372
|
}
|
|
3067
3373
|
const hasQwikRouter = server.config.plugins?.some((plugin => "vite-plugin-qwik-router" === plugin.name));
|
|
3374
|
+
const cssImportedByCSS = new Set;
|
|
3068
3375
|
server.middlewares.use((async (req, res, next) => {
|
|
3069
3376
|
try {
|
|
3070
3377
|
const {ORIGIN: ORIGIN} = process.env;
|
|
@@ -3104,11 +3411,8 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3104
3411
|
if ("function" === typeof render) {
|
|
3105
3412
|
const manifest = {
|
|
3106
3413
|
manifestHash: "",
|
|
3107
|
-
symbols: {},
|
|
3108
3414
|
mapping: {},
|
|
3109
|
-
|
|
3110
|
-
injections: [],
|
|
3111
|
-
version: "1"
|
|
3415
|
+
injections: []
|
|
3112
3416
|
};
|
|
3113
3417
|
const added = new Set;
|
|
3114
3418
|
const CSS_EXTENSIONS = [ ".css", ".scss", ".sass", ".less", ".styl", ".stylus" ];
|
|
@@ -3122,11 +3426,17 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3122
3426
|
const {pathId: pathId, query: query} = parseId(v.url);
|
|
3123
3427
|
if ("" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
|
|
3124
3428
|
const isEntryCSS = 0 === v.importers.size;
|
|
3429
|
+
const hasCSSImporter = Array.from(v.importers).some((importer => {
|
|
3430
|
+
const importerPath = importer.url || importer.file;
|
|
3431
|
+
const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
|
|
3432
|
+
isCSS && v.url && cssImportedByCSS.add(v.url);
|
|
3433
|
+
return isCSS;
|
|
3434
|
+
}));
|
|
3125
3435
|
const hasJSImporter = Array.from(v.importers).some((importer => {
|
|
3126
3436
|
const importerPath = importer.url || importer.file;
|
|
3127
3437
|
return importerPath && JS_EXTENSIONS.test(importerPath);
|
|
3128
3438
|
}));
|
|
3129
|
-
if ((isEntryCSS || hasJSImporter) && !added.has(v.url)) {
|
|
3439
|
+
if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url) && !added.has(v.url)) {
|
|
3130
3440
|
added.add(v.url);
|
|
3131
3441
|
manifest.injections.push({
|
|
3132
3442
|
tag: "link",
|
|
@@ -3147,7 +3457,6 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3147
3457
|
snapshot: !isClientDevOnly,
|
|
3148
3458
|
manifest: isClientDevOnly ? void 0 : manifest,
|
|
3149
3459
|
symbolMapper: isClientDevOnly ? void 0 : symbolMapper,
|
|
3150
|
-
prefetchStrategy: null,
|
|
3151
3460
|
serverData: serverData,
|
|
3152
3461
|
containerAttributes: {
|
|
3153
3462
|
...serverData.containerAttributes
|
|
@@ -3165,11 +3474,17 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3165
3474
|
const {pathId: pathId, query: query} = parseId(v.url);
|
|
3166
3475
|
if (!added.has(v.url) && "" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
|
|
3167
3476
|
const isEntryCSS = 0 === v.importers.size;
|
|
3477
|
+
const hasCSSImporter = Array.from(v.importers).some((importer => {
|
|
3478
|
+
const importerPath = importer.url || importer.file;
|
|
3479
|
+
const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
|
|
3480
|
+
isCSS && v.url && cssImportedByCSS.add(v.url);
|
|
3481
|
+
return isCSS;
|
|
3482
|
+
}));
|
|
3168
3483
|
const hasJSImporter = Array.from(v.importers).some((importer => {
|
|
3169
3484
|
const importerPath = importer.url || importer.file;
|
|
3170
3485
|
return importerPath && JS_EXTENSIONS.test(importerPath);
|
|
3171
3486
|
}));
|
|
3172
|
-
if (isEntryCSS || hasJSImporter) {
|
|
3487
|
+
if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url)) {
|
|
3173
3488
|
res.write(`<link rel="stylesheet" href="${base}${v.url.slice(1)}">`);
|
|
3174
3489
|
added.add(v.url);
|
|
3175
3490
|
}
|
|
@@ -3334,28 +3649,19 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3334
3649
|
let rootDir = null;
|
|
3335
3650
|
let ssrOutDir = null;
|
|
3336
3651
|
const fileFilter = qwikViteOpts.fileFilter ? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter(id, type) : () => true;
|
|
3652
|
+
const disableFontPreload = qwikViteOpts.disableFontPreload ?? false;
|
|
3337
3653
|
const injections = [];
|
|
3338
|
-
const qwikPlugin =
|
|
3339
|
-
|
|
3340
|
-
const sys = qwikPlugin.getSys();
|
|
3341
|
-
const cwdRelativePath = absolutePathAwareJoin(sys.path, rootDir || ".", clientOutDir2, "q-insights.json");
|
|
3342
|
-
const path = absolutePathAwareJoin(sys.path, process.cwd(), cwdRelativePath);
|
|
3343
|
-
const fs = await sys.dynamicImport("node:fs");
|
|
3344
|
-
if (fs.existsSync(path)) {
|
|
3345
|
-
qwikPlugin.log("Reading Qwik Insight data from: " + cwdRelativePath);
|
|
3346
|
-
return JSON.parse(await fs.promises.readFile(path, "utf-8"));
|
|
3347
|
-
}
|
|
3348
|
-
return null;
|
|
3349
|
-
}
|
|
3654
|
+
const qwikPlugin = createQwikPlugin(qwikViteOpts.optimizerOptions);
|
|
3655
|
+
const bundleGraphAdders = new Set;
|
|
3350
3656
|
const api = {
|
|
3351
3657
|
getOptimizer: () => qwikPlugin.getOptimizer(),
|
|
3352
3658
|
getOptions: () => qwikPlugin.getOptions(),
|
|
3353
3659
|
getManifest: () => manifestInput,
|
|
3354
|
-
getInsightsManifest: (clientOutDir2 = "") => loadQwikInsights(clientOutDir2),
|
|
3355
3660
|
getRootDir: () => qwikPlugin.getOptions().rootDir,
|
|
3356
3661
|
getClientOutDir: () => clientOutDir,
|
|
3357
3662
|
getClientPublicOutDir: () => clientPublicOutDir,
|
|
3358
|
-
getAssetsDir: () => viteAssetsDir
|
|
3663
|
+
getAssetsDir: () => viteAssetsDir,
|
|
3664
|
+
registerBundleGraphAdder: adder => bundleGraphAdders.add(adder)
|
|
3359
3665
|
};
|
|
3360
3666
|
const vitePluginPre = {
|
|
3361
3667
|
name: "vite-plugin-qwik",
|
|
@@ -3454,9 +3760,9 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3454
3760
|
const qTestKey = "globalThis.qTest";
|
|
3455
3761
|
const qInspectorKey = "globalThis.qInspector";
|
|
3456
3762
|
const qSerializeKey = "globalThis.qSerialize";
|
|
3457
|
-
const
|
|
3458
|
-
const
|
|
3459
|
-
const
|
|
3763
|
+
const qDev = viteConfig?.define?.[qDevKey] ?? isDevelopment;
|
|
3764
|
+
const qInspector = viteConfig?.define?.[qInspectorKey] ?? isDevelopment;
|
|
3765
|
+
const qSerialize = viteConfig?.define?.[qSerializeKey] ?? isDevelopment;
|
|
3460
3766
|
const updatedViteConfig = {
|
|
3461
3767
|
ssr: {
|
|
3462
3768
|
noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID, ...vendorIds ]
|
|
@@ -3469,6 +3775,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3469
3775
|
"@builder.io/qwik": "@qwik.dev/core",
|
|
3470
3776
|
"@builder.io/qwik/build": "@qwik.dev/core/build",
|
|
3471
3777
|
"@builder.io/qwik/server": "@qwik.dev/core/server",
|
|
3778
|
+
"@builder.io/qwik/preloader": "@qwik.dev/core/preloader",
|
|
3472
3779
|
"@builder.io/qwik/jsx-runtime": "@qwik.dev/core/jsx-runtime",
|
|
3473
3780
|
"@builder.io/qwik/jsx-dev-runtime": "@qwik.dev/core/jsx-dev-runtime",
|
|
3474
3781
|
"@builder.io/qwik/optimizer": "@qwik.dev/core/optimizer",
|
|
@@ -3490,15 +3797,16 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3490
3797
|
exclude: [ /./ ]
|
|
3491
3798
|
},
|
|
3492
3799
|
rollupOptions: {
|
|
3800
|
+
maxParallelFileOps: 1,
|
|
3493
3801
|
output: {
|
|
3494
3802
|
manualChunks: qwikPlugin.manualChunks
|
|
3495
3803
|
}
|
|
3496
3804
|
}
|
|
3497
3805
|
},
|
|
3498
3806
|
define: {
|
|
3499
|
-
[qDevKey]:
|
|
3500
|
-
[qInspectorKey]:
|
|
3501
|
-
[qSerializeKey]:
|
|
3807
|
+
[qDevKey]: qDev,
|
|
3808
|
+
[qInspectorKey]: qInspector,
|
|
3809
|
+
[qSerializeKey]: qSerialize,
|
|
3502
3810
|
[qTestKey]: JSON.stringify("test" === process.env.NODE_ENV)
|
|
3503
3811
|
}
|
|
3504
3812
|
};
|
|
@@ -3509,7 +3817,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3509
3817
|
const origOnwarn = updatedViteConfig.build.rollupOptions?.onwarn;
|
|
3510
3818
|
updatedViteConfig.build.rollupOptions = {
|
|
3511
3819
|
input: opts.input,
|
|
3512
|
-
output: normalizeRollupOutputOptions(
|
|
3820
|
+
output: normalizeRollupOutputOptions(qwikPlugin, viteConfig.build?.rollupOptions?.output, useAssetsDir, buildOutputDir),
|
|
3513
3821
|
preserveEntrySignatures: "exports-only",
|
|
3514
3822
|
onwarn: (warning, warn) => {
|
|
3515
3823
|
if ("typescript" === warning.plugin && warning.message.includes("outputToFilesystem")) {
|
|
@@ -3536,26 +3844,21 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3536
3844
|
[qInspectorKey]: false
|
|
3537
3845
|
};
|
|
3538
3846
|
}
|
|
3539
|
-
globalThis.qDev =
|
|
3847
|
+
globalThis.qDev = qDev;
|
|
3540
3848
|
globalThis.qTest = true;
|
|
3541
|
-
globalThis.qInspector =
|
|
3849
|
+
globalThis.qInspector = qInspector;
|
|
3542
3850
|
}
|
|
3543
3851
|
return updatedViteConfig;
|
|
3544
3852
|
},
|
|
3545
3853
|
async configResolved(config) {
|
|
3546
3854
|
basePathname = config.base;
|
|
3547
3855
|
if (!(basePathname.startsWith("/") && basePathname.endsWith("/"))) {
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
const sys = qwikPlugin.getSys();
|
|
3551
|
-
if ("node" === sys.env && !qwikViteOpts.entryStrategy) {
|
|
3552
|
-
try {
|
|
3553
|
-
const entryStrategy = await loadQwikInsights(qwikViteOpts.csr ? void 0 : qwikViteOpts.client?.outDir);
|
|
3554
|
-
entryStrategy && (qwikViteOpts.entryStrategy = entryStrategy);
|
|
3555
|
-
} catch {}
|
|
3856
|
+
console.error("warning: vite's config.base must begin and end with /. This will be an error in v2. If you have a valid use case, please open an issue.");
|
|
3857
|
+
basePathname.endsWith("/") || (basePathname += "/");
|
|
3556
3858
|
}
|
|
3557
3859
|
const useSourcemap = !!config.build.sourcemap;
|
|
3558
3860
|
useSourcemap && void 0 === qwikViteOpts.optimizerOptions?.sourcemap && qwikPlugin.setSourceMapSupport(true);
|
|
3861
|
+
qwikPlugin.normalizeOptions(qwikViteOpts);
|
|
3559
3862
|
},
|
|
3560
3863
|
async buildStart() {
|
|
3561
3864
|
const resolver = this.resolve.bind(this);
|
|
@@ -3612,7 +3915,6 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3612
3915
|
async handler(_, rollupBundle) {
|
|
3613
3916
|
const opts = qwikPlugin.getOptions();
|
|
3614
3917
|
if ("client" === opts.target) {
|
|
3615
|
-
const outputAnalyzer = qwikPlugin.createOutputAnalyzer(rollupBundle);
|
|
3616
3918
|
for (const [fileName, b] of Object.entries(rollupBundle)) {
|
|
3617
3919
|
if ("asset" === b.type) {
|
|
3618
3920
|
const baseFilename = basePathname + fileName;
|
|
@@ -3634,7 +3936,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3634
3936
|
});
|
|
3635
3937
|
} else {
|
|
3636
3938
|
const selectedFont = FONTS.find((ext => fileName.endsWith(ext)));
|
|
3637
|
-
selectedFont && injections.unshift({
|
|
3939
|
+
selectedFont && !disableFontPreload && injections.unshift({
|
|
3638
3940
|
tag: "link",
|
|
3639
3941
|
location: "head",
|
|
3640
3942
|
attributes: {
|
|
@@ -3648,47 +3950,16 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3648
3950
|
}
|
|
3649
3951
|
}
|
|
3650
3952
|
}
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
manifest.platform = {
|
|
3657
|
-
...versions,
|
|
3658
|
-
vite: "",
|
|
3659
|
-
rollup: this.meta?.rollupVersion || "",
|
|
3660
|
-
env: optimizer.sys.env,
|
|
3661
|
-
os: optimizer.sys.os
|
|
3662
|
-
};
|
|
3663
|
-
"node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
|
|
3664
|
-
const clientManifestStr = JSON.stringify(manifest, null, 2);
|
|
3665
|
-
this.emitFile({
|
|
3666
|
-
type: "asset",
|
|
3667
|
-
fileName: Q_MANIFEST_FILENAME,
|
|
3668
|
-
source: clientManifestStr
|
|
3953
|
+
const clientManifestStr = await qwikPlugin.generateManifest(this, rollupBundle, bundleGraphAdders, {
|
|
3954
|
+
injections: injections,
|
|
3955
|
+
platform: {
|
|
3956
|
+
vite: ""
|
|
3957
|
+
}
|
|
3669
3958
|
});
|
|
3670
|
-
const assetsDir = qwikPlugin.getOptions().assetsDir || "";
|
|
3671
|
-
const useAssetsDir = !!assetsDir && "_astro" !== assetsDir;
|
|
3672
3959
|
const sys = qwikPlugin.getSys();
|
|
3673
|
-
this.emitFile({
|
|
3674
|
-
type: "asset",
|
|
3675
|
-
fileName: sys.path.join(useAssetsDir ? assetsDir : "", "build", `q-bundle-graph-${manifest.manifestHash}.json`),
|
|
3676
|
-
source: JSON.stringify(convertManifestToBundleGraph(manifest))
|
|
3677
|
-
});
|
|
3678
|
-
const fs = await sys.dynamicImport("node:fs");
|
|
3679
|
-
const workerScriptPath = (await this.resolve("@qwik.dev/core/qwik-prefetch.js")).id;
|
|
3680
|
-
const workerScript = await fs.promises.readFile(workerScriptPath, "utf-8");
|
|
3681
|
-
const qwikPrefetchServiceWorkerFile = "qwik-prefetch-service-worker.js";
|
|
3682
|
-
this.emitFile({
|
|
3683
|
-
type: "asset",
|
|
3684
|
-
fileName: useAssetsDir ? sys.path.join(assetsDir, "build", qwikPrefetchServiceWorkerFile) : qwikPrefetchServiceWorkerFile,
|
|
3685
|
-
source: workerScript
|
|
3686
|
-
});
|
|
3687
|
-
"function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
|
|
3688
|
-
"function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(qwikPlugin.getTransformedOutputs());
|
|
3689
3960
|
if (tmpClientManifestPath && "node" === sys.env) {
|
|
3690
|
-
const
|
|
3691
|
-
await
|
|
3961
|
+
const fs = await sys.dynamicImport("node:fs");
|
|
3962
|
+
await fs.promises.writeFile(tmpClientManifestPath, clientManifestStr);
|
|
3692
3963
|
}
|
|
3693
3964
|
}
|
|
3694
3965
|
}
|
|
@@ -3856,7 +4127,7 @@ var findQwikRoots = async (sys, packageJsonDir) => {
|
|
|
3856
4127
|
} catch (e) {
|
|
3857
4128
|
console.error(e);
|
|
3858
4129
|
}
|
|
3859
|
-
} catch
|
|
4130
|
+
} catch {}
|
|
3860
4131
|
prevPackageJsonDir = packageJsonDir;
|
|
3861
4132
|
packageJsonDir = sys.path.dirname(packageJsonDir);
|
|
3862
4133
|
} while (packageJsonDir !== prevPackageJsonDir);
|
|
@@ -3871,94 +4142,4 @@ var VITE_CLIENT_MODULE = "@qwik.dev/core/vite-client";
|
|
|
3871
4142
|
|
|
3872
4143
|
var CLIENT_DEV_INPUT = "entry.dev";
|
|
3873
4144
|
|
|
3874
|
-
function absolutePathAwareJoin(path, ...segments) {
|
|
3875
|
-
for (let i = segments.length - 1; i >= 0; --i) {
|
|
3876
|
-
const segment = segments[i];
|
|
3877
|
-
if (segment.startsWith(path.sep) || -1 !== segment.indexOf(path.delimiter)) {
|
|
3878
|
-
segments.splice(0, i);
|
|
3879
|
-
break;
|
|
3880
|
-
}
|
|
3881
|
-
}
|
|
3882
|
-
return path.join(...segments);
|
|
3883
|
-
}
|
|
3884
|
-
|
|
3885
|
-
function convertManifestToBundleGraph(manifest) {
|
|
3886
|
-
const bundleGraph = [];
|
|
3887
|
-
const graph = manifest.bundles;
|
|
3888
|
-
if (!graph) {
|
|
3889
|
-
return [];
|
|
3890
|
-
}
|
|
3891
|
-
const names = Object.keys(graph).sort();
|
|
3892
|
-
const map = new Map;
|
|
3893
|
-
const clearTransitiveDeps = (parentDeps, seen, bundleName) => {
|
|
3894
|
-
const bundle = graph[bundleName];
|
|
3895
|
-
if (!bundle) {
|
|
3896
|
-
return;
|
|
3897
|
-
}
|
|
3898
|
-
for (const dep of bundle.imports || []) {
|
|
3899
|
-
parentDeps.has(dep) && parentDeps.delete(dep);
|
|
3900
|
-
if (!seen.has(dep)) {
|
|
3901
|
-
seen.add(dep);
|
|
3902
|
-
clearTransitiveDeps(parentDeps, seen, dep);
|
|
3903
|
-
}
|
|
3904
|
-
}
|
|
3905
|
-
};
|
|
3906
|
-
for (const bundleName of names) {
|
|
3907
|
-
const bundle = graph[bundleName];
|
|
3908
|
-
const index = bundleGraph.length;
|
|
3909
|
-
const deps = new Set(bundle.imports);
|
|
3910
|
-
for (const depName of deps) {
|
|
3911
|
-
if (!graph[depName]) {
|
|
3912
|
-
continue;
|
|
3913
|
-
}
|
|
3914
|
-
clearTransitiveDeps(deps, new Set, depName);
|
|
3915
|
-
}
|
|
3916
|
-
let didAdd = false;
|
|
3917
|
-
for (const depName of bundle.dynamicImports || []) {
|
|
3918
|
-
const dep = graph[depName];
|
|
3919
|
-
if (!graph[depName]) {
|
|
3920
|
-
continue;
|
|
3921
|
-
}
|
|
3922
|
-
if (dep.isTask) {
|
|
3923
|
-
if (!didAdd) {
|
|
3924
|
-
deps.add("<dynamic>");
|
|
3925
|
-
didAdd = true;
|
|
3926
|
-
}
|
|
3927
|
-
deps.add(depName);
|
|
3928
|
-
}
|
|
3929
|
-
}
|
|
3930
|
-
map.set(bundleName, {
|
|
3931
|
-
index: index,
|
|
3932
|
-
deps: deps
|
|
3933
|
-
});
|
|
3934
|
-
bundleGraph.push(bundleName);
|
|
3935
|
-
while (index + deps.size >= bundleGraph.length) {
|
|
3936
|
-
bundleGraph.push(null);
|
|
3937
|
-
}
|
|
3938
|
-
}
|
|
3939
|
-
for (const bundleName of names) {
|
|
3940
|
-
const bundle = map.get(bundleName);
|
|
3941
|
-
if (!bundle) {
|
|
3942
|
-
console.warn(`Bundle ${bundleName} not found in the bundle graph.`);
|
|
3943
|
-
continue;
|
|
3944
|
-
}
|
|
3945
|
-
let {index: index, deps: deps} = bundle;
|
|
3946
|
-
index++;
|
|
3947
|
-
for (const depName of deps) {
|
|
3948
|
-
if ("<dynamic>" === depName) {
|
|
3949
|
-
bundleGraph[index++] = -1;
|
|
3950
|
-
continue;
|
|
3951
|
-
}
|
|
3952
|
-
const dep = map.get(depName);
|
|
3953
|
-
if (!dep) {
|
|
3954
|
-
console.warn(`Dependency ${depName} of ${bundleName} not found in the bundle graph.`);
|
|
3955
|
-
continue;
|
|
3956
|
-
}
|
|
3957
|
-
const depIndex = dep.index;
|
|
3958
|
-
bundleGraph[index++] = depIndex;
|
|
3959
|
-
}
|
|
3960
|
-
}
|
|
3961
|
-
return bundleGraph;
|
|
3962
|
-
}
|
|
3963
|
-
|
|
3964
4145
|
export { createOptimizer, qwikRollup, qwikVite, symbolMapper, versions };
|