Skip to content

Commit 351046b

Browse files
committed
fix(build): Revert rollup-utils changes that broke package builds
The makeStripEsmPlugin and makeStripCjsPlugin additions to rollup-utils were causing the build output to be incorrectly structured (files going to browser/nextjs subdirectories instead of root). Also fix import to use @sentry/react instead of @sentry/browser directly.
1 parent 7501e60 commit 351046b

File tree

3 files changed

+11
-68
lines changed

3 files changed

+11
-68
lines changed

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import {
1818
makeNodeResolvePlugin,
1919
makeProductionReplacePlugin,
2020
makeRrwebBuildPlugin,
21-
makeStripCjsPlugin,
22-
makeStripEsmPlugin,
2321
makeSucrasePlugin,
2422
} from './plugins/index.mjs';
2523
import { makePackageNodeEsm } from './plugins/make-esm-plugin.mjs';
@@ -123,19 +121,13 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
123121

124122
if (emitCjs) {
125123
if (splitDevProd) {
126-
variantSpecificConfigs.push({
127-
output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs/dev') },
128-
plugins: [makeStripEsmPlugin()],
129-
});
124+
variantSpecificConfigs.push({ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs/dev') } });
130125
variantSpecificConfigs.push({
131126
output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs/prod') },
132-
plugins: [makeProductionReplacePlugin(), makeStripEsmPlugin()],
127+
plugins: [makeProductionReplacePlugin()],
133128
});
134129
} else {
135-
variantSpecificConfigs.push({
136-
output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') },
137-
plugins: [makeStripEsmPlugin()],
138-
});
130+
variantSpecificConfigs.push({ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } });
139131
}
140132
}
141133

@@ -145,22 +137,22 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
145137
output: {
146138
format: 'esm',
147139
dir: path.join(baseConfig.output.dir, 'esm/dev'),
148-
plugins: [makeStripCjsPlugin(), makePackageNodeEsm()],
140+
plugins: [makePackageNodeEsm()],
149141
},
150142
});
151143
variantSpecificConfigs.push({
152144
output: {
153145
format: 'esm',
154146
dir: path.join(baseConfig.output.dir, 'esm/prod'),
155-
plugins: [makeProductionReplacePlugin(), makeStripCjsPlugin(), makePackageNodeEsm()],
147+
plugins: [makeProductionReplacePlugin(), makePackageNodeEsm()],
156148
},
157149
});
158150
} else {
159151
variantSpecificConfigs.push({
160152
output: {
161153
format: 'esm',
162154
dir: path.join(baseConfig.output.dir, 'esm'),
163-
plugins: [makeStripCjsPlugin(), makePackageNodeEsm()],
155+
plugins: [makePackageNodeEsm()],
164156
},
165157
});
166158
}

dev-packages/rollup-utils/plugins/npmPlugins.mjs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -143,58 +143,6 @@ export function makeProductionReplacePlugin() {
143143
};
144144
}
145145

146-
/**
147-
* Creates a plugin to strip ESM-only code from CJS bundles.
148-
* ESM-only code should be wrapped in special comments:
149-
* /* rollup-esm-only *\/ ... /* rollup-esm-only-end *\/
150-
*
151-
* This is necessary for code that uses `import.meta` which causes syntax errors in CJS.
152-
*
153-
* @returns A rollup plugin that removes ESM-only blocks from CJS bundles.
154-
*/
155-
export function makeStripEsmPlugin() {
156-
const pattern = /\/\* rollup-esm-only \*\/[\s\S]*?\/\* rollup-esm-only-end \*\/\s*/g;
157-
158-
function stripEsmBlocks(code) {
159-
if (!code) return null;
160-
if (!code.includes('rollup-esm-only')) return null;
161-
const replaced = code.replace(pattern, '');
162-
return { code: replaced, map: null };
163-
}
164-
165-
return {
166-
name: 'strip-esm-only-blocks',
167-
renderChunk(code) {
168-
return stripEsmBlocks(code);
169-
},
170-
};
171-
}
172-
173-
/**
174-
* Creates a plugin to strip CJS-only code from ESM bundles.
175-
* CJS-only code should be wrapped in special comments:
176-
* /* rollup-cjs-only *\/ ... /* rollup-cjs-only-end *\/
177-
*
178-
* @returns A rollup plugin that removes CJS-only blocks from ESM bundles.
179-
*/
180-
export function makeStripCjsPlugin() {
181-
const pattern = /\/\* rollup-cjs-only \*\/[\s\S]*?\/\* rollup-cjs-only-end \*\/\s*/g;
182-
183-
function stripCjsBlocks(code) {
184-
if (!code) return null;
185-
if (!code.includes('rollup-cjs-only')) return null;
186-
const replaced = code.replace(pattern, '');
187-
return { code: replaced, map: null };
188-
}
189-
190-
return {
191-
name: 'strip-cjs-only-blocks',
192-
renderChunk(code) {
193-
return stripCjsBlocks(code);
194-
},
195-
};
196-
}
197-
198146
/**
199147
* Creates a plugin to replace build flags of rrweb with either a constant (if passed true/false) or with a safe statement that:
200148
* a) evaluates to `true`

packages/nextjs/src/client/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ import {
1111
GLOBAL_OBJ,
1212
resolveSpotlightOptions,
1313
} from '@sentry/core';
14-
import { spotlightBrowserIntegration } from '@sentry/browser';
1514
import type { BrowserOptions } from '@sentry/react';
16-
import { getDefaultIntegrations as getReactDefaultIntegrations, init as reactInit } from '@sentry/react';
15+
import {
16+
getDefaultIntegrations as getReactDefaultIntegrations,
17+
init as reactInit,
18+
spotlightBrowserIntegration,
19+
} from '@sentry/react';
1720
import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor';
1821
import { getVercelEnv } from '../common/getVercelEnv';
1922
import { isRedirectNavigationError } from '../common/nextNavigationErrorUtils';

0 commit comments

Comments
 (0)