@@ -57,7 +57,6 @@ var BUNDLED_FILE_HEADER = [
5757const languages = i18n . defaultLanguages . concat ( [ ] ) ; // i18n.defaultLanguages.concat(process.env.VSCODE_QUALITY !== 'stable' ? i18n.extraLanguages : []);
5858
5959const extractEditorSrcTask = task . define ( 'extract-editor-src' , ( ) => {
60- console . log ( `If the build fails, consider tweaking shakeLevel below to a lower value.` ) ;
6160 const apiusages = monacoapi . execute ( ) . usageContent ;
6261 const extrausages = fs . readFileSync ( path . join ( root , 'build' , 'monaco' , 'monaco.usage.recipe' ) ) . toString ( ) ;
6362 standalone . extractEditor ( {
@@ -71,14 +70,6 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
7170 apiusages ,
7271 extrausages
7372 ] ,
74- typings : [
75- 'typings/lib.ie11_safe_es6.d.ts' ,
76- 'typings/thenable.d.ts' ,
77- 'typings/es6-promise.d.ts' ,
78- 'typings/require-monaco.d.ts' ,
79- "typings/lib.es2018.promise.d.ts" ,
80- 'vs/monaco.d.ts'
81- ] ,
8273 libs : [
8374 `lib.es5.d.ts` ,
8475 `lib.dom.d.ts` ,
@@ -138,18 +129,70 @@ const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () =>
138129} ) ;
139130
140131const compileEditorESMTask = task . define ( 'compile-editor-esm' , ( ) => {
132+ console . log ( `Launching the TS compiler at ${ path . join ( __dirname , '../out-editor-esm' ) } ...` ) ;
133+ let result ;
141134 if ( process . platform === 'win32' ) {
142- const result = cp . spawnSync ( `..\\node_modules\\.bin\\tsc.cmd` , {
135+ result = cp . spawnSync ( `..\\node_modules\\.bin\\tsc.cmd` , {
143136 cwd : path . join ( __dirname , '../out-editor-esm' )
144137 } ) ;
145- console . log ( result . stdout . toString ( ) ) ;
146- console . log ( result . stderr . toString ( ) ) ;
147138 } else {
148- const result = cp . spawnSync ( `node` , [ `../node_modules/.bin/tsc` ] , {
139+ result = cp . spawnSync ( `node` , [ `../node_modules/.bin/tsc` ] , {
149140 cwd : path . join ( __dirname , '../out-editor-esm' )
150141 } ) ;
151- console . log ( result . stdout . toString ( ) ) ;
152- console . log ( result . stderr . toString ( ) ) ;
142+ }
143+
144+ console . log ( result . stdout . toString ( ) ) ;
145+ console . log ( result . stderr . toString ( ) ) ;
146+
147+ if ( result . status !== 0 ) {
148+ console . log ( `The TS Compilation failed, preparing analysis folder...` ) ;
149+ const destPath = path . join ( __dirname , '../../vscode-monaco-editor-esm-analysis' ) ;
150+ return util . rimraf ( destPath ) ( ) . then ( ( ) => {
151+ fs . mkdirSync ( destPath ) ;
152+
153+ // initialize a new repository
154+ cp . spawnSync ( `git` , [ `init` ] , {
155+ cwd : destPath
156+ } ) ;
157+
158+ // build a list of files to copy
159+ const files = util . rreddir ( path . join ( __dirname , '../out-editor-esm' ) ) ;
160+
161+ // copy files from src
162+ for ( const file of files ) {
163+ const srcFilePath = path . join ( __dirname , '../src' , file ) ;
164+ const dstFilePath = path . join ( destPath , file ) ;
165+ if ( fs . existsSync ( srcFilePath ) ) {
166+ util . ensureDir ( path . dirname ( dstFilePath ) ) ;
167+ const contents = fs . readFileSync ( srcFilePath ) . toString ( ) . replace ( / \r \n | \r | \n / g, '\n' ) ;
168+ fs . writeFileSync ( dstFilePath , contents ) ;
169+ }
170+ }
171+
172+ // create an initial commit to diff against
173+ cp . spawnSync ( `git` , [ `add` , `.` ] , {
174+ cwd : destPath
175+ } ) ;
176+
177+ // create the commit
178+ cp . spawnSync ( `git` , [ `commit` , `-m` , `"original sources"` , `--no-gpg-sign` ] , {
179+ cwd : destPath
180+ } ) ;
181+
182+ // copy files from esm
183+ for ( const file of files ) {
184+ const srcFilePath = path . join ( __dirname , '../out-editor-esm' , file ) ;
185+ const dstFilePath = path . join ( destPath , file ) ;
186+ if ( fs . existsSync ( srcFilePath ) ) {
187+ util . ensureDir ( path . dirname ( dstFilePath ) ) ;
188+ const contents = fs . readFileSync ( srcFilePath ) . toString ( ) . replace ( / \r \n | \r | \n / g, '\n' ) ;
189+ fs . writeFileSync ( dstFilePath , contents ) ;
190+ }
191+ }
192+
193+ console . log ( `Open in VS Code the folder at '${ destPath } ' and you can alayze the compilation error` ) ;
194+ throw new Error ( 'Standalone Editor compilation failed. If this is the build machine, simply launch `yarn run gulp editor-distro` on your machine to further analyze the compilation problem.' ) ;
195+ } ) ;
153196 }
154197} ) ;
155198
0 commit comments