1
- /* eslint-disable no-console */
2
1
import { Package } from '@sentry/types' ;
3
2
import { existsSync , mkdirSync , promises } from 'fs' ;
4
3
import HtmlWebpackPlugin from 'html-webpack-plugin' ;
@@ -9,11 +8,11 @@ import webpackConfig from '../webpack.config';
9
8
10
9
const PACKAGE_PATH = '../../packages' ;
11
10
12
- const bundleKey = process . env . PW_BUNDLE || '' ;
13
- const useCompiledModule = ( bundleKey && bundleKey === 'esm' ) || bundleKey === 'dist' ;
11
+ const bundleKey = process . env . PW_BUNDLE ;
12
+ const useCompiledModule = bundleKey && ( bundleKey === 'esm' || bundleKey === 'dist' ) ;
14
13
const useBundle = bundleKey && ! useCompiledModule ;
15
14
16
- const TEST_PATHS : Record < string , Record < string , string > > = {
15
+ const BUNDLE_PATHS : Record < string , Record < string , string > > = {
17
16
browser : {
18
17
dist : 'dist/index.js' ,
19
18
esm : 'esm/index.js' ,
@@ -43,26 +42,20 @@ async function generateSentryAlias(): Promise<Record<string, string>> {
43
42
44
43
return Object . fromEntries (
45
44
await Promise . all (
46
- dirents . map ( async packageName => {
45
+ dirents . map ( async d => {
47
46
const packageJSON : Package = JSON . parse (
48
- (
49
- await promises . readFile ( path . resolve ( PACKAGE_PATH , packageName , 'package.json' ) , { encoding : 'utf-8' } )
50
- ) . toString ( ) ,
47
+ ( await promises . readFile ( path . resolve ( PACKAGE_PATH , d , 'package.json' ) , { encoding : 'utf-8' } ) ) . toString ( ) ,
51
48
) ;
52
49
53
- const packagePath = path . resolve ( PACKAGE_PATH , packageName ) ;
50
+ const modulePath = path . resolve ( PACKAGE_PATH , d ) ;
54
51
55
- if ( useCompiledModule && TEST_PATHS [ packageName ] ) {
56
- const bundlePath = path . resolve ( packagePath , TEST_PATHS [ packageName ] [ bundleKey ] ) ;
57
-
58
- if ( ! existsSync ( bundlePath ) ) {
59
- console . warn ( `${ bundlePath } is not found. Try building the package before running tests.` ) ;
60
- }
52
+ if ( useCompiledModule && bundleKey && BUNDLE_PATHS [ d ] [ bundleKey ] ) {
53
+ const bundlePath = path . resolve ( modulePath , BUNDLE_PATHS [ d ] [ bundleKey ] ) ;
61
54
62
55
return [ packageJSON [ 'name' ] , bundlePath ] ;
63
56
}
64
57
65
- return [ packageJSON [ 'name' ] , packagePath ] ;
58
+ return [ packageJSON [ 'name' ] , modulePath ] ;
66
59
} ) ,
67
60
) ,
68
61
) ;
@@ -83,11 +76,12 @@ export async function generatePage(
83
76
mkdirSync ( localPath , { recursive : true } ) ;
84
77
}
85
78
86
- const bundlesToInject = useBundle
87
- ? [ 'browser' , 'tracing' ] . map ( sentryPackage =>
88
- path . resolve ( PACKAGE_PATH , sentryPackage , TEST_PATHS [ sentryPackage ] [ bundleKey ] ) ,
89
- )
90
- : [ ] ;
79
+ const bundlesToInject =
80
+ useBundle && bundleKey
81
+ ? [ 'browser' , 'tracing' ] . map ( sentryPackage =>
82
+ path . resolve ( PACKAGE_PATH , sentryPackage , BUNDLE_PATHS [ sentryPackage ] [ bundleKey ] ) ,
83
+ )
84
+ : [ ] ;
91
85
92
86
const initializationEntry = bundlesToInject . concat ( initializationPath ) ;
93
87
@@ -111,7 +105,8 @@ export async function generatePage(
111
105
filename : 'index.html' ,
112
106
template : templatePath ,
113
107
initialization : 'initialization.bundle.js' ,
114
- subject : `subject.bundle.js` ,
108
+ subject : 'subject.bundle.js' ,
109
+ inject : false ,
115
110
} ) ,
116
111
] ,
117
112
} ) ,
0 commit comments