Skip to content

Subresource Integrity for lazy modules is broken when DL is enabled #15468

Closed
@alan-agius4

Description

@alan-agius4

🐞 Bug report

Command (mark with an x)

- [ ] new
- [X] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, this is caused by the downleveling process.

Description

🔬 Minimal Reproduction

ng new lazy-loading-dl --routing
cd lazy-loading-dl
ng g m foo --module app.module --route foo

Add the below in app.component.html

<a [routerLink]="['/foo']" >
  link to foo
</a>
ng build --prod --subresourceIntegrity
http-server dist/lazy-loading-dl

Open browser and click on the link

🔥 Exception or Error


127.0.0.1/:1 Failed to find a valid digest in the 'integrity' attribute for resource 'http://127.0.0.1:8080/5-es2015.0914cd2e5d35cddfa66f.js' with computed SHA-256 integrity '9yuul7bmARNSj/M5wygxgYjfklmwN0bTD+8YGHdn5/I='. The resource has been blocked.
main-es2015.8ce6a89e85cdffc26eb1.js:1 ERROR Error: Uncaught (in promise): ChunkLoadError: Loading chunk 5 failed.
(error: http://127.0.0.1:8080/5-es2015.0914cd2e5d35cddfa66f.js)
ChunkLoadError: Loading chunk 5 failed.
(error: http://127.0.0.1:8080/5-es2015.0914cd2e5d35cddfa66f.js)
    at Function.u.e (runtime-es2015.6b58afc9912521e9b6e5.js:1)
    at w (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at Rn.loadModuleFactory (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at Rn.load (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at c.project (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at c._tryNext (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at c._next (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at c.next (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at e._subscribe (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at e._trySubscribe (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at P (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at P (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at polyfills-es2015.fd917e7c3ed57f282ee5.js:1
    at a.invokeTask (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at Object.onInvokeTask (main-es2015.8ce6a89e85cdffc26eb1.js:1)
    at a.invokeTask (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at s.runTask (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at _ (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at c.invokeTask [as invoke] (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)
    at y (polyfills-es2015.fd917e7c3ed57f282ee5.js:1)

🌍 Your Environment


Angular CLI: 8.3.0
Node: 10.10.0
OS: win32 x64
Angular: 8.2.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.0
@angular-devkit/build-angular     0.803.0
@angular-devkit/build-optimizer   0.803.0
@angular-devkit/build-webpack     0.803.0
@angular-devkit/core              8.3.0
@angular-devkit/schematics        8.3.0
@angular/cli                      8.3.0
@ngtools/webpack                  8.3.0
@schematics/angular               8.3.0
@schematics/update                0.803.0
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions