Open aerojas opened 7 years ago
Hi @aerojas. The --lazy-root
flag (default value src
) can tell ngu-sw-manifest
which path to use to resolve lazy routes.
To get your templates working correctly, you need to specify moduleId: module.id
alongside the templateUrl
. Then your template URL can be ./app.component.html
as the CLI expects, and ngu-sw-manifest
will be able to resolve the full path.
ngu-sw-manifest
must be run from the root dir of your project (next to node_modules
).
Thank you Alex for your time and making this tool.
I could resolve the issue, it was not so simple though (I'm saying this for the Virtual Machine part, it was a bit extreme solution in my opinion, haha).
Steps I had to follow:
moduleId: module.id
in @Component
for all components of my appimports
section. Some routes started with ./some_folder
(correct), but others started without the period and the slash --> /some_folder/
(incorrect). I don't know if that was my fault or it was written that way by VSCode/some VSCode plugin. Once I fixed this, the issue was solved.ng build --prod
)ngu-sw-manifest
without arguments from root dir of project (one level above node_modules
and src
)ngu-sw-manifest
with the --module
flag. The routes generated correctly this time.I tried to use the --lazy-root
flag but I had no difference in the error generated, even changing the router. Don't take this as evidence though, I used it when there were some errors in the app.
If someone has questions, feel free to ask. I'll try to answer the best I can.
@aerojas thanks for the feedback! I'm not surprised --lazy-root
didn't work if some of your loadChildren
routes were absolute paths, I don't believe the tool supports those.
@aerojas @alxhub
I'm not able to run ngu-sw-manifest
from root directory. Only ./node_modules/.bin/ngu-sw-manifest
works for me.
I'm stuck with ./node_modules/.bin/ngu-sw-manifest --module ./src/app/app.component.ts
step.
Since I have
contains no @NgModules
error
Could you suggest anything? I'm using latest Angular and dependencies. At the moment of this writing it's v.5.2.8
Thanks
+1 having a totally standard app-routing.module.ts 👍
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}
and got the same :
node_modules/ng-pwa-tools/lib/common/ng.js:52
throw new Error(modPath + ' contains no @NgModules');
@jscti
Haven't tried yet but Angular member advised me to use @angular/service-worker
instead. Starting from Angular 5.
Seems like the functionality of ng-pwa-tools is built in
I'm trying to use the --module option in my Angular app, but the following error appears:
It seems the issue has to do with how the tool (or its dependencies) solve the directories:
In my
app.component.ts
file, my templateUrl is./app.component.html
and it works fine when compiling (ng serve
). If I modify it to something like./src/app/app.component.html
it works fine withngu-sw-manifest
, but fails when I do ng serve because it cannot find the .html file. And the problem extends all the components in my app.If I move to
src/
and run../node_modules/.bin/ngu-sw-manifest --module ./app/app.module.ts
I get../node_modules/.bin/ngu-sw-manifest: line 12: node_modules/.bin/ts-node: No such file or directory
Thank you.