-
Notifications
You must be signed in to change notification settings - Fork 12k
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
TypeError: Cannot read property 'then' of undefined
when used with serviceworker-webpack-plugin
#7615
Comments
Within the original Typescript code, looks like the non-null assertion operator was used, which masks this issue:
|
Branch with the proposed fix -- https://github.com/rezonant/angular-cli/tree/fix-7615 |
@rezonant would you be interested in submitting this fix as a PR? |
No problem. I used a forked patch build with my fix in my work yesterday and it looks to be working correctly. |
Check if this.done is defined before delaying file access
Can you provide an excerpt of your webpack config showing the service worker plugin? Also, is the service worker plugin defined before or after the AOT plugin? The service worker plugin uses a child compilation (which is where the failure is occurring) so verifying that there are not more systemic issues at play may be prudent. |
Ah, interesting. Moving the service worker plugin below the AotPlugin instance appears to resolve the issue as well. So perhaps this is because AotPlugin has not initialized Here is the plugin instantiation I'm using:
|
Check if this.done is defined before delaying file access
Check if this.done is defined before delaying file access
Check if this.done is defined before delaying file access
Check if this.done is defined before delaying file access
Check if this.done is defined before delaying file access
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
@ngtools/webpack 1.6.2
Description
When using serviceworker-webpack-plugin,
@ngtools/webpack
tries to call done.then() on itsafter-resolvers
step, butdone
isundefined
. Crashing code is:Furthermore, this code will run (and crash) even if the
@ngtools/webpack
loader definition is set to exclude the service worker TS files.It appears that the fix may be to check if
this.done
is defined before delayingcb
, otherwise just runcb()
as if the file was not a.ts
, but I'm not well versed with the@ngtools/webpack
codebase. I can provide a PR if necessary.Repro steps.
Create a webpack project which uses
@ngtools/webpack
as its Typescript compiler, include serviceworker-webpack-plugin, point that plugin at a.ts
file.The log given by the failure.
A change was made locally to serviceworker-webpack-plugin to output the exception that it caught:
The text was updated successfully, but these errors were encountered: