Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prod build generates empty urls and patterns in ngsw.json for Angular Service Worker #10297

Closed
webmaxru opened this issue Apr 12, 2018 · 4 comments
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@webmaxru
Copy link
Member

Versions

Angular CLI: 6.0.0-rc.3
Node: 9.11.1
OS: darwin x64
Angular: 6.0.0-rc.3
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Repro steps

ng new testApp2
ng add @angular/pwa --project=testApp2
npm i @angular/service-worker@next --save (to workaround angular/devkit#679 )
ng build --prod

Observed behavior

resulting ngsw.json

{
  "configVersion": 1,
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "updateMode": "prefetch",
      "urls": [],
      "patterns": []
    },
    {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "urls": [],
      "patterns": []
    }
  ],
  "dataGroups": [],
  "hashTable": {}
}

Desired behavior

urls and patterns should be populated by the entries reflecting the assets in dist/testApp2

Mention any other details that might be useful (optional)

This might be connected to the new folder structure - maybe NGSW CLI is still looking for the files in dist folder instead of dist/[projectName]

CC: @Brocco @alxhub

@filipesilva filipesilva added this to the v6.0.0 milestone Apr 12, 2018
@hansl hansl added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Apr 12, 2018
@gkalpak
Copy link
Member

gkalpak commented Apr 13, 2018

There are several problems afaict:

  1. The filesystem passed to the Generator here, has outputPath as base. This means that it will list file inside dist/<app-name>/, but the Generator is actually interested in files inside src/.
    EDIT: As @filipesilva pointed out elsewhere, this makes no sense. The current behavior is fine. No idea what I was thinking 😇

  2. virtualFs.Host will list files without the leading /, while the Generator (which requests all files here) will try to match the names to globs starting with /.

  3. The Generator expects that ALL files will be listed here (unlike how ls and virtualFs.Host work). virtualFs.Host will instead only contain the names of directories, not their deeply nested files.

@hansl
Copy link
Contributor

hansl commented Apr 13, 2018

About point #2; list() is meant to list a directory (think readdir), so no slashes should be involved (as these are file names, not paths).

It seems like #3 is simply not understanding the contracts between the two interfaces. I'm curious how it passes our tests (which means we need to improve coverage).

Seems easy to fix if that's the issue. Whoever fixes this should also include a test that fails before the fix and succeeds after.

@filipesilva
Copy link
Contributor

Have a PR for this in angular/devkit#709.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

4 participants