@@ -26,14 +26,15 @@ module.exports = {
2626
2727 included ( ) {
2828 this . _super . included . apply ( this , arguments ) ;
29- const env = this . parent ?. app ?. env ?? 'production' ;
29+ const includeMirage = this . _includeMirageInBuild ( ) ;
3030
3131 // these are dependencies used our mirage code within the
3232 // api addon and should not be included in production builds,
3333 // after this addon has been migrated to a v2 addon this can
3434 // be removed as the addon's dependencies will be statically
3535 // analyzable
36- if ( env === 'production' ) {
36+ if ( ! includeMirage ) {
37+ // exclude mirage and dependencies from this addon that are used by mirage
3738 this . options . autoImport . exclude . push (
3839 'miragejs' ,
3940 'sinon' ,
@@ -44,16 +45,15 @@ module.exports = {
4445 } ,
4546
4647 treeForAddon ( ) {
47- const env = this . parent ?. app ?. env ?? 'production' ;
48+ const includeMirage = this . _includeMirageInBuild ;
4849
4950 // Exclude anything in the workers folder from being bundled in the final
5051 // build as we're manually bundling the files ourselves below.
5152 const tree = this . _super . treeForAddon . apply ( this , arguments ) ;
5253 return funnel ( tree , {
53- exclude : [
54- 'api/workers/**/*' ,
55- env === 'production' && 'api/mirage/**/*' ,
56- ] . filter ( Boolean ) ,
54+ exclude : [ 'api/workers/**/*' , ! includeMirage && 'api/mirage/**/*' ] . filter (
55+ Boolean ,
56+ ) ,
5757 } ) ;
5858 } ,
5959
@@ -94,4 +94,10 @@ module.exports = {
9494
9595 return merge ( trees ) ;
9696 } ,
97+
98+ _includeMirageInBuild ( ) {
99+ const env = this . parent . app ?. env ?? 'production' ;
100+ const config = this . project . config ( env ) ;
101+ return config . mirage . enabled || env !== 'production' ;
102+ } ,
97103} ;
0 commit comments