Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 2 additions & 1 deletion dev-packages/rollup-utils/npmHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
makeSetSDKSourcePlugin,
makeSucrasePlugin,
} from './plugins/index.mjs';
import { makePackageNodeEsm } from './plugins/make-esm-plugin.mjs';
import { mergePlugins } from './utils.mjs';

const packageDotJSON = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './package.json'), { encoding: 'utf8' }));
Expand Down Expand Up @@ -120,7 +121,7 @@ export function makeBaseNPMConfig(options = {}) {
export function makeNPMConfigVariants(baseConfig) {
const variantSpecificConfigs = [
{ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } },
{ output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm') } },
{ output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm'), plugins: [makePackageNodeEsm()] } },
];

return variantSpecificConfigs.map(variant => deepMerge(baseConfig, variant));
Expand Down
16 changes: 16 additions & 0 deletions dev-packages/rollup-utils/plugins/make-esm-plugin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Outputs a package.json file with {type: module} in the root of the output directory so that Node
* treats .js files as ESM.
*/
export function makePackageNodeEsm() {
return {
name: 'make-package-node-esm',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'package.json',
source: '{ "type": "module" }',
});
},
};
}
13 changes: 13 additions & 0 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/npm/cjs/index.js",
"module": "build/npm/esm/index.js",
"types": "build/npm/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/esm/index.js"
},
"require": {
"types": "./build/npm.types/index.d.ts",
"default": "./build/npm/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/esm/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
9 changes: 9 additions & 0 deletions packages/deno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"license": "MIT",
"module": "build/index.mjs",
"types": "build/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/index.d.ts",
"default": "./build/index.mjs"
}
}
},
"publishConfig": {
"access": "public"
},
Expand Down
13 changes: 13 additions & 0 deletions packages/feedback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/npm/cjs/index.js",
"module": "build/npm/esm/index.js",
"types": "build/npm/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/esm/index.js"
},
"require": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/integration-shims/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
11 changes: 11 additions & 0 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"types": "build/types/index.types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.js"
},
"node": "./build/cjs/index.server.js",
"types": "./build/types/index.types.d.ts"
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
stripUrlQueryAndFragment,
} from '@sentry/utils';
import type { NEXT_DATA as NextData } from 'next/dist/next-server/lib/utils';
import { default as Router } from 'next/router';
import RouterImport from 'next/router';

// next/router v10 is CJS
//
// For ESM/CJS interoperability 'reasons', depending on how this file is loaded, Router might be on the default export
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
const Router: typeof RouterImport = RouterImport.events ? RouterImport : (RouterImport as any).default;

import { DEBUG_BUILD } from '../../common/debug-build';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WINDOW } from '@sentry/react';
import { JSDOM } from 'jsdom';
import type { NEXT_DATA as NextData } from 'next/dist/next-server/lib/utils';
import { default as Router } from 'next/router';
import Router from 'next/router';

import { pagesRouterInstrumentation } from '../../src/client/routing/pagesRouterRoutingInstrumentation';

Expand Down
13 changes: 13 additions & 0 deletions packages/node-experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
5 changes: 3 additions & 2 deletions packages/node-experimental/src/integrations/tracing/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { PrismaInstrumentation } from '@prisma/instrumentation';
// When importing CommonJs modules into an ESM module, we import the named exports directly.
import * as prismaInstrumentation from '@prisma/instrumentation';
import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';

Expand All @@ -10,7 +11,7 @@ const _prismaIntegration = (() => {
registerInstrumentations({
instrumentations: [
// does not have a hook to adjust spans & add origin
new PrismaInstrumentation({}),
new prismaInstrumentation.PrismaInstrumentation({}),
],
});
},
Expand Down
8 changes: 5 additions & 3 deletions packages/node-experimental/src/sdk/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import { defaultStackParser, getSentryRelease } from './api';
import { NodeClient } from './client';
import { initOtel } from './initOtel';

function getCjsOnlyIntegrations(isCjs = typeof require !== 'undefined'): Integration[] {
return isCjs ? [nativeNodeFetchIntegration(), modulesIntegration()] : [];
}

/** Get the default integrations for the Node Experimental SDK. */
export function getDefaultIntegrations(options: Options): Integration[] {
// TODO
Expand All @@ -51,17 +55,15 @@ export function getDefaultIntegrations(options: Options): Integration[] {
// Native Wrappers
consoleIntegration(),
httpIntegration(),
nativeNodeFetchIntegration(),
// Global Handlers
onUncaughtExceptionIntegration(),
onUnhandledRejectionIntegration(),
// Event Info
contextLinesIntegration(),
localVariablesIntegration(),
nodeContextIntegration(),
modulesIntegration(),
httpIntegration(),
nativeNodeFetchIntegration(),
...getCjsOnlyIntegrations(),
...(hasTracingEnabled(options) ? getAutoPerformanceIntegrations() : []),
];
}
Expand Down
13 changes: 13 additions & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/opentelemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
9 changes: 9 additions & 0 deletions packages/profiling-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"license": "MIT",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"require": {
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"lib/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
11 changes: 11 additions & 0 deletions packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"types": "build/types/index.types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.js"
},
"node": "./build/cjs/index.server.js",
"types": "./build/types/index.types.d.ts"
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
13 changes: 13 additions & 0 deletions packages/replay-canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
"main": "build/npm/cjs/index.js",
"module": "build/npm/esm/index.js",
"types": "build/npm/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/esm/index.js"
},
"require": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
Loading