File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
packages/app/src/sandbox/eval Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -273,12 +273,13 @@ export default class Manager {
273273 * Will transpile this module and all eventual children (requires) that go with it
274274 * @param {* } entry
275275 */
276- async transpileModules ( entry : Module , isEntry : boolean = true ) {
276+ async transpileModules ( entry : Module , isTestFile : boolean = false ) {
277277 this . hmrStatus = 'check' ;
278278 this . setEnvironmentVariables ( ) ;
279279 const transpiledModule = this . getTranspiledModule ( entry ) ;
280280
281- transpiledModule . setIsEntry ( isEntry ) ;
281+ transpiledModule . setIsEntry ( true ) ;
282+ transpiledModule . setIsTestFile ( isTestFile ) ;
282283
283284 const result = await transpiledModule . transpile ( this ) ;
284285 this . getTranspiledModules ( ) . forEach ( t => t . postTranspile ( this ) ) ;
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ export default class TestRunner {
9090
9191 async transpileTests ( ) {
9292 for ( let t of this . tests ) {
93- await this . manager . transpileModules ( t , false ) ;
93+ await this . manager . transpileModules ( t , true ) ;
9494 }
9595 }
9696
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ export default class TranspiledModule {
125125 // Unique identifier
126126 hash: string ;
127127
128+ isTestFile: boolean = false ;
129+
128130 /**
129131 * Set how this module handles HMR. The default is undefined, which means
130132 * that we handle the HMR like CodeSandbox does.
@@ -189,6 +191,7 @@ export default class TranspiledModule {
189191 this . resetTranspilation ( ) ;
190192
191193 this . setIsEntry ( false ) ;
194+ this . setIsTestFile ( false ) ;
192195 }
193196
194197 resetTranspilation ( ) {
@@ -389,6 +392,15 @@ export default class TranspiledModule {
389392 this . isEntry = isEntry ;
390393 }
391394
395+ /**
396+ * Mark if this is a test file. If this is a test file we know that we don't
397+ * need to do any refresh or fixing when an error is thrown by the module. It's
398+ * not a vital module after all.
399+ */
400+ setIsTestFile ( isTestFile : boolean ) {
401+ this . isTestFile = isTestFile ;
402+ }
403+
392404 /**
393405 * Transpile the module, it takes in all loaders from the default loaders +
394406 * query string and passes the result from loader to loader. During transpilation
@@ -542,7 +554,7 @@ export default class TranspiledModule {
542554 if ( ! this . compilation ) {
543555 const shouldReloadPage = this . hmrConfig
544556 ? this . hmrConfig . isDeclined ( this . isEntry )
545- : this . isEntry ;
557+ : this . isEntry && ! this . isTestFile ;
546558
547559 if ( shouldReloadPage ) {
548560 location . reload ( ) ;
You can’t perform that action at this time.
0 commit comments