Skip to content

Commit 300b155

Browse files
committed
remove minifying for now
1 parent 447f630 commit 300b155

File tree

4 files changed

+54
-98
lines changed

4 files changed

+54
-98
lines changed

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

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -86,71 +86,65 @@ export function makeBrowserBuildPlugin(isBrowserBuild) {
8686
});
8787
}
8888

89-
/**
90-
* Terser options for bundling the SDK.
91-
*
92-
* @see https://github.com/terser/terser#api-reference
93-
* @see https://github.com/TrySound/rollup-plugin-terser#options
94-
* @type {import('terser').MinifyOptions}
95-
*/
96-
export const terserOptions = {
97-
mangle: {
98-
// `captureException` and `captureMessage` are public API methods and they don't need to be listed here, as the
99-
// mangler won't touch user-facing things, but `sentryWrapped` is not user-facing, and would be mangled during
100-
// minification. (We need it in its original form to correctly detect our internal frames for stripping.) All three
101-
// are all listed here just for the clarity's sake, as they are all used in the frames manipulation process.
102-
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
103-
properties: {
104-
// allow mangling of private field names...
105-
regex: /^_[^_]/,
106-
reserved: [
107-
// ...except for `_experiments`, which we want to remain usable from the outside
108-
'_experiments',
109-
// We want to keep some replay fields unmangled to enable integration tests to access them
110-
'_replay',
111-
'_canvas',
112-
// We also can't mangle rrweb private fields when bundling rrweb in the replay CDN bundles
113-
'_cssText',
114-
// We want to keep the _integrations variable unmangled to send all installed integrations from replay
115-
'_integrations',
116-
// _meta is used to store metadata of replay network events
117-
'_meta',
118-
// We store SDK metadata in the options
119-
'_metadata',
120-
// Object we inject debug IDs into with bundler plugins
121-
'_sentryDebugIds',
122-
// These are used by instrument.ts in utils for identifying HTML elements & events
123-
'_sentryCaptured',
124-
'_sentryId',
125-
// Keeps the frozen DSC on a Sentry Span
126-
'_frozenDsc',
127-
// These are used to keep span & scope relationships
128-
'_sentryRootSpan',
129-
'_sentryChildSpans',
130-
'_sentrySpan',
131-
'_sentryScope',
132-
'_sentryIsolationScope',
133-
// require-in-the-middle calls `Module._resolveFilename`. We cannot mangle this (AWS lambda layer bundle).
134-
'_resolveFilename',
135-
// Set on e.g. the shim feedbackIntegration to be able to detect it
136-
'_isShim',
137-
// This is used in metadata integration
138-
'_sentryModuleMetadata',
139-
],
140-
},
141-
},
142-
output: {
143-
comments: false,
144-
},
145-
};
89+
// `terser` options reference: https://github.com/terser/terser#api-reference
90+
// `rollup-plugin-terser` options reference: https://github.com/TrySound/rollup-plugin-terser#options
14691

14792
/**
14893
* Create a plugin to perform minification using `terser`.
14994
*
15095
* @returns An instance of the `terser` plugin
15196
*/
15297
export function makeTerserPlugin() {
153-
return terser(terserOptions);
98+
return terser({
99+
mangle: {
100+
// `captureException` and `captureMessage` are public API methods and they don't need to be listed here, as the
101+
// mangler won't touch user-facing things, but `sentryWrapped` is not user-facing, and would be mangled during
102+
// minification. (We need it in its original form to correctly detect our internal frames for stripping.) All three
103+
// are all listed here just for the clarity's sake, as they are all used in the frames manipulation process.
104+
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
105+
properties: {
106+
// allow mangling of private field names...
107+
regex: /^_[^_]/,
108+
reserved: [
109+
// ...except for `_experiments`, which we want to remain usable from the outside
110+
'_experiments',
111+
// We want to keep some replay fields unmangled to enable integration tests to access them
112+
'_replay',
113+
'_canvas',
114+
// We also can't mangle rrweb private fields when bundling rrweb in the replay CDN bundles
115+
'_cssText',
116+
// We want to keep the _integrations variable unmangled to send all installed integrations from replay
117+
'_integrations',
118+
// _meta is used to store metadata of replay network events
119+
'_meta',
120+
// We store SDK metadata in the options
121+
'_metadata',
122+
// Object we inject debug IDs into with bundler plugins
123+
'_sentryDebugIds',
124+
// These are used by instrument.ts in utils for identifying HTML elements & events
125+
'_sentryCaptured',
126+
'_sentryId',
127+
// Keeps the frozen DSC on a Sentry Span
128+
'_frozenDsc',
129+
// These are used to keep span & scope relationships
130+
'_sentryRootSpan',
131+
'_sentryChildSpans',
132+
'_sentrySpan',
133+
'_sentryScope',
134+
'_sentryIsolationScope',
135+
// require-in-the-middle calls `Module._resolveFilename`. We cannot mangle this (AWS lambda layer bundle).
136+
'_resolveFilename',
137+
// Set on e.g. the shim feedbackIntegration to be able to detect it
138+
'_isShim',
139+
// This is used in metadata integration
140+
'_sentryModuleMetadata',
141+
],
142+
},
143+
},
144+
output: {
145+
comments: false,
146+
},
147+
});
154148
}
155149

