Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework development mode related inferno warnings #1573 #1582 #1666

Merged
merged 1 commit into from
Feb 4, 2024
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
2 changes: 2 additions & 0 deletions packages/inferno/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2326,4 +2326,6 @@ declare global {
semantics: Inferno.DetailedHTMLProps<Inferno.HTMLAttributes<MathMLElement>, MathMLElement>;
}
}

var SKIP_INFERNO_WARNINGS: string;
p1100i marked this conversation as resolved.
Show resolved Hide resolved
}
39 changes: 21 additions & 18 deletions packages/inferno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,30 @@ import { createRef, forwardRef, mountRef } from './core/refs';
export * from './core/types';

if (process.env.NODE_ENV !== 'production') {
// Checks if Inferno is running in jest testing environment.
const testingEnv =
typeof process === 'object' && process.env?.JEST_WORKER_ID !== undefined;
p1100i marked this conversation as resolved.
Show resolved Hide resolved
const skipWarnings =
typeof SKIP_INFERNO_WARNINGS !== 'undefined' ||
(typeof process === 'object' &&
(process.env?.SKIP_INFERNO_WARNINGS !== undefined ||
process.env?.JEST_WORKER_ID !== undefined));

// This message informs developers that they are using development mode (can happen
// in production because of bundling mistakes) and, therefore, Inferno is slower
// than in production mode. Skipping the notification for testing mode to keep testing
// console clear.
if (!skipWarnings) {
// This message informs developers that they are using development mode
// (can happen in production because of bundling mistakes) and, therefore,
// Inferno is slower than in production mode.
console.log('Inferno is in development mode.');

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const testFunc = function testFn() {};
console.log('Inferno is in development mode.');
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const testFunc = function testFn() {};

// eslint-disable-next-line
if (!testingEnv && !((testFunc as Function).name || testFunc.toString()).includes('testFn')) {
warning(
"It looks like you're using a minified copy of the development build " +
'of Inferno. When deploying Inferno apps to production, make sure to use ' +
'the production build which skips development warnings and is faster. ' +
'See http://infernojs.org for more details.',
);
// eslint-disable-next-line
if (!((testFunc as Function).name || testFunc.toString()).includes('testFn')) {
warning(
"It looks like you're using a minified copy of the development build " +
'of Inferno. When deploying Inferno apps to production, make sure to use ' +
'the production build which skips development warnings and is faster. ' +
'See http://infernojs.org for more details.',
);
}
}
}

Expand Down
Loading