Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lwc-monorepo",
"version": "8.12.4",
"version": "8.12.5",
"private": true,
"description": "Lightning Web Components",
"repository": {
Expand Down Expand Up @@ -34,43 +34,43 @@
},
"devDependencies": {
"@commitlint/cli": "^19.6.1",
"@eslint/js": "9.17.0",
"@eslint/js": "9.18.0",
"@lwc/eslint-plugin-lwc-internal": "link:./scripts/eslint-plugin",
"@lwc/test-utils-lwc-internals": "link:./scripts/test-utils",
"@nx/js": "20.3.0",
"@nx/js": "20.3.2",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-typescript": "^12.1.2",
"@swc-node/register": "~1.10.9",
"@swc/core": "~1.10.4",
"@swc/core": "~1.10.8",
"@swc/helpers": "~0.5.15",
"@types/babel__core": "^7.20.5",
"@types/node": "^22.10.5",
"@types/node": "^22.10.7",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/eslint-plugin": "^1.1.24",
"@vitest/eslint-plugin": "^1.1.25",
"@vitest/ui": "^2.1.8",
"bytes": "^3.1.2",
"es-module-lexer": "^1.6.0",
"eslint": "9.17.0",
"eslint-config-flat-gitignore": "^0.3.0",
"eslint": "9.18.0",
"eslint-config-flat-gitignore": "^1.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.31.0",
"glob": "^11.0.0",
"glob": "^11.0.1",
"globals": "^15.14.0",
"husky": "^9.1.7",
"isbinaryfile": "^5.0.4",
"jsdom": "^25.0.1",
"lint-staged": "^15.3.0",
"jsdom": "^26.0.0",
"lint-staged": "^15.4.1",
"magic-string": "^0.30.17",
"nx": "20.3.0",
"nx": "20.3.2",
"prettier": "^3.4.2",
"rollup": "^4.30.0",
"rollup": "^4.31.0",
"terser": "^5.37.0",
"tslib": "^2.8.1",
"typescript": "5.4.5",
"typescript-eslint": "8.19.0",
"typescript-eslint": "8.20.0",
"vitest": "^2.1.8"
},
"lint-staged": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/aria-reflection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/aria-reflection",
"version": "8.12.4",
"version": "8.12.5",
"description": "ARIA element reflection polyfill for strings",
"keywords": [
"aom",
Expand Down
6 changes: 3 additions & 3 deletions packages/@lwc/babel-plugin-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/babel-plugin-component",
"version": "8.12.4",
"version": "8.12.5",
"description": "Babel plugin to transform a LWC module",
"keywords": [
"lwc"
Expand Down Expand Up @@ -47,8 +47,8 @@
},
"dependencies": {
"@babel/helper-module-imports": "7.25.9",
"@lwc/errors": "8.12.4",
"@lwc/shared": "8.12.4",
"@lwc/errors": "8.12.5",
"@lwc/shared": "8.12.5",
"line-column": "~1.0.2"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions packages/@lwc/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/compiler",
"version": "8.12.4",
"version": "8.12.5",
"description": "LWC compiler",
"keywords": [
"lwc"
Expand Down Expand Up @@ -52,11 +52,11 @@
"@babel/plugin-transform-class-properties": "7.25.9",
"@babel/plugin-transform-object-rest-spread": "7.25.9",
"@locker/babel-plugin-transform-unforgeables": "0.22.0",
"@lwc/babel-plugin-component": "8.12.4",
"@lwc/errors": "8.12.4",
"@lwc/shared": "8.12.4",
"@lwc/ssr-compiler": "8.12.4",
"@lwc/style-compiler": "8.12.4",
"@lwc/template-compiler": "8.12.4"
"@lwc/babel-plugin-component": "8.12.5",
"@lwc/errors": "8.12.5",
"@lwc/shared": "8.12.5",
"@lwc/ssr-compiler": "8.12.5",
"@lwc/style-compiler": "8.12.5",
"@lwc/template-compiler": "8.12.5"
}
}
8 changes: 4 additions & 4 deletions packages/@lwc/engine-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/engine-core",
"version": "8.12.4",
"version": "8.12.5",
"description": "Core LWC engine APIs.",
"keywords": [
"lwc"
Expand Down Expand Up @@ -46,9 +46,9 @@
}
},
"dependencies": {
"@lwc/features": "8.12.4",
"@lwc/shared": "8.12.4",
"@lwc/signals": "8.12.4"
"@lwc/features": "8.12.5",
"@lwc/shared": "8.12.5",
"@lwc/signals": "8.12.5"
},
"devDependencies": {
"observable-membrane": "2.0.0"
Expand Down
105 changes: 105 additions & 0 deletions packages/@lwc/engine-core/src/framework/hydration-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { ArrayPush, ArrayJoin, ArraySort, ArrayFrom, isNull, isUndefined } from '@lwc/shared';

import { assertNotProd } from './utils';

// Errors that occured during the hydration process
let hydrationErrors: Array<HydrationError> = [];

// These values are the ones from Node.nodeType (https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType)
const enum EnvNodeTypes {
ELEMENT = 1,
TEXT = 3,
COMMENT = 8,
}

interface HydrationError {
type: string;
serverRendered: any;
clientExpected: any;
}

export type Classes = Omit<Set<string>, 'add'>;

/*
Prints attributes as null or "value"
*/
export function prettyPrintAttribute(attribute: string, value: any): string {
assertNotProd(); // this method should never leak to prod
return `${attribute}=${isNull(value) || isUndefined(value) ? value : `"${value}"`}`;
}

/*
Sorts and stringifies classes
*/
export function prettyPrintClasses(classes: Classes) {
assertNotProd(); // this method should never leak to prod
const value = JSON.stringify(ArrayJoin.call(ArraySort.call(ArrayFrom(classes)), ' '));
return `class=${value}`;
}

/*
Hydration errors occur before the source node has been fully hydrated,
queue them so they can be logged later against the mounted node.
*/
export function queueHydrationError(type: string, serverRendered?: any, clientExpected?: any) {
assertNotProd(); // this method should never leak to prod
ArrayPush.call(hydrationErrors, { type, serverRendered, clientExpected });
}

/*
Flushes (logs) any queued errors after the source node has been mounted.
*/
export function flushHydrationErrors(source?: Node | null) {
assertNotProd(); // this method should never leak to prod
for (const hydrationError of hydrationErrors) {
logHydrationWarning(
`Hydration ${hydrationError.type} mismatch on:`,
source,
`\n- rendered on server:`,
hydrationError.serverRendered,
`\n- expected on client:`,
hydrationError.clientExpected || source
);
}
hydrationErrors = [];
}

export function isTypeElement(node?: Node): node is Element {
const isCorrectType = node?.nodeType === EnvNodeTypes.ELEMENT;
if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
queueHydrationError('node', node);
}
return isCorrectType;
}

export function isTypeText(node?: Node): node is Text {
const isCorrectType = node?.nodeType === EnvNodeTypes.TEXT;
if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
queueHydrationError('node', node);
}
return isCorrectType;
}

export function isTypeComment(node?: Node): node is Comment {
const isCorrectType = node?.nodeType === EnvNodeTypes.COMMENT;
if (process.env.NODE_ENV !== 'production' && !isCorrectType) {
queueHydrationError('node', node);
}
return isCorrectType;
}

/*
logger.ts converts all args to a string, losing object referenences and has
legacy bloat which would have meant more pathing.
*/
export function logHydrationWarning(...args: any) {
assertNotProd(); // this method should never leak to prod
/* eslint-disable-next-line no-console */
console.warn('[LWC warn:', ...args);
}
Loading
Loading