Skip to content

Commit 0ac1e10

Browse files
authored
feat(core/utils): Deprecate dynamicRequire (#14506)
1 parent a11630e commit 0ac1e10

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

docs/migration/draft-v9-migration-guide.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- Deprecated `getNumberOfUrlSegments`. No replacements.
3636
- Deprecated `BAGGAGE_HEADER_NAME`. No replacements.
3737
- Deprecated `makeFifoCache`. No replacements.
38+
- Deprecated `dynamicRequire`. No replacements.
3839
- Deprecated `flatten`. No replacements.
3940
- Deprecated `_browserPerformanceTimeOriginMode`. No replacements.
4041

packages/core/src/utils-hoist/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export {
4949
parseSemver,
5050
uuid4,
5151
} from './misc';
52+
// eslint-disable-next-line deprecation/deprecation
5253
export { dynamicRequire, isNodeEnv, loadModule } from './node';
5354
export { normalize, normalizeToSize, normalizeUrlToBase } from './normalize';
5455
export {

packages/core/src/utils-hoist/node.ts

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function isNodeEnv(): boolean {
2323
* Requires a module which is protected against bundler minification.
2424
*
2525
* @param request The module path to resolve
26+
* @deprecated This function will be removed in the next major version.
2627
*/
2728
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2829
export function dynamicRequire(mod: any, request: string): any {
@@ -47,14 +48,17 @@ export function loadModule<T>(moduleName: string): T | undefined {
4748
let mod: T | undefined;
4849

4950
try {
51+
// eslint-disable-next-line deprecation/deprecation
5052
mod = dynamicRequire(module, moduleName);
5153
} catch (e) {
5254
// no-empty
5355
}
5456

5557
if (!mod) {
5658
try {
59+
// eslint-disable-next-line deprecation/deprecation
5760
const { cwd } = dynamicRequire(module, 'process');
61+
// eslint-disable-next-line deprecation/deprecation
5862
mod = dynamicRequire(module, `${cwd()}/node_modules/${moduleName}`) as T;
5963
} catch (e) {
6064
// no-empty

packages/utils/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ export const browserPerformanceTimeOrigin = browserPerformanceTimeOrigin_importe
603603
export const supportsHistory = supportsHistory_imported;
604604

605605
/** @deprecated Import from `@sentry/core` instead. */
606+
// eslint-disable-next-line deprecation/deprecation
606607
export const dynamicRequire = dynamicRequire_imported;
607608

608609
/** @deprecated Import from `@sentry/core` instead. */

0 commit comments

Comments
 (0)