You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('AoT + genDir', function() {
var resourcePath = 'src/app/my-module/my-module.routes.ts';
var modulePath = '../groups/inventory/index#InventoryModule';
beforeEach(function () {
query = '?aot=true&genDir=compiled/src/app'
});
it('should return a loadChildren async require statement', function() {
var result = [
'loadChildren: () => new Promise(function (resolve) {',
' (require as any).ensure([], function (require: any) {',
' resolve(require(\'../../../compiled/src/app/groups/inventory/index.ngfactory\')[\'InventoryModuleNgFactory\']);',
' });',
'})'
];
var loadedString = loader.call({
resourcePath: resourcePath,
query: query
}, `loadChildren: '${modulePath}'`);
checkResult(loadedString, result);
});
});
Basically the whole resolving logic is not current.
The Wiki says, if "genDir": "src/compiled" then 'angular-router-loader?aot=true&genDir=src/compiled/src/app' which makes no sense... why adding the addition app?
The genDir in the query should point to the genDir defined in tsconfig.json but relative to the root, which is genDir=src/compiled
Basically if tsconfig is in the app root both genDir values are identical
Even with this change it's still not working...
The unit tests for AOT are all wrong
All unit tests expect
var resourcePath = 'path/to/routes.ts';
var modulePath = './path/to/file.module#FileModule';
With query ?aot=true&genDir=.
To resolve this path ../../path/to/file.module.ngfactory
Which is incorrect (and confusing)
The actual resolved path should be ./path/to/file.module.ngfactory
Why?
Because genDir=. is the same as no genDir or empty string.
If you set genDir: "." in tsconfig it's like setting "" or not setting genDir at all, i.e: emit compiled files in the source tree.
The tests assume emit source file in the root of the project which is a non valid scenario.
And again, my supplied unit test provides a scenario that the loader can't handle.
I will post a PR soon with a refactor for the relative module path resolution when using AOT.
This is not a breaking change but it will be for some projects since they are setting an invalid value in the genDir query parameter.
The text was updated successfully, but these errors were encountered:
shlomiassaf
pushed a commit
to shlomiassaf/angular-router-loader
that referenced
this issue
Dec 30, 2016
Just run this test:
Basically the whole resolving logic is not current.
The Wiki says, if
"genDir": "src/compiled"
then'angular-router-loader?aot=true&genDir=src/compiled/src/app'
which makes no sense... why adding the additionapp
?The genDir in the query should point to the genDir defined in
tsconfig.json
but relative to the root, which isgenDir=src/compiled
Even with this change it's still not working...
The unit tests for AOT are all wrong
All unit tests expect
With query
?aot=true&genDir=.
To resolve this path
../../path/to/file.module.ngfactory
Which is incorrect (and confusing)
The actual resolved path should be
./path/to/file.module.ngfactory
Why?
Because
genDir=.
is the same as no genDir or empty string.If you set
genDir: "."
in tsconfig it's like setting "" or not setting genDir at all, i.e: emit compiled files in the source tree.The tests assume emit source file in the root of the project which is a non valid scenario.
And again, my supplied unit test provides a scenario that the loader can't handle.
I will post a PR soon with a refactor for the relative module path resolution when using AOT.
This is not a breaking change but it will be for some projects since they are setting an invalid value in the genDir query parameter.
The text was updated successfully, but these errors were encountered: