File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ module.exports = {
66 parserOptions : {
77 jsx : true ,
88 } ,
9+ ignorePatterns : [ 'scripts/prepack.ts' ] ,
910 extends : [ '../../.eslintrc.js' ] ,
1011} ;
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+
15*
6+
27! /dist /** /*
38! /esm /** /*
4- ! /build /types /** /*
9+ ! /types /** /*
10+
11+ # Gatsby specific
512! gatsby-browser.js
613! gatsby-node.js
Original file line number Diff line number Diff line change 1313 "engines" : {
1414 "node" : " >=6"
1515 },
16- "main" : " dist/index.js" ,
17- "module" : " esm/index.js" ,
16+ "main" : " build/ dist/index.js" ,
17+ "module" : " build/ esm/index.js" ,
1818 "types" : " build/types/index.d.ts" ,
1919 "publishConfig" : {
2020 "access" : " public"
4646 "build:es5:watch" : " yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***" ,
4747 "build:esm:watch" : " tsc -p tsconfig.esm.json --watch" ,
4848 "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 " ,
5050 "circularDepCheck" : " madge --circular src/index.ts" ,
5151 "clean" : " rimraf dist esm build coverage" ,
5252 "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 33
44 "compilerOptions" : {
55 "module" : " commonjs" ,
6- "outDir" : " dist"
6+ "outDir" : " build/ dist"
77 }
88}
Original file line number Diff line number Diff line change 33
44 "compilerOptions" : {
55 "module" : " es6" ,
6- "outDir" : " esm"
6+ "outDir" : " build/ esm"
77 }
88}
Original file line number Diff line number Diff line change 66 the directory structure inside `build`.
77*/
88
9+ import * as childProcess from 'child_process' ;
910import * as fs from 'fs' ;
1011import * as fse from 'fs-extra' ;
1112import * as path from 'path' ;
8889 process . exit ( 1 ) ;
8990}
9091
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+
91111console . log ( `\nSuccessfully finished prepack commands for ${ pkgJson . name } \n` ) ;
You can’t perform that action at this time.
0 commit comments