Skip to content

stop using gulp for closure compiler tasks #10305

Description

@maribethb

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

We are using gulp to invoke closure-compiler and do some other tasks related to building, like renaming some files. However, this has a few problems:

  1. gulp is barely maintained
  2. our gulp scripts are difficult to reason about/modify
  3. nx may or may not actually be cacheing the build output correctly or efficiently
  4. the google-closure-compiler gulp plugin we're using is updated frequently but doesn't seem to be officially supported by google, and nobody can answer questions about it apparently. it also breaks every ~month or so requiring us to update to the newest version which has no appreciable new features or value to us other than unborking CI. unfortunately this may or may not be solved by this move because it's the same npm package we'd be using, but we'd switch to the plain node implementation instead of the gulp plugin.
    We can remove gulp from the build_tasks with the following replacements:
  • a bunch of functions that are already async or just doing some work and calling gulp's done at the end: just regular functions, stay the same / drop the done callback
  • stripApacheLicense: currently using gulp-replace stream that modifies the files in-stream so this intermediate step isn't written anywhere. we can modify the tsc output in place instead (and write to disk)
    • note that we currently call this on the advanced_compilation_test's source files, but we don't need to because who cares if those test files still have the apache header instead of 4 newlines? so it's okay for this to move out of the current place and just act on the tsc outputs instead of everything that's passed to cc.
  • compile uses the google-closure-compiler gulp plugin. instead, we can just use the native node API. we may need to add our own error handling to make a closure compiler exit the script with error, instead of relying on the gulp plugin to cause a stream error.
  • gulp-sourcemaps plugin: remove and just pass the sourcemap flags to closure compiler directly.
  • buildCompiled is the complicated step. it currently has 6 stages:
    1. stripApacheLicense: discussed above, rewrite in place
    2. sourcemaps.init(): discussed above, just drop this
    3. compile: discussed above
    4. rename to add _compressed to filenames: just rename the files on disk afterwards, then update the names in the sourcemaps after they're generated
    5. sourcemaps.write: discussed above, handled by passing the --create-source-map flag to cc. since this would be generated in step 3 now, need to handle renaming the files to compressed in the sourcemaps as well.
    6. gulp.dest is where all of this is finally written to disk, instead we'd be doing it as we go
  • advancedCompilationTest: similar to the steps above, but no need to strip the license and not sure if we need to generate source maps or not?

To verify this work is correct we should do a diff of the build output including the sourcemaps to make sure they're identical.

Reproduction steps

Priority

No response

Stack trace

Screenshots

No response

Browsers

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions