Menu

#2867 Migrate workbox-build to TypeScript

closed
nobody
None
2021-07-17
2021-06-15
Anonymous
No

Originally created by: jeffposnick

R: @tropicadri

Fixes [#2806], fixes [#2477]

There's obviously a lot going on in this PR. Sorry!

At a high level, this migrates workbox-build to TypeScript. (Following this PR, only workbox-webpack-plugin and workbox-sw are written in JavaScript.)

The goal was to preserve functionality during this migration, and not require a major semver bump. The biggest change under the hood is swapping out @hapi/joi option validation for a two-part system that generates JSON schema based on our TypeScript definitions at build time, and then uses https://ajv.js.org/ to validate at runtime against that schema. @hapi/joi is a bit more sophisticated in terms of complex runtime validation (e.g. ensuring that if one option is set, another option needs to also be set, making options mutually exclusive, etc.) so some of those relationships needed to be expressed at runtime via custom functions, meaning that the generated JSON schema are not 100% the source of truth.

Many of the test changes across all the packages reflect the fact that validation now throws slightly different errors due to the above mentioned change.

There are other small changes sprinkled throughout this PR as well, based on things that I found necessary while working with the additional TypeScript code. Please flag anything that looks amiss!

Related

Tickets: #2477
Tickets: #2806
Tickets: #2865

Discussion

  • Anonymous

    Anonymous - 2021-06-16

    Originally posted by: jeffposnick

    Thanks! Regarding the linting errors, I'm not going to be able to resolve the three instances of Parsing error: Cannot read property 'map' of undefined in this PR. As per https://stackoverflow.com/a/64626605/385997, we're going to have to upgrade our TypeScript eslint dependencies to resolve them, and that's a larger effort being done in the other PR that you're working on.

    The other errors should be resolved now, though.

     
  • Anonymous

    Anonymous - 2021-06-17

    Ticket changed by: jeffposnick

    • status: open --> closed
     

Log in to post a comment.