@@ -20,7 +20,6 @@ import type {
20
20
WebpackConfigObject ,
21
21
WebpackConfigObjectWithModuleRules ,
22
22
WebpackEntryProperty ,
23
- WebpackModuleRule ,
24
23
} from './types' ;
25
24
import { getWebpackPluginOptions } from './webpackPluginOptions' ;
26
25
@@ -305,35 +304,6 @@ export function constructWebpackConfigFunction(
305
304
}
306
305
}
307
306
308
- // TODO(v8): Remove this logic since we are deprecating es5.
309
- // The SDK uses syntax (ES6 and ES6+ features like object spread) which isn't supported by older browsers. For users
310
- // who want to support such browsers, `transpileClientSDK` allows them to force the SDK code to go through the same
311
- // transpilation that their code goes through. We don't turn this on by default because it increases bundle size
312
- // fairly massively.
313
- if ( ! isServer && userSentryOptions ?. transpileClientSDK ) {
314
- // Find all loaders which apply transpilation to user code
315
- const transpilationRules = findTranspilationRules ( newConfig . module ?. rules , projectDir ) ;
316
-
317
- // For each matching rule, wrap its `exclude` function so that it won't exclude SDK files, even though they're in
318
- // `node_modules` (which is otherwise excluded)
319
- transpilationRules . forEach ( rule => {
320
- // All matching rules will necessarily have an `exclude` property, but this keeps TS happy
321
- if ( rule . exclude && typeof rule . exclude === 'function' ) {
322
- const origExclude = rule . exclude ;
323
-
324
- const newExclude = ( filepath : string ) : boolean => {
325
- if ( filepath . includes ( '@sentry' ) ) {
326
- // `false` in this case means "don't exclude it"
327
- return false ;
328
- }
329
- return origExclude ( filepath ) ;
330
- } ;
331
-
332
- rule . exclude = newExclude ;
333
- }
334
- } ) ;
335
- }
336
-
337
307
if ( ! isServer ) {
338
308
// Tell webpack to inject the client config files (containing the client-side `Sentry.init()` call) into the appropriate output
339
309
// bundles. Store a separate reference to the original `entry` value to avoid an infinite loop. (If we don't do
@@ -385,72 +355,6 @@ export function constructWebpackConfigFunction(
385
355
} ;
386
356
}
387
357
388
- /**
389
- * Determine if this `module.rules` entry is one which will transpile user code
390
- *
391
- * @param rule The rule to check
392
- * @param projectDir The path to the user's project directory
393
- * @returns True if the rule transpiles user code, and false otherwise
394
- */
395
- function isMatchingRule ( rule : WebpackModuleRule , projectDir : string ) : boolean {
396
- // We want to run our SDK code through the same transformations the user's code will go through, so we test against a
397
- // sample user code path
398
- const samplePagePath = path . resolve ( projectDir , 'pageFile.js' ) ;
399
- if ( rule . test && rule . test instanceof RegExp && ! rule . test . test ( samplePagePath ) ) {
400
- return false ;
401
- }
402
- if ( Array . isArray ( rule . include ) && ! rule . include . includes ( projectDir ) ) {
403
- return false ;
404
- }
405
-
406
- // `rule.use` can be an object or an array of objects. For simplicity, force it to be an array.
407
- const useEntries = arrayify ( rule . use ) ;
408
-
409
- // Depending on the version of nextjs we're talking about, the loader which does the transpiling is either
410
- //
411
- // 'next-babel-loader' (next 10),
412
- // '/abs/path/to/node_modules/next/more/path/babel/even/more/path/loader/yet/more/path/index.js' (next 11), or
413
- // 'next-swc-loader' (next 12).
414
- //
415
- // The next 11 option is ugly, but thankfully 'next', 'babel', and 'loader' do appear in it in the same order as in
416
- // 'next-babel-loader', so we can use the same regex to test for both.
417
- if ( ! useEntries . some ( entry => entry ?. loader && / n e x t .* ( b a b e l | s w c ) .* l o a d e r / . test ( entry . loader ) ) ) {
418
- return false ;
419
- }
420
-
421
- return true ;
422
- }
423
-
424
- /**
425
- * Find all rules in `module.rules` which transpile user code.
426
- *
427
- * @param rules The `module.rules` value
428
- * @param projectDir The path to the user's project directory
429
- * @returns An array of matching rules
430
- */
431
- function findTranspilationRules ( rules : WebpackModuleRule [ ] | undefined , projectDir : string ) : WebpackModuleRule [ ] {
432
- if ( ! rules ) {
433
- return [ ] ;
434
- }
435
-
436
- const matchingRules : WebpackModuleRule [ ] = [ ] ;
437
-
438
- // Each entry in `module.rules` is either a rule in and of itself or an object with a `oneOf` property, whose value is
439
- // an array of rules
440
- rules . forEach ( rule => {
441
- // if (rule.oneOf) {
442
- if ( isMatchingRule ( rule , projectDir ) ) {
443
- matchingRules . push ( rule ) ;
444
- } else if ( rule . oneOf ) {
445
- const matchingOneOfRules = rule . oneOf . filter ( oneOfRule => isMatchingRule ( oneOfRule , projectDir ) ) ;
446
- matchingRules . push ( ...matchingOneOfRules ) ;
447
- // } else if (isMatchingRule(rule, projectDir)) {
448
- }
449
- } ) ;
450
-
451
- return matchingRules ;
452
- }
453
-
454
358
/**
455
359
* Modify the webpack `entry` property so that the code in `sentry.client.config.js` is
456
360
* included in the the necessary bundles.
0 commit comments