Search code examples
extjsautoloader

ExtJS 6 view autoloader issue


ExtJS 6.5.0: in application it's used

appFolder: '/app/document/app'

But it looks like not workable for views:

>> Ext.Loader.getPath('Document');
/app/document/app

>> Ext.Loader.getPath('Document.view.main.Main');
classic/src/view/main/Main.js
{OR} modern/src/view/main/Main.js
// Expected:
// /app/document/app/classic/src/view/main/Main.js
// OR /app/document/app/modern/src/view/main/Main.js

>> Ext.Loader.getPath('Document.main.Main');
/app/document/app/main/Main.js

Could anyone suggest a solution for that?


Steps to reproduce the issue:

sencha generate workspace ./
sencha framework add ~/extjs/6.5.0 ext
sencha -sdk ext generate app Document ./app/document

nano ./app/document/app.js
> + appFolder: '/app/documents/app',

Move index file two folders up... open console and check commands from the top.


P.S. I've made a hack in Ext.beforeLoad to resolve it, but I need a solution directly "out of the box"


Solution

  • Here is an approach from https://www.sencha.com/forum/showthread.php?269448-Cmd-3-1-2-Ext-Loader-path-prefix :

    To dynamically load the assets from other than the page-location's context, without using the base tag I think one really does have to mess with the loader configuration. Something like:

    Code:

    Ext.Loader.setPath({
        "Ext":              "http://path/ext/src",
        "MyApp":            "http://path/app",
        "MyApp.model":      "http://path/app/model",
        "MyApp.view":       "http://path/app/view",
        "MyApp.controller": "http://path/app/controller",
        "MyApp.store":      "http://path/app/store",
        "MyApp.extras":     "http://path/app/extras"
    

    });

    The namespace needs to be "over-specified" because Ext.application will trash the autoloader's MyApp path by overriding it with the value of MyApp.appFolder (which is really not supposed to be an absolute path; even Architect won't allow you to set one.)