chore: degulpify the package tasks - #10323
Conversation
|
traced the failures to a goof that happened when i deleted the package-lock to deal with the npm bug. fixed in #10378 will rebase when that's merged and fix the package-lock again but correctly this time |
a920f67 to
0ea8014
Compare
| */ | ||
| async function typings(buildFlags) { | ||
| await clean(); | ||
| await runGulpTask('tsc', buildFlags); |
There was a problem hiding this comment.
The tsc gulp task looks to be two shell commands and takes no flags. Probably just inline it here and drop the buildFlags arg from this method?
There was a problem hiding this comment.
AFAICT, this method is used only to invoke the tsc, cleanBuildDir, and build Gulp tasks. The first two are effectively one-liner shell commands, and the latter could be npm run build – maybe just do that and remove this file entirely?
There was a problem hiding this comment.
This file feels like too much faffing about for one little rm – can it be inlined or consolidated into another file?
| * The file is re-read on every call so that callers always see | ||
| * up-to-date data, even if it has been modified (e.g. to bump the | ||
| * version number) since the script started. |
There was a problem hiding this comment.
I'd just drop this, this is the behavior I'd expect by default.
There was a problem hiding this comment.
Removed it, but expecting it by default caused problems for us previously and we had to do the weird cache-busting workaround because subsequent reads would read the cached value. But since this is a totally different way of reading the file, it's probably fine, it's just a footgun that we've hit before.
| /** | ||
| * A dependency to be injected into a UMD module. | ||
| * | ||
| * @typedef {object} UmdDependency | ||
| * @property {string} name Name of the dependency, used as the default | ||
| * for any of the other properties that are omitted. | ||
| * @property {string=} amd Module ID to require in an AMD loader. | ||
| * @property {string=} cjs Module ID to require in a CJS loader. | ||
| * @property {string=} global Property of the global object (minus the | ||
| * leading "root.") to use in a browser. | ||
| * @property {string=} param Name of the factory function parameter the | ||
| * dependency is passed as. | ||
| */ |
There was a problem hiding this comment.
Are these files actually typechecked, and if so can they just be Typescript?
There was a problem hiding this comment.
not by the runtime environment, we'd have to compile the scripts before running them which seems like it would add needless complexity and time to the build. but most IDEs can handle reading the type declarations in comments so they're still useful when writing as your IDE can yell at you even if the running script won't
| * Wrap the given script in a Universal Module Definition, so that it | ||
| * can be loaded by an AMD loader, by a CJS loader, or directly in a | ||
| * browser. | ||
| * | ||
| * This is a replacement for the gulp-umd plugin, supporting just the | ||
| * subset of its template syntax and options that our templates use. |
There was a problem hiding this comment.
"Wrap the given script in a Universal Module Definition." seems adequate here? The bit about it being a replacement I'd definitely drop.
There was a problem hiding this comment.
I think it's useful to know this was yanked directly out of the gulp-umd plugin so that it can be updated or we can look there if we find a bug with this or whatever.
| } | ||
|
|
||
| /** | ||
| * Write a text file, creating its parent directories if needed. |
There was a problem hiding this comment.
This doesn't seem to be limited to text files?
There was a problem hiding this comment.
writeFile will assume it's utf8 encoding since we didn't specify otherwise, so I think it is. i.e. this would not work to write a binary file
| * (and so binary-safe) if it is omitted. | ||
| * @returns {Promise<void>} Promise resolved when copying is complete. | ||
| */ | ||
| export async function copyFiles({from, patterns, to, ignore = [], transform}) { |
There was a problem hiding this comment.
Can these just be regular args vs an options object?
There was a problem hiding this comment.
it could, but I think the call sites are a lot more readable with the names since there's so many params. any particular reason you prefer regular args?
maribethb
left a comment
There was a problem hiding this comment.
Changed a few things:
- moved
cleanReleaseDirinto fs_utils - created
cleanBuildDirthere too instead of using the gulp task for it, and then replaced the gulp task in build_tasks with this script version as well - used
npm run buildandnpm run tscinstead of calling the underlying gulp build task directly - those two things let me remove the run gulp task script
- added a run npm task script instead, the reason for that instead of just using
spawnAsyncdirectly is that windows can't spawn npm commands unless you setshell: trueso this function handles that for you - dropped the build args from the
typingscommand and updated the documentation to more clearly state they only apply topack
| } | ||
|
|
||
| /** | ||
| * Write a text file, creating its parent directories if needed. |
There was a problem hiding this comment.
writeFile will assume it's utf8 encoding since we didn't specify otherwise, so I think it is. i.e. this would not work to write a binary file
| * (and so binary-safe) if it is omitted. | ||
| * @returns {Promise<void>} Promise resolved when copying is complete. | ||
| */ | ||
| export async function copyFiles({from, patterns, to, ignore = [], transform}) { |
There was a problem hiding this comment.
it could, but I think the call sites are a lot more readable with the names since there's so many params. any particular reason you prefer regular args?
| * The file is re-read on every call so that callers always see | ||
| * up-to-date data, even if it has been modified (e.g. to bump the | ||
| * version number) since the script started. |
There was a problem hiding this comment.
Removed it, but expecting it by default caused problems for us previously and we had to do the weird cache-busting workaround because subsequent reads would read the cached value. But since this is a totally different way of reading the file, it's probably fine, it's just a footgun that we've hit before.
| /** | ||
| * A dependency to be injected into a UMD module. | ||
| * | ||
| * @typedef {object} UmdDependency | ||
| * @property {string} name Name of the dependency, used as the default | ||
| * for any of the other properties that are omitted. | ||
| * @property {string=} amd Module ID to require in an AMD loader. | ||
| * @property {string=} cjs Module ID to require in a CJS loader. | ||
| * @property {string=} global Property of the global object (minus the | ||
| * leading "root.") to use in a browser. | ||
| * @property {string=} param Name of the factory function parameter the | ||
| * dependency is passed as. | ||
| */ |
There was a problem hiding this comment.
not by the runtime environment, we'd have to compile the scripts before running them which seems like it would add needless complexity and time to the build. but most IDEs can handle reading the type declarations in comments so they're still useful when writing as your IDE can yell at you even if the running script won't
| * Wrap the given script in a Universal Module Definition, so that it | ||
| * can be loaded by an AMD loader, by a CJS loader, or directly in a | ||
| * browser. | ||
| * | ||
| * This is a replacement for the gulp-umd plugin, supporting just the | ||
| * subset of its template syntax and options that our templates use. |
There was a problem hiding this comment.
I think it's useful to know this was yanked directly out of the gulp-umd plugin so that it can be updated or we can look there if we find a bug with this or whatever.
|
Actually, now we don't need the |
The basics
The details
Resolves
Fixes #10300
Proposed Changes
gulpfiles/package_tasks.jsand replaces it with a function-by-function equivalent that uses plain node scripts instead of gulp tasks.gulpfiles/helper_tasks.jsand replaces it with several different utility files with better-organized helper functions.replaceon the contents of all the msg files to "remove references to goog.module and goog.provide" -- there weren't any of those references present, and that is a bug waiting to happen if a translation ever contains the stringgoogThe biggest addition in this PR is
scripts/package.mjsand if you review that side-by-side with the old (deleted in this PR)gulpfiles/package_tasks.jsit's easier to understand since it really is function-by-function equivalent (with the exception above about the msg files)Reason for Changes
This is faster and easier to read
Test Coverage
Verified that the results of
dist/are identical before and after this change.Documentation
n/a
Additional Information
This change was created with assistance from Claude and manually verified / tested / rewritten where needed