Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
1.5 KiB
Text
34 lines
1.5 KiB
Text
import { GLOBAL_OBJ, debug, consoleSandbox } from '@sentry/core';
|
|
import { createAddHookMessageChannel } from 'import-in-the-middle';
|
|
import moduleModule from 'module';
|
|
|
|
/** Initialize the ESM loader. */
|
|
function maybeInitializeEsmLoader() {
|
|
const [nodeMajor = 0, nodeMinor = 0] = process.versions.node.split('.').map(Number);
|
|
|
|
// Register hook was added in v20.6.0 and v18.19.0
|
|
if (nodeMajor >= 21 || (nodeMajor === 20 && nodeMinor >= 6) || (nodeMajor === 18 && nodeMinor >= 19)) {
|
|
if (!GLOBAL_OBJ._sentryEsmLoaderHookRegistered) {
|
|
try {
|
|
const { addHookMessagePort } = createAddHookMessageChannel();
|
|
// @ts-expect-error register is available in these versions
|
|
moduleModule.register('import-in-the-middle/hook.mjs', import.meta.url, {
|
|
data: { addHookMessagePort, include: [] },
|
|
transferList: [addHookMessagePort],
|
|
});
|
|
} catch (error) {
|
|
debug.warn('Failed to register ESM hook', error);
|
|
}
|
|
}
|
|
} else {
|
|
consoleSandbox(() => {
|
|
// eslint-disable-next-line no-console
|
|
console.warn(
|
|
`[Sentry] You are using Node.js v${process.versions.node} in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.`,
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
export { maybeInitializeEsmLoader };
|
|
//# sourceMappingURL=esmLoader.js.map
|