@@ -124,8 +124,13 @@ module.exports = class Extension {
124124 }
125125
126126 isInstalled ( ) {
127- const indexScript = this . __getScriptFile ( 'index' )
128- return ! ! indexScript
127+ try {
128+ this . __getScriptFile ( 'index' )
129+ }
130+ catch ( e ) {
131+ return false
132+ }
133+ return true
129134 }
130135
131136 async install ( skipPkgInstall ) {
@@ -293,33 +298,42 @@ module.exports = class Extension {
293298 )
294299 }
295300
301+ /**
302+ * Returns the file absolute path. If the file cannot be found into the default 'src' folder,
303+ * searches it into the `dist` folder.
304+ *
305+ * This allows to use preprocessors (eg. TypeScript) for all AE files (even index, install and other Quasar-specific scripts)
306+ * as long as the corresponding file isn't available into the `src` folder, making the feature opt-in
307+ */
296308 __getScriptFile ( scriptName ) {
297309 let script
298310
299311 try {
300- script = require . resolve ( this . packageName + '/dist/' + scriptName , {
312+ script = require . resolve ( ` ${ this . packageName } /src/ ${ scriptName } ` , {
301313 paths : [ appPaths . appDir ]
302314 } )
303315 }
304316 catch ( e ) {
305- try {
306- script = require . resolve ( this . packageName + '/src/' + scriptName , {
307- paths : [ appPaths . appDir ]
308- } )
309- }
310- catch ( e ) {
311- return
312- }
317+ script = require . resolve ( `${ this . packageName } /dist/${ scriptName } ` , {
318+ paths : [ appPaths . appDir ]
319+ } )
313320 }
314321
315322 return script
316323 }
317324
318325 __getScript ( scriptName , fatalError ) {
319- const script = this . __getScriptFile ( scriptName )
326+ let script
327+
328+ try {
329+ script = this . __getScriptFile ( scriptName )
330+ }
331+ catch ( e ) {
332+ if ( fatalError ) {
333+ fatal ( `App Extension "${ this . extId } " has missing ${ scriptName } script...` )
334+ }
320335
321- if ( fatalError && ! script ) {
322- fatal ( `App Extension "${ this . extId } " has missing ${ scriptName } script...` )
336+ return
323337 }
324338
325339 return require ( script )
0 commit comments