Skip to content

Commit 7397767

Browse files
committed
fix: local dev logs LWC mismatch warnings on every SSR request
1 parent 1350a3e commit 7397767

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/@lwc/engine-core/src/framework/check-version-mismatch.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export function checkVersionMismatch(
3838
) {
3939
const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
4040
if (!isNull(versionMatcher) && !warned) {
41+
if (process.env.SKIP_LWC_VERSION_MISMATCH_CHECK === 'true') {
42+
warned = true; // skip printing out version mismatch errors when env var is set
43+
return;
44+
}
45+
4146
const version = versionMatcher[1];
4247
if (version !== LWC_VERSION) {
4348
warned = true; // only warn once to avoid flooding the console

packages/@lwc/integration-karma/test/rendering/version-mismatch/index.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,27 @@ describe('compiler version mismatch', () => {
4848
});
4949

5050
afterEach(() => {
51+
process.env.SKIP_LWC_VERSION_MISMATCH_CHECK = 'false';
5152
detachReportingControlDispatcher();
5253
});
5354

55+
it('skip warning during local dev', () => {
56+
process.env.SKIP_LWC_VERSION_MISMATCH_CHECK = 'true';
57+
function tmpl() {
58+
return [];
59+
/*LWC compiler v123.456.789*/
60+
}
61+
62+
expect(() => {
63+
registerTemplate(tmpl);
64+
}).not.toLogErrorDev(
65+
new RegExp(
66+
`LWC WARNING: current engine is v${process.env.LWC_VERSION}, but template was compiled with v123.456.789`
67+
)
68+
);
69+
expect(dispatcher).not.toHaveBeenCalled();
70+
});
71+
5472
it('template', () => {
5573
function tmpl() {
5674
return [];

0 commit comments

Comments
 (0)