@@ -9,7 +9,12 @@ const writeFile = require('broccoli-file-creator');
99const replace = require ( 'broccoli-string-replace' ) ;
1010const Funnel = require ( 'broccoli-funnel' ) ;
1111const packageJson = require ( './package.json' ) ;
12- const { map, mv } = stew ;
12+ const { mv } = stew ;
13+
14+ const {
15+ EMBER_VERSIONS_SUPPORTED ,
16+ PREVIOUS_EMBER_VERSIONS_SUPPORTED ,
17+ } = require ( 'ember-debug/versions' ) ;
1318
1419const options = {
1520 autoImport : {
@@ -84,95 +89,30 @@ module.exports = function (defaults) {
8489 app . import ( 'node_modules/compare-versions/index.js' ) ;
8590 app . import ( 'node_modules/normalize.css/normalize.css' ) ;
8691
87- let emberDebug = 'ember_debug/dist' ;
88-
89- emberDebug = new Funnel ( emberDebug , {
90- destDir : 'ember-debug' ,
91- include : [ '**/*.js' ] ,
92- } ) ;
93-
94- const previousEmberVersionsSupportedString = `[${ packageJson . previousEmberVersionsSupported
95- . map ( function ( item ) {
96- return `'${ item } '` ;
97- } )
98- . join ( ',' ) } ]`;
99- const emberVersionsSupportedString = `[${ packageJson . emberVersionsSupported
100- . map ( function ( item ) {
101- return `'${ item } '` ;
102- } )
103- . join ( ',' ) } ]`;
104-
105- let startupWrapper = new Funnel ( 'ember_debug' , {
106- srcDir : 'vendor' ,
107- files : [ 'startup-wrapper.js' ] ,
108- } ) ;
109-
110- startupWrapper = replace ( startupWrapper , {
111- files : [ 'startup-wrapper.js' ] ,
112- patterns : [
113- {
114- match : / { { EMBER_ V E R S I O N S _ S U P P O R T E D } } / ,
115- replacement : emberVersionsSupportedString ,
116- } ,
117- ] ,
118- } ) ;
119-
120- const loader = new Funnel ( 'ember_debug' , {
121- srcDir : 'vendor' ,
122- files : [ 'loader.js' ] ,
123- } ) ;
124-
125- emberDebug = mergeTrees ( [ startupWrapper , emberDebug , loader ] ) ;
126-
127- emberDebug = concatFiles ( emberDebug , {
128- headerFiles : [ 'loader.js' ] ,
129- inputFiles : [ '**/*.js' ] ,
130- outputFile : '/ember_debug.js' ,
131- sourceMapConfig : { enabled : false } ,
132- } ) ;
133-
134- function wrapWithLoader ( content ) {
135- return `(function loadEmberDebugInWebpage() {
136- const waitForEmberLoad = new Promise((resolve) => {
137- if (window.requireModule) {
138- const has =
139- window.requireModule.has ||
140- function has(id) {
141- return !!(
142- window.requireModule.entries[id] ||
143- window.requireModule.entries[id + '/index']
144- );
145- };
146- if (has('ember')) {
147- return resolve();
148- }
149- }
150-
151- /**
152- * NOTE: if the above (for some reason) fails and the consuming app has
153- * deprecation-workflow's throwOnUnhandled: true
154- * or set \`ember-global\`'s handler to 'throw'
155- * and is using at least \`[email protected] \` 156- *
157- * this will throw an exception in the consuming project
158- */
159- if (window.Ember) return resolve();
160-
161- window.addEventListener('Ember', resolve, { once: true });
162- });
163- waitForEmberLoad.then(() => ${ content } );
164- })()
165- ` ;
166- }
92+ const previousEmberVersionsSupportedString = JSON . stringify (
93+ PREVIOUS_EMBER_VERSIONS_SUPPORTED ,
94+ ) ;
95+ const emberVersionsSupportedString = JSON . stringify ( EMBER_VERSIONS_SUPPORTED ) ;
16796
16897 const emberDebugs = [ ] ;
98+
16999 [ 'basic' , 'chrome' , 'firefox' , 'bookmarklet' , 'websocket' ] . forEach (
170100 function ( dist ) {
171- emberDebugs [ dist ] = map ( emberDebug , '**/*.js' , function ( content ) {
172- return wrapWithLoader (
173- `(function(adapter) {\n${ content } \n}('${ dist } '))` ,
174- ) ;
175- } ) ;
101+ let emberDebug = 'ember_debug/dist' ;
102+
103+ let entryPoint = concatFiles (
104+ new Funnel ( emberDebug , {
105+ destDir : 'ember-debug' ,
106+ include : [ `${ dist } -debug.js` ] ,
107+ } ) ,
108+ {
109+ inputFiles : [ '**/*.js' ] ,
110+ outputFile : '/ember_debug.js' ,
111+ sourceMapConfig : { enabled : false } ,
112+ } ,
113+ ) ;
114+
115+ emberDebugs [ dist ] = mergeTrees ( [ emberDebug , entryPoint ] ) ;
176116 } ,
177117 ) ;
178118
@@ -190,10 +130,7 @@ module.exports = function (defaults) {
190130 patterns : emberInspectorVersionPattern ,
191131 } ) ;
192132
193- const minimumVersion = packageJson . emberVersionsSupported [ 0 ] . replace (
194- / \. / g,
195- '-' ,
196- ) ;
133+ const minimumVersion = EMBER_VERSIONS_SUPPORTED [ 0 ] . replace ( / \. / g, '-' ) ;
197134 const webExtensionRoot = `panes-${ minimumVersion } ` ;
198135
199136 let tabLabel ;
@@ -264,7 +201,7 @@ module.exports = function (defaults) {
264201 skeletonBookmarklet ,
265202 ] ) ;
266203
267- packageJson . previousEmberVersionsSupported . forEach ( function ( version ) {
204+ PREVIOUS_EMBER_VERSIONS_SUPPORTED . forEach ( function ( version ) {
268205 version = version . replace ( / \. / g, '-' ) ;
269206 if ( env === 'production' ) {
270207 const prevDist = `dist_prev/${ env } ` ;
0 commit comments