diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index e2ec03cfc7..d3bf7eea7e 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -11,3 +11,4 @@ export * from './dom'; export * from './exhaustiveCheck'; export * from './context/PortalContext'; export * from './getComponentBreakpoint'; +export * from './warning'; diff --git a/packages/shared/src/warning.ts b/packages/shared/src/warning.ts new file mode 100644 index 0000000000..72bf8c27ab --- /dev/null +++ b/packages/shared/src/warning.ts @@ -0,0 +1,11 @@ +/* eslint-disable no-console */ +let warnings: Set | null; + +if (process.env.NODE_ENV === 'development') { + warnings = new Set(); +} + +export function devWarning(message: string) { + if (!(process.env.NODE_ENV === 'development') || warnings?.has(message)) return; + console.warn(message); +} diff --git a/typings/environment.d.ts b/typings/environment.d.ts new file mode 100644 index 0000000000..689e680871 --- /dev/null +++ b/typings/environment.d.ts @@ -0,0 +1,9 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + NODE_ENV: 'development' | 'production' | 'test'; + } + } +} + +export {};