Skip to content

Commit 2937602

Browse files
authored
fix: add environment variable to disable LWC version mismatch loglines (#5187)
1 parent fa4c927 commit 2937602

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

+5
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

+14
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,23 @@ 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(new RegExp(`LWC WARNING:`));
65+
expect(dispatcher).not.toHaveBeenCalled();
66+
});
67+
5468
it('template', () => {
5569
function tmpl() {
5670
return [];

0 commit comments

Comments
 (0)