11const cloneDeep = require ( 'lodash.clonedeep' )
22const path = require ( 'path' )
33const webpack = require ( 'webpack' )
4- const log = require ( 'debug' ) ( 'cypress:webpack' )
4+ const debug = require ( 'debug' ) ( 'cypress:webpack' )
55
66const createDeferred = require ( './deferred' )
77
@@ -42,7 +42,7 @@ const defaultOptions = {
4242// on('file:preprocessor', webpack(options))
4343//
4444const preprocessor = ( options = { } ) => {
45- log ( 'user options:' , options )
45+ debug ( 'user options:' , options )
4646
4747 // we return function that accepts the arguments provided by
4848 // the event 'file:preprocessor'
@@ -57,13 +57,13 @@ const preprocessor = (options = {}) => {
5757 // the supported file and spec file to be requested again
5858 return ( file ) => {
5959 const filePath = file . filePath
60- log ( 'get' , filePath )
60+ debug ( 'get' , filePath )
6161
6262 // since this function can get called multiple times with the same
6363 // filePath, we return the cached bundle promise if we already have one
6464 // since we don't want or need to re-initiate webpack for it
6565 if ( bundles [ filePath ] ) {
66- log ( `already have bundle for ${ filePath } ` )
66+ debug ( `already have bundle for ${ filePath } ` )
6767 return bundles [ filePath ]
6868 }
6969
@@ -90,8 +90,8 @@ const preprocessor = (options = {}) => {
9090 } ,
9191 } )
9292
93- log ( `input: ${ filePath } ` )
94- log ( `output: ${ outputPath } ` )
93+ debug ( `input: ${ filePath } ` )
94+ debug ( `output: ${ outputPath } ` )
9595
9696 const compiler = webpack ( webpackOptions )
9797
@@ -108,7 +108,7 @@ const preprocessor = (options = {}) => {
108108 err . filePath = filePath
109109 // backup the original stack before it's potentially modified by bluebird
110110 err . originalStack = err . stack
111- log ( `errored bundling ${ outputPath } ` , err )
111+ debug ( `errored bundling ${ outputPath } ` , err )
112112 latestBundle . reject ( err )
113113 }
114114
@@ -129,11 +129,11 @@ const preprocessor = (options = {}) => {
129129
130130 // these stats are really only useful for debugging
131131 if ( jsonStats . warnings . length > 0 ) {
132- log ( `warnings for ${ outputPath } ` )
133- log ( jsonStats . warnings )
132+ debug ( `warnings for ${ outputPath } ` )
133+ debug ( jsonStats . warnings )
134134 }
135135
136- log ( 'finished bundling' , outputPath )
136+ debug ( 'finished bundling' , outputPath )
137137 // resolve with the outputPath so Cypress knows where to serve
138138 // the file from
139139 latestBundle . resolve ( outputPath )
@@ -143,12 +143,12 @@ const preprocessor = (options = {}) => {
143143 const plugin = { name : 'CypressWebpackPreprocessor' }
144144
145145 const onCompile = ( ) => {
146- log ( 'compile' , filePath )
146+ debug ( 'compile' , filePath )
147147 // we overwrite the latest bundle, so that a new call to this function
148148 // returns a promise that resolves when the bundling is finished
149149 latestBundle = createDeferred ( )
150150 bundles [ filePath ] = latestBundle . promise . tap ( ( ) => {
151- log ( '- compile finished for' , filePath )
151+ debug ( '- compile finished for' , filePath )
152152 // when the bundling is finished, emit 'rerun' to let Cypress
153153 // know to rerun the spec
154154 file . emit ( 'rerun' )
@@ -158,7 +158,7 @@ const preprocessor = (options = {}) => {
158158 // when we should watch, we hook into the 'compile' hook so we know when
159159 // to rerun the tests
160160 if ( file . shouldWatch ) {
161- log ( 'watching' )
161+ debug ( 'watching' )
162162
163163 if ( compiler . hooks ) {
164164 compiler . hooks . compile . tap ( plugin , onCompile )
@@ -172,7 +172,7 @@ const preprocessor = (options = {}) => {
172172 // when the spec or project is closed, we need to clean up the cached
173173 // bundle promise and stop the watcher via `bundler.close()`
174174 file . on ( 'close' , ( ) => {
175- log ( 'close' , filePath )
175+ debug ( 'close' , filePath )
176176 delete bundles [ filePath ]
177177
178178 if ( file . shouldWatch ) {
0 commit comments