@ngrs/vite 0.3.0 → 0.3.2
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/package.json +2 -2
- package/src/index.mjs +274 -155
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrs/vite",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Native Rust Angular compiler & Ivy linker plugins for Vite, powered by @ngrs/compiler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.cjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"src"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ngrs/compiler": "0.3.
|
|
26
|
+
"@ngrs/compiler": "0.3.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"happy-dom": ">=15.0.0 || ^20.0.0",
|
package/src/index.mjs
CHANGED
|
@@ -84,6 +84,7 @@ export const isRolldownVite =
|
|
|
84
84
|
|
|
85
85
|
const INLINE_SOURCEMAP_RE =
|
|
86
86
|
/\n?\/\/# sourceMappingURL=data:application\/json;(?:charset=utf-8;)?base64,([A-Za-z0-9+/=]+)\s*$/;
|
|
87
|
+
const supportsEnvironmentHotUpdate = 'DevEnvironment' in viteNamespace;
|
|
87
88
|
const TS_FILE_RE = /\.[cm]?tsx?$/;
|
|
88
89
|
const DTS_FILE_RE = /\.d\.[cm]?ts$/;
|
|
89
90
|
const JS_MODULE_RE = /\.[cm]?js$/;
|
|
@@ -636,6 +637,35 @@ export function angularCompilerPlugin(options = {}) {
|
|
|
636
637
|
/** @type {Set<string>} clean paths already served via `load` during one-shot build */
|
|
637
638
|
const servedViaLoad = new Set();
|
|
638
639
|
let pendingDeferredTypecheck = false;
|
|
640
|
+
let pendingHandledComponentHtmlCount = 0;
|
|
641
|
+
|
|
642
|
+
function resolveWorkspaceFileCandidates(rawFilePath) {
|
|
643
|
+
const abs = path.resolve(rawFilePath);
|
|
644
|
+
const out = [abs, toPosixPath(abs)];
|
|
645
|
+
try {
|
|
646
|
+
const realAbs = fs.realpathSync(abs);
|
|
647
|
+
if (!out.includes(realAbs)) out.push(realAbs);
|
|
648
|
+
const realPosix = toPosixPath(realAbs);
|
|
649
|
+
if (!out.includes(realPosix)) out.push(realPosix);
|
|
650
|
+
const realRoot = fs.realpathSync(workspaceRoot);
|
|
651
|
+
if (realRoot !== workspaceRoot) {
|
|
652
|
+
if (realAbs.startsWith(realRoot + path.sep)) {
|
|
653
|
+
const mapped = path.join(workspaceRoot, realAbs.slice(realRoot.length));
|
|
654
|
+
if (!out.includes(mapped)) out.push(mapped);
|
|
655
|
+
const mappedPosix = toPosixPath(mapped);
|
|
656
|
+
if (!out.includes(mappedPosix)) out.push(mappedPosix);
|
|
657
|
+
} else if (abs.startsWith(workspaceRoot + path.sep)) {
|
|
658
|
+
const mappedReal = path.join(realRoot, abs.slice(workspaceRoot.length));
|
|
659
|
+
if (!out.includes(mappedReal)) out.push(mappedReal);
|
|
660
|
+
const mappedRealPosix = toPosixPath(mappedReal);
|
|
661
|
+
if (!out.includes(mappedRealPosix)) out.push(mappedRealPosix);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
} catch {
|
|
665
|
+
// Ignore missing realpath
|
|
666
|
+
}
|
|
667
|
+
return out;
|
|
668
|
+
}
|
|
639
669
|
|
|
640
670
|
function isOneShotBuild() {
|
|
641
671
|
return resolvedConfig?.command === 'build' && !resolvedConfig?.build?.watch;
|
|
@@ -995,10 +1025,29 @@ export function angularCompilerPlugin(options = {}) {
|
|
|
995
1025
|
// Ignore missing realpath
|
|
996
1026
|
}
|
|
997
1027
|
}
|
|
1028
|
+
const existingHotUpdateEnvs = userConfig?.server?.hotUpdateEnvironments;
|
|
998
1029
|
patch.server = {
|
|
999
1030
|
fs: {
|
|
1000
1031
|
allow: [...allowDirs],
|
|
1001
1032
|
},
|
|
1033
|
+
...(supportsEnvironmentHotUpdate
|
|
1034
|
+
? {
|
|
1035
|
+
async hotUpdateEnvironments(srv, hmr) {
|
|
1036
|
+
if (pendingHandledComponentHtmlCount > 0) {
|
|
1037
|
+
pendingHandledComponentHtmlCount--;
|
|
1038
|
+
const nonClientEnvs = Object.values(srv.environments).filter(
|
|
1039
|
+
(e) => e.name !== 'client',
|
|
1040
|
+
);
|
|
1041
|
+
await Promise.all(nonClientEnvs.map((e) => hmr(e)));
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
if (typeof existingHotUpdateEnvs === 'function') {
|
|
1045
|
+
return existingHotUpdateEnvs(srv, hmr);
|
|
1046
|
+
}
|
|
1047
|
+
await Promise.all(Object.values(srv.environments).map((e) => hmr(e)));
|
|
1048
|
+
},
|
|
1049
|
+
}
|
|
1050
|
+
: {}),
|
|
1002
1051
|
};
|
|
1003
1052
|
}
|
|
1004
1053
|
|
|
@@ -1096,6 +1145,7 @@ export function angularCompilerPlugin(options = {}) {
|
|
|
1096
1145
|
fileContentSnapshots.clear();
|
|
1097
1146
|
servedViaLoad.clear();
|
|
1098
1147
|
pendingDeferredTypecheck = false;
|
|
1148
|
+
pendingHandledComponentHtmlCount = 0;
|
|
1099
1149
|
|
|
1100
1150
|
const oneShot = isOneShotBuild();
|
|
1101
1151
|
const isTestMode = Boolean(
|
|
@@ -1357,205 +1407,274 @@ export function angularCompilerPlugin(options = {}) {
|
|
|
1357
1407
|
},
|
|
1358
1408
|
}),
|
|
1359
1409
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1410
|
+
...(supportsEnvironmentHotUpdate
|
|
1411
|
+
? {
|
|
1412
|
+
async hotUpdate(ctx) {
|
|
1413
|
+
if (this.environment && this.environment.name !== 'client') {
|
|
1414
|
+
return undefined;
|
|
1415
|
+
}
|
|
1416
|
+
return processHotUpdate(ctx);
|
|
1417
|
+
},
|
|
1418
|
+
}
|
|
1419
|
+
: {
|
|
1420
|
+
async handleHotUpdate(ctx) {
|
|
1421
|
+
return processHotUpdate(ctx);
|
|
1422
|
+
},
|
|
1423
|
+
}),
|
|
1424
|
+
};
|
|
1369
1425
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1426
|
+
async function processHotUpdate(ctx) {
|
|
1427
|
+
if (!compiler || ctx.type === 'delete') {
|
|
1428
|
+
return undefined;
|
|
1429
|
+
}
|
|
1430
|
+
const cleanFile = stripQueryAndHash(ctx.file);
|
|
1431
|
+
const candidates = resolveWorkspaceFileCandidates(cleanFile);
|
|
1432
|
+
const normFile = toPosixPath(path.resolve(cleanFile));
|
|
1433
|
+
if (normFile.includes('/node_modules/') || DTS_FILE_RE.test(normFile)) {
|
|
1434
|
+
return undefined;
|
|
1435
|
+
}
|
|
1374
1436
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1437
|
+
const isTsChange = TS_FILE_RE.test(normFile);
|
|
1438
|
+
const isResourceChange = RESOURCE_FILE_RE.test(normFile);
|
|
1439
|
+
const isTsconfigChange =
|
|
1440
|
+
normFile.endsWith('/tsconfig.json') || /tsconfig.*\.json$/i.test(path.basename(normFile));
|
|
1378
1441
|
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const affectedStylePaths = new Set();
|
|
1442
|
+
if (!isTsChange && !isResourceChange && !isTsconfigChange) {
|
|
1443
|
+
return undefined;
|
|
1444
|
+
}
|
|
1383
1445
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1446
|
+
// 1. Handle external component resource (.html / .css / .scss / .sass + SCSS partials)
|
|
1447
|
+
if (isResourceChange && !isTsChange) {
|
|
1448
|
+
let matchedResourceFile = cleanFile;
|
|
1449
|
+
let directOwners = [];
|
|
1450
|
+
for (const cand of candidates) {
|
|
1451
|
+
const owners = compiler.getAffectedComponentsForResource(cand);
|
|
1452
|
+
if (owners.length > 0) {
|
|
1453
|
+
directOwners = owners;
|
|
1454
|
+
matchedResourceFile = cand;
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
const matchedNormFile = toPosixPath(path.resolve(workspaceRoot, matchedResourceFile));
|
|
1459
|
+
const affectedStylePaths = new Set();
|
|
1460
|
+
|
|
1461
|
+
if (SASS_FILE_RE.test(normFile)) {
|
|
1462
|
+
if (directOwners.length > 0) {
|
|
1463
|
+
affectedStylePaths.add(matchedNormFile);
|
|
1464
|
+
}
|
|
1465
|
+
for (const cand of candidates) {
|
|
1466
|
+
const dependentStyles = partialToComponentStyles.get(toPosixPath(cand));
|
|
1398
1467
|
if (dependentStyles) {
|
|
1399
1468
|
for (const depStyle of dependentStyles) {
|
|
1400
1469
|
affectedStylePaths.add(depStyle);
|
|
1401
1470
|
}
|
|
1402
1471
|
}
|
|
1403
1472
|
}
|
|
1473
|
+
}
|
|
1404
1474
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1475
|
+
const rebuildTargets =
|
|
1476
|
+
affectedStylePaths.size > 0
|
|
1477
|
+
? [...affectedStylePaths]
|
|
1478
|
+
: directOwners.length > 0
|
|
1479
|
+
? [matchedResourceFile]
|
|
1480
|
+
: [];
|
|
1407
1481
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
return undefined;
|
|
1482
|
+
if (rebuildTargets.length === 0) {
|
|
1483
|
+
// Global stylesheet or unrelated static HTML file — let Vite handle natively
|
|
1484
|
+
if (/\.(?:css|scss|sass|less)$/i.test(normFile)) {
|
|
1485
|
+
options.onDevServerUpdate?.({ kind: 'style-update', file: cleanFile });
|
|
1414
1486
|
}
|
|
1487
|
+
return undefined;
|
|
1488
|
+
}
|
|
1415
1489
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1490
|
+
// Preserve only genuine Vite global CSS pipeline modules (e.g. `styles.scss?direct` with
|
|
1491
|
+
// `type === 'css'` / `isSelfAccepting`, or Sass partial `asset` nodes imported by global CSS).
|
|
1492
|
+
// Never return synthetic `type === 'js'` nodes registered via `this.addWatchFile(...)`,
|
|
1493
|
+
// which have `isSelfAccepting === false` and would otherwise force a Vite `full-reload`!
|
|
1494
|
+
const isStylesheetFile = /\.(?:css|scss|sass|less)$/i.test(normFile);
|
|
1495
|
+
const isHtmlTemplateFile = /\.html?$/i.test(normFile);
|
|
1496
|
+
const isGlobalCssPipelineMod = (m) =>
|
|
1497
|
+
m.type === 'css' ||
|
|
1498
|
+
Boolean(m.isSelfAccepting) ||
|
|
1499
|
+
(m.type === 'asset' &&
|
|
1500
|
+
Boolean(
|
|
1501
|
+
m.importers &&
|
|
1502
|
+
[...m.importers].some((imp) => imp.type === 'css' || Boolean(imp.isSelfAccepting)),
|
|
1503
|
+
));
|
|
1504
|
+
const passthroughCssMods = isStylesheetFile
|
|
1505
|
+
? (ctx.modules || []).filter(isGlobalCssPipelineMod)
|
|
1506
|
+
: [];
|
|
1507
|
+
|
|
1508
|
+
// Deduplicate duplicate OS watcher events (e.g. macOS FSEvents firing for both symlinked
|
|
1509
|
+
// `/var/folders/...` and canonical `/private/var/folders/...`) when content is unchanged.
|
|
1510
|
+
const diskContentNow = readDiskTextSafe(matchedNormFile);
|
|
1511
|
+
if (
|
|
1512
|
+
enableHmr &&
|
|
1513
|
+
diskContentNow !== null &&
|
|
1514
|
+
fileContentSnapshots.get(matchedNormFile) === diskContentNow
|
|
1515
|
+
) {
|
|
1516
|
+
const ownerHasActiveHmr = directOwners.some((owner) =>
|
|
1517
|
+
compiler.getHmrIdsForFile(owner).some((id) => activeHmrUpdates.has(id)),
|
|
1518
|
+
);
|
|
1519
|
+
if (ownerHasActiveHmr) {
|
|
1520
|
+
if (supportsEnvironmentHotUpdate && isHtmlTemplateFile && passthroughCssMods.length === 0) {
|
|
1521
|
+
pendingHandledComponentHtmlCount++;
|
|
1434
1522
|
}
|
|
1523
|
+
return passthroughCssMods;
|
|
1435
1524
|
}
|
|
1525
|
+
}
|
|
1436
1526
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1527
|
+
const resourceRebuildStart = performance.now();
|
|
1528
|
+
if (affectedStylePaths.size > 0) {
|
|
1529
|
+
try {
|
|
1530
|
+
const overrides = await preprocessComponentStyles([...affectedStylePaths]);
|
|
1531
|
+
if (overrides.length > 0) {
|
|
1532
|
+
compiler.setResourceOverrides(overrides);
|
|
1533
|
+
}
|
|
1534
|
+
} catch (err) {
|
|
1535
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1536
|
+
if (!options.suppressViteDiagnosticsLog) {
|
|
1537
|
+
resolvedConfig?.logger?.error(msg);
|
|
1538
|
+
}
|
|
1539
|
+
ctx.server.ws.send({
|
|
1540
|
+
type: 'error',
|
|
1541
|
+
err: { message: msg, stack: '', id: cleanFile, plugin: 'ngrs:angular-compiler' },
|
|
1542
|
+
});
|
|
1543
|
+
options.onDevServerUpdate?.({ kind: 'error', file: cleanFile, message: msg });
|
|
1544
|
+
if (supportsEnvironmentHotUpdate && isHtmlTemplateFile) {
|
|
1545
|
+
pendingHandledComponentHtmlCount++;
|
|
1449
1546
|
}
|
|
1547
|
+
return [];
|
|
1450
1548
|
}
|
|
1451
|
-
|
|
1452
|
-
const invalidatedOwnerMods = invalidateOwnerModules(ctx.server, ownerList);
|
|
1549
|
+
}
|
|
1453
1550
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
);
|
|
1551
|
+
const rebuildResult = compiler.rebuild(rebuildTargets);
|
|
1552
|
+
const resourceRebuildMs = performance.now() - resourceRebuildStart;
|
|
1553
|
+
for (const target of rebuildTargets) {
|
|
1554
|
+
recordSnapshot(target);
|
|
1555
|
+
}
|
|
1556
|
+
recordSnapshot(matchedResourceFile);
|
|
1557
|
+
recordSnapshot(cleanFile);
|
|
1558
|
+
surfaceDiagnostics(rebuildResult.diagnostics, null, ctx.server);
|
|
1458
1559
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1560
|
+
const allOwners = new Set(directOwners);
|
|
1561
|
+
for (const target of rebuildTargets) {
|
|
1562
|
+
for (const owner of compiler.getAffectedComponentsForResource(target)) {
|
|
1563
|
+
allOwners.add(owner);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
const ownerList = [...allOwners];
|
|
1567
|
+
const invalidatedOwnerMods = invalidateOwnerModules(ctx.server, ownerList);
|
|
1568
|
+
|
|
1569
|
+
if (enableHmr && rebuildResult.exitCode === 0) {
|
|
1570
|
+
let sentLiveHmr = false;
|
|
1571
|
+
const timestamp = Date.now();
|
|
1572
|
+
for (const owner of ownerList) {
|
|
1573
|
+
const hmrIds = compiler.getHmrIdsForFile(owner);
|
|
1574
|
+
for (const hmrId of hmrIds) {
|
|
1575
|
+
const updateCode = compiler.getHmrUpdateModule(hmrId);
|
|
1576
|
+
if (updateCode) {
|
|
1577
|
+
activeHmrUpdates.set(hmrId, updateCode);
|
|
1578
|
+
ctx.server.ws.send({
|
|
1579
|
+
type: 'custom',
|
|
1580
|
+
event: 'angular:component-update',
|
|
1581
|
+
data: { id: hmrId, timestamp },
|
|
1582
|
+
});
|
|
1583
|
+
sentLiveHmr = true;
|
|
1475
1584
|
}
|
|
1476
1585
|
}
|
|
1477
|
-
if (sentLiveHmr) {
|
|
1478
|
-
options.onDevServerUpdate?.({
|
|
1479
|
-
kind: 'component-update',
|
|
1480
|
-
file: cleanFile,
|
|
1481
|
-
durationMs: resourceRebuildMs,
|
|
1482
|
-
});
|
|
1483
|
-
return passthroughCssMods;
|
|
1484
|
-
}
|
|
1485
1586
|
}
|
|
1486
|
-
|
|
1487
|
-
if (invalidatedOwnerMods.length > 0) {
|
|
1587
|
+
if (sentLiveHmr) {
|
|
1488
1588
|
options.onDevServerUpdate?.({
|
|
1489
|
-
kind: '
|
|
1490
|
-
file:
|
|
1589
|
+
kind: 'component-update',
|
|
1590
|
+
file: matchedResourceFile,
|
|
1491
1591
|
durationMs: resourceRebuildMs,
|
|
1492
1592
|
});
|
|
1493
|
-
|
|
1593
|
+
if (supportsEnvironmentHotUpdate && isHtmlTemplateFile && passthroughCssMods.length === 0) {
|
|
1594
|
+
pendingHandledComponentHtmlCount++;
|
|
1595
|
+
}
|
|
1596
|
+
return passthroughCssMods;
|
|
1494
1597
|
}
|
|
1495
|
-
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
if (invalidatedOwnerMods.length > 0) {
|
|
1496
1601
|
options.onDevServerUpdate?.({
|
|
1497
1602
|
kind: 'reload',
|
|
1498
1603
|
file: cleanFile,
|
|
1499
1604
|
durationMs: resourceRebuildMs,
|
|
1500
1605
|
});
|
|
1501
|
-
return [];
|
|
1606
|
+
return [...invalidatedOwnerMods, ...passthroughCssMods];
|
|
1502
1607
|
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1608
|
+
ctx.server.ws.send({ type: 'full-reload', path: '*' });
|
|
1609
|
+
options.onDevServerUpdate?.({
|
|
1610
|
+
kind: 'reload',
|
|
1611
|
+
file: cleanFile,
|
|
1612
|
+
durationMs: resourceRebuildMs,
|
|
1613
|
+
});
|
|
1614
|
+
if (supportsEnvironmentHotUpdate && isHtmlTemplateFile) {
|
|
1615
|
+
pendingHandledComponentHtmlCount++;
|
|
1507
1616
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
recordSnapshot(cleanFile);
|
|
1617
|
+
return [];
|
|
1618
|
+
}
|
|
1511
1619
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1620
|
+
// 2. Handle .ts / fileReplacements / tsconfig.json changes
|
|
1621
|
+
if (isTsconfigChange) {
|
|
1622
|
+
refreshTsconfigMappings(tsconfigPath);
|
|
1623
|
+
}
|
|
1624
|
+
const matchedTsFile =
|
|
1625
|
+
candidates.find((c) => compiler.getEmittedModule?.(c) || compiler.getEmittedJs?.(c)) ||
|
|
1626
|
+
cleanFile;
|
|
1627
|
+
const tsRebuildStart = performance.now();
|
|
1628
|
+
compiler.rebuild([matchedTsFile]);
|
|
1629
|
+
recordSnapshot(matchedTsFile);
|
|
1630
|
+
recordSnapshot(cleanFile);
|
|
1631
|
+
|
|
1632
|
+
// Check if newly added/edited component introduced new .scss resources
|
|
1633
|
+
const postResources = compiler.getAllResources();
|
|
1634
|
+
const uncompiledScss = postResources.filter((r) => {
|
|
1635
|
+
if (!SASS_FILE_RE.test(r)) return false;
|
|
1636
|
+
const norm = toPosixPath(path.resolve(workspaceRoot, r));
|
|
1637
|
+
return !compiledComponentStyleCss.has(norm);
|
|
1638
|
+
});
|
|
1639
|
+
if (uncompiledScss.length > 0) {
|
|
1640
|
+
const extraOverrides = await preprocessComponentStyles(uncompiledScss);
|
|
1641
|
+
if (extraOverrides.length > 0) {
|
|
1642
|
+
compiler.setResourceOverrides(extraOverrides);
|
|
1643
|
+
compiler.rebuild(extraOverrides.map((o) => o.path));
|
|
1525
1644
|
}
|
|
1645
|
+
}
|
|
1526
1646
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1647
|
+
const tsRebuildMs = performance.now() - tsRebuildStart;
|
|
1648
|
+
surfaceDiagnostics(compiler.getDiagnostics(), null, ctx.server);
|
|
1529
1649
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
}
|
|
1650
|
+
// Refresh HMR cache for modified .ts components if applicable and invalidate Vite moduleGraph
|
|
1651
|
+
const changedTsPaths = [matchedTsFile];
|
|
1652
|
+
for (const rep of normalizedReplacements) {
|
|
1653
|
+
if (candidates.some((c) => toPosixPath(rep.with) === toPosixPath(c))) {
|
|
1654
|
+
changedTsPaths.push(rep.replace);
|
|
1536
1655
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1656
|
+
}
|
|
1657
|
+
for (const tsPath of changedTsPaths) {
|
|
1658
|
+
for (const hmrId of compiler.getHmrIdsForFile(tsPath)) {
|
|
1659
|
+
const updateCode = compiler.getHmrUpdateModule(hmrId);
|
|
1660
|
+
if (updateCode) {
|
|
1661
|
+
activeHmrUpdates.set(hmrId, updateCode);
|
|
1543
1662
|
}
|
|
1544
1663
|
}
|
|
1664
|
+
}
|
|
1545
1665
|
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1666
|
+
options.onDevServerUpdate?.({
|
|
1667
|
+
kind: 'reload',
|
|
1668
|
+
file: matchedTsFile,
|
|
1669
|
+
durationMs: tsRebuildMs,
|
|
1670
|
+
});
|
|
1551
1671
|
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
};
|
|
1672
|
+
const invalidated = invalidateOwnerModules(ctx.server, changedTsPaths);
|
|
1673
|
+
if (invalidated.length > 0) {
|
|
1674
|
+
return invalidated;
|
|
1675
|
+
}
|
|
1676
|
+
return ctx.modules;
|
|
1677
|
+
}
|
|
1559
1678
|
}
|
|
1560
1679
|
|
|
1561
1680
|
/**
|