156150
// We don't pass these plugins any options which need to be calculated or changed by us, so no need to wrap them in

packages/aws-serverless/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
},
7676
"devDependencies": {
7777
"@types/node": "^18.19.1",
78-
"@vercel/nft": "^0.29.4",
79-
"terser": "^5.43.1"
78+
"@vercel/nft": "^0.29.4"
8079
},
8180
"scripts": {
8281
"build": "run-p build:transpile build:types",

packages/aws-serverless/scripts/buildLambdaLayer.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/* eslint-disable no-console */
2-
// @ts-expect-error - no types
3-
import { terserOptions } from '@sentry-internal/rollup-utils';
42
import { nodeFileTrace } from '@vercel/nft';
53
import * as childProcess from 'child_process';
64
import * as fs from 'fs';
75
import * as path from 'path';
8-
import { minify } from 'terser';
96
import { version } from '../package.json';
107

118
/**
@@ -91,8 +88,6 @@ async function pruneNodeModules(): Promise<void> {
9188
console.log('Cleaning up empty directories.');
9289

9390
removeEmptyDirs('./build/aws/dist-serverless/nodejs/node_modules');
94-
95-
await minifyJavaScriptFiles(fileList);
9691
}
9792

9893
function removeEmptyDirs(dir: string): void {
@@ -142,35 +137,3 @@ function getAllFiles(dir: string): string[] {
142137
walkDirectory(dir);
143138
return files;
144139
}
145-
146-
async function minifyJavaScriptFiles(fileList: Set<string>): Promise<void> {
147-
console.log('Minifying JavaScript files.');
148-
let minifiedCount = 0;
149-
150-
for (const file of fileList) {
151-
if (!file.endsWith('.js') && !file.endsWith('.mjs') && !file.endsWith('.cjs')) {
152-
continue;
153-
}
154-
155-
// Skip minification for OpenTelemetry files to avoid CommonJS/ESM interop issues
156-
if (file.includes('@opentelemetry')) {
157-
continue;
158-
}
159-
160-
try {
161-
const fullPath = path.resolve(file);
162-
const code = fs.readFileSync(fullPath, 'utf-8');
163-
164-
const result = await minify(code, terserOptions);
165-
166-
if (result.code) {
167-
fs.writeFileSync(fullPath, result.code, 'utf-8');
168-
minifiedCount++;
169-
}
170-
} catch (error) {
171-
console.error(`Error minifying ${file}`, error);
172-
}
173-
}
174-
175-
console.log(`Minified ${minifiedCount} files.`);
176-
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29026,7 +29026,7 @@ terser@5.14.2:
2902629026
commander "^2.20.0"
2902729027
source-map-support "~0.5.20"
2902829028

29029-
terser@^5.10.0, terser@^5.17.4, terser@^5.31.1, terser@^5.43.1, terser@^5.7.0:
29029+
terser@^5.10.0, terser@^5.17.4, terser@^5.31.1, terser@^5.7.0:
2903029030
version "5.43.1"
2903129031
resolved "https://registry.yarnpkg.com/terser/-/terser-5.43.1.tgz#88387f4f9794ff1a29e7ad61fb2932e25b4fdb6d"
2903229032
integrity sha512-+6erLbBm0+LROX2sPXlUYx/ux5PyE9K/a92Wrt6oA+WDAoFTdpHE5tCYCI5PNzq2y8df4rA+QgHLJuR4jNymsg==

0 commit comments

Comments
 (0)