File tree 6 files changed +55
-6
lines changed
6 files changed +55
-6
lines changed Original file line number Diff line number Diff line change
1
+ # Info: the paths in this file are specified so that they align with the file
2
+ # structure in `./build` where this file is copied to. This is done by the
3
+ # prepack script `sentry-javascript/scripts/prepack.ts`.
4
+
1
5
*
6
+
2
7
! /dist /** /*
3
8
! /esm /** /*
4
- ! /build /types /** /*
9
+ ! /types /** /*
10
+
11
+ # Gatsby specific
5
12
! gatsby-browser.js
6
13
! gatsby-node.js
Original file line number Diff line number Diff line change 13
13
"engines" : {
14
14
"node" : " >=6"
15
15
},
16
- "main" : " dist/index.js" ,
17
- "module" : " esm/index.js" ,
16
+ "main" : " build/ dist/index.js" ,
17
+ "module" : " build/ esm/index.js" ,
18
18
"types" : " build/types/index.d.ts" ,
19
19
"publishConfig" : {
20
20
"access" : " public"
46
46
"build:es5:watch" : " yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***" ,
47
47
"build:esm:watch" : " tsc -p tsconfig.esm.json --watch" ,
48
48
"build:types:watch" : " tsc -p tsconfig.types.json --watch" ,
49
- "build:npm" : " npm pack" ,
49
+ "build:npm" : " ts-node ../../scripts/prepack.ts -noBundles && npm pack ./build " ,
50
50
"circularDepCheck" : " madge --circular src/index.ts" ,
51
51
"clean" : " rimraf dist esm build coverage" ,
52
52
"fix" : " run-s fix:eslint fix:prettier" ,
Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-console */
2
+ // DO NOT RUN this script yourself!
3
+ // This is invoked from the main `prepack.ts` script in `sentry-javascript/scripts/prepack.ts`.
4
+ import * as fs from 'fs' ;
5
+ import * as path from 'path' ;
6
+
7
+ const BUILD_DIR = 'build' ;
8
+ const PACKAGE_ASSETS = [ 'gatsby-browser.js' , 'gatsby-node.js' ] ;
9
+
10
+ // copy package-specific assets to build dir
11
+ PACKAGE_ASSETS . forEach ( asset => {
12
+ const assetPath = path . resolve ( asset ) ;
13
+ try {
14
+ if ( ! fs . existsSync ( assetPath ) ) {
15
+ console . error ( `Asset ${ asset } does not exist.` ) ;
16
+ process . exit ( 1 ) ;
17
+ }
18
+ fs . copyFileSync ( assetPath , path . resolve ( BUILD_DIR , asset ) ) ;
19
+ } catch ( error ) {
20
+ console . error ( `Error while copying ${ asset } to ${ BUILD_DIR } ` ) ;
21
+ }
22
+ } ) ;
Original file line number Diff line number Diff line change 3
3
4
4
"compilerOptions" : {
5
5
"module" : " commonjs" ,
6
- "outDir" : " dist"
6
+ "outDir" : " build/ dist"
7
7
}
8
8
}
Original file line number Diff line number Diff line change 3
3
4
4
"compilerOptions" : {
5
5
"module" : " es6" ,
6
- "outDir" : " esm"
6
+ "outDir" : " build/ esm"
7
7
}
8
8
}
Original file line number Diff line number Diff line change 6
6
the directory structure inside `build`.
7
7
*/
8
8
9
+ import * as childProcess from 'child_process' ;
9
10
import * as fs from 'fs' ;
10
11
import * as fse from 'fs-extra' ;
11
12
import * as path from 'path' ;
88
89
process . exit ( 1 ) ;
89
90
}
90
91
92
+ // execute package specific settings
93
+ // 1. check if a package called `<package-root>/scripts/prepack.ts` exitsts
94
+ // if yes, 2.) execute that script for things that are package-specific
95
+ const packagePrepackPath = path . resolve ( 'scripts' , 'prepack.ts' ) ;
96
+ try {
97
+ if ( fs . existsSync ( packagePrepackPath ) ) {
98
+ const proc = childProcess . fork ( packagePrepackPath ) ;
99
+ proc . on ( 'exit' , code => {
100
+ if ( code !== 0 ) {
101
+ console . error ( `Error while executing ${ packagePrepackPath . toString ( ) } ` ) ;
102
+ process . exit ( 1 ) ;
103
+ }
104
+ } ) ;
105
+ }
106
+ } catch ( error ) {
107
+ console . error ( `Error while trying to access ${ packagePrepackPath . toString ( ) } ` ) ;
108
+ process . exit ( 1 ) ;
109
+ }
110
+
91
111
console . log ( `\nSuccessfully finished prepack commands for ${ pkgJson . name } \n` ) ;
You can’t perform that action at this time.
0 commit comments