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

feat: Emit *.mjs files across all packages #10833

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4b99aaf
build: Make all packages emit mjs
AbhiPrasad Feb 27, 2024
ee1ec19
feat: Emit *.mjs files across all packages
AbhiPrasad Feb 27, 2024
921c283
fix size limit
AbhiPrasad Feb 28, 2024
52e88c2
Fix a load of ESM compatibility issues
timfish Feb 29, 2024
653f10b
Merge branch 'develop' into abhi-esmify
timfish Feb 29, 2024
442b935
Fix more ESM incompatibilities
timfish Feb 29, 2024
4400d68
Merge branch 'develop' into abhi-esmify
timfish Mar 1, 2024
0c57b11
can't import opentelemetry-instrumentation-fetch-node because it brea…
timfish Mar 1, 2024
309fc29
Merge branch 'abhi-esmify' of github.com:getsentry/sentry-javascript …
timfish Mar 1, 2024
d238f24
Merge branch 'develop' into abhi-esmify
timfish Mar 1, 2024
136f396
Remove `nativeNodeFetchIntegration` from default integrations
timfish Mar 1, 2024
18e3364
Merge branch 'abhi-esmify' of github.com:getsentry/sentry-javascript …
timfish Mar 1, 2024
f8743f5
Don't use mjs for browser
timfish Mar 1, 2024
abaf959
Don't use mjs for browser
timfish Mar 1, 2024
0f8051b
Merge branch 'develop' into abhi-esmify
timfish Mar 4, 2024
e8ed2de
Revert "Don't use mjs for browser"
timfish Mar 4, 2024
c07de79
Merge remote-tracking branch 'upstream/develop' into abhi-esmify
timfish Mar 4, 2024
6c3f7f0
Merge remote-tracking branch 'upstream/develop' into abhi-esmify
timfish Mar 4, 2024
ba04d76
Revert some changes and try nextjs paths
timfish Mar 5, 2024
2e64455
Fix nextjs global issue
timfish Mar 5, 2024
fa7afc3
Merge branch 'develop' into abhi-esmify
timfish Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 20 additions & 14 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ module.exports = [
// Main browser webpack builds
{
name: '@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, Replay, browserTracingIntegration, Feedback }',
gzip: true,
limit: '90 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, Replay, browserTracingIntegration }',
gzip: true,
limit: '75 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, Replay, browserTracingIntegration, ReplayCanvas }',
gzip: true,
limit: '90 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, Replay, browserTracingIntegration }',
gzip: true,
limit: '75 KB',
Expand All @@ -42,35 +42,35 @@ module.exports = [
},
{
name: '@sentry/browser (incl. Tracing) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, browserTracingIntegration }',
gzip: true,
limit: '35 KB',
},
{
name: '@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, browserTracingIntegration }',
gzip: true,
limit: '35 KB',
},
{
name: '@sentry/browser (incl. Feedback) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, Feedback }',
gzip: true,
limit: '50 KB',
},
{
name: '@sentry/browser (incl. sendFeedback) - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init, sendFeedback }',
gzip: true,
limit: '50 KB',
},
{
name: '@sentry/browser - Webpack (gzipped)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/index.mjs',
import: '{ init }',
gzip: true,
limit: '28 KB',
Expand Down Expand Up @@ -137,37 +137,43 @@ module.exports = [
// React
{
name: '@sentry/react (incl. Tracing, Replay) - Webpack (gzipped)',
path: 'packages/react/build/esm/index.js',
path: 'packages/react/build/esm/index.mjs',
import: '{ init, browserTracingIntegration, Replay }',
gzip: true,
limit: '75 KB',
},
{
name: '@sentry/react - Webpack (gzipped)',
path: 'packages/react/build/esm/index.js',
path: 'packages/react/build/esm/index.mjs',
import: '{ init }',
gzip: true,
limit: '30 KB',
},

// Next.js
// We ignore next/router and next/constants because they break size-limit calculation
// with new *.mjs bundles in v8
{
name: '@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped)',
path: 'packages/nextjs/build/esm/client/index.js',
path: 'packages/nextjs/build/esm/client/index.mjs',
import: '{ init, browserTracingIntegration, Replay }',
ignore: ['next/router', 'next/constants'],
gzip: true,
limit: '110 KB',
},
{
name: '@sentry/nextjs Client - Webpack (gzipped)',
path: 'packages/nextjs/build/esm/client/index.js',
path: 'packages/nextjs/build/esm/client/index.mjs',
import: '{ init }',
ignore: ['next/router', 'next/constants'],
gzip: true,
limit: '57 KB',
},

// Feedback
{
name: '@sentry-internal/feedback - Webpack (gzipped)',
path: 'packages/feedback/build/npm/esm/index.js',
path: 'packages/feedback/build/npm/esm/index.mjs',
import: '{ Feedback }',
gzip: true,
limit: '25 KB',
Expand Down
11 changes: 10 additions & 1 deletion dev-packages/rollup-utils/npmHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,20 @@ export function makeBaseNPMConfig(options = {}) {
});
}

export function makeNPMConfigVariants(baseConfig) {
export function makeNPMConfigVariants(baseConfig, options = {}) {
const { emitMjs = true, entryFileNameWithoutExtension = '[name]' } = options;
const variantSpecificConfigs = [
{ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } },
{ output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm') } },
];

if (emitMjs) {
variantSpecificConfigs[1].output.entryFileNames = `${entryFileNameWithoutExtension}.mjs`;
}

if (entryFileNameWithoutExtension !== '[name]') {
variantSpecificConfigs[0].output.entryFileNames = `${entryFileNameWithoutExtension}.js`;
}

return variantSpecificConfigs.map(variant => deepMerge(baseConfig, variant));
}
14 changes: 7 additions & 7 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
"types-ts3.8"
],
"main": "build/cjs/index.client.js",
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"module": "build/esm/index.server.mjs",
"browser": "build/esm/index.client.mjs",
"types": "build/types/index.types.d.ts",
"exports": {
".": {
"node": "./build/esm/index.server.js",
"browser": "./build/esm/index.client.js",
"import": "./build/esm/index.client.js",
"node": "./build/esm/index.server.mjs",
"browser": "./build/esm/index.client.mjs",
"import": "./build/esm/index.client.mjs",
"require": "./build/cjs/index.server.js",
"types": "./build/types/index.types.d.ts"
},
"./middleware": {
"node": "./build/esm/integration/middleware/index.js",
"import": "./build/esm/integration/middleware/index.js",
"node": "./build/esm/integration/middleware/index.mjs",
"import": "./build/esm/integration/middleware/index.mjs",
"require": "./build/cjs/integration/middleware/index.js",
"types": "./build/types/integration/middleware/index.types.d.ts"
}
Expand Down
15 changes: 14 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@
"types-ts3.8"
],
"main": "build/npm/cjs/index.js",
"module": "build/npm/esm/index.js",
"module": "build/npm/esm/index.mjs",
"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.mjs"
},
"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
15 changes: 14 additions & 1 deletion packages/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@
"types-ts3.8"
],
"main": "build/esm/index.js",
"module": "build/esm/index.js",
"module": "build/esm/index.mjs",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.mjs"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
15 changes: 14 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@
"types-ts3.8"
],
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"module": "build/esm/index.mjs",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.mjs"
},
"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
15 changes: 14 additions & 1 deletion packages/feedback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@
"types-ts3.8"
],
"main": "build/npm/cjs/index.js",
"module": "build/npm/esm/index.js",
"module": "build/npm/esm/index.mjs",
"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.mjs"
},
"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
15 changes: 14 additions & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@
"gatsby-node.d.ts"
],
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"module": "build/esm/index.mjs",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.mjs"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
15 changes: 14 additions & 1 deletion packages/integration-shims/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
"version": "8.0.0-alpha.0",
"description": "Shims for integrations in Sentry SDK.",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"module": "build/esm/index.mjs",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/types/index.d.ts",
"default": "./build/esm/index.mjs"
},
"require": {
"types": "./build/types/index.d.ts",
"default": "./build/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
Expand Down
17 changes: 14 additions & 3 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
"node": ">=14.8"
},
"main": "build/cjs/index.server.js",
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"module": "build/esm/index.server.mjs",
"browser": "build/esm/index.client.mjs",
"types": "build/types/index.types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"import": "./build/esm/index.client.mjs",
"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 Expand Up @@ -56,7 +67,7 @@
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "ts-node scripts/buildRollup.ts",
"build:transpile": "rollup -c rollup.npm.config.mjs",
"build:types": "run-s build:types:core build:types:downlevel",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
Expand Down
10 changes: 4 additions & 6 deletions packages/nextjs/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ export default [

packageSpecificConfig: {
output: {
// Preserve the original file structure (i.e., so that everything is still relative to `src`)
entryFileNames: 'config/templates/[name].js',

// this is going to be add-on code, so it doesn't need the trappings of a full module (and in fact actively
// shouldn't have them, lest they muck with the module to which we're adding it)
sourcemap: false,
Expand All @@ -55,21 +52,22 @@ export default [
],
},
}),
// Preserve the original file structure (i.e., so that everything is still relative to `src`)
{ entryFileNameWithoutExtension: 'config/templates/[name]' },
),
...makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/config/loaders/index.ts'],

packageSpecificConfig: {
output: {
// Preserve the original file structure (i.e., so that everything is still relative to `src`)
entryFileNames: 'config/loaders/[name].js',

// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
external: ['@rollup/plugin-commonjs', 'rollup'],
},
}),
// Preserve the original file structure (i.e., so that everything is still relative to `src`)
{ entryFileNameWithoutExtension: 'config/loaders/[name]' },
),
];