Repository navigation
chore: pull build and test-compile-advanced task out of gulp - #10546
Conversation
| const source = await readFile(filePath, 'utf8'); | ||
| // Strip out Google's and MIT's Apache licences. | ||
| // Closure Compiler preserves dozens of Apache licences in the Blockly code. | ||
| // Remove these if they belong to Google or MIT. |
There was a problem hiding this comment.
Or RPF (I think the regex was already updated to do this, but you can doublecheck)
| 'visibility', | ||
| ]; | ||
|
|
||
| var languages = null; |
There was a problem hiding this comment.
this should be a let, no reason to use var anymore, right?
| export const buildAdvancedCompilationTest = gulp.series( | ||
| compileAdvancedCompilationTest, | ||
| ); | ||
| build(); |
There was a problem hiding this comment.
test_compile_advanced imports the compile function from this file, and because of this line it would then kick off a build, but the adv compile test already does its own build too which is going to be running at the same time this one is. and since this modifies files on disk that is going to be problematic.
the easiest solution is probably moving compile and anything else that's imported from a different file to its own module with no side effects, and then this line needs a top-level await so that any following scripts actually wait for the build to complete
| * This will normalize the command across platforms (e.g. python3 on Linux and | ||
| * Mac, python on Windows). | ||
| */ | ||
| const PYTHON = process.platform === 'win32' ? 'python' : 'python3'; |
There was a problem hiding this comment.
this is already in build_constants, we should just import it from there.
| ); | ||
| } | ||
|
|
||
| compileAdvancedCompilationTest(); No newline at end of file |
There was a problem hiding this comment.
i think this might need an await, to make sure it finishes before the next thing happens. same for build. it would match the pattern we have in clean.mjs
| "build-strict": "gulp build --verbose --strict", | ||
| "build-strict-log": "npm run build:strict > build-debug.log 2>&1 && tail -3 build-debug.log", | ||
| "build": "npm run tsc && node \"scripts/build.mjs\" && npm run langfiles", | ||
| "build-debug": "npm run build --verbose --debug", |
There was a problem hiding this comment.
I think these flags are being passed to npm now, not all the way through to the build script. and you can't just add another layer of -- because then they'd be passed to npm run langfiles since that's the last command in the npm run build sequence. so I think this needs to be rethought a little bit. same for below.
There was a problem hiding this comment.
though npm run langfiles in the build command seems redundant since you're already running that as part of the build script
There was a problem hiding this comment.
this one can probably be removed now, right. and maybe some of the others
| "lint": "eslint .", | ||
| "lint-fix": "eslint . --fix", | ||
| "langfiles": "node \"scripts/langfiles.mjs\"", | ||
| "minify": "gulp minify", |
There was a problem hiding this comment.
the nx file still references this
There was a problem hiding this comment.
also i ran prepareDemos locally and the _deploy isn't gitignored so it creates noise. need to add packages/blockly/_deploy to the gitignore
you can run this locally to check to make sure the paths are all correct with:
npm run prepareDemos
npx http-server _deploy -p 8081
| create_source_map: mapPath, | ||
| }; | ||
|
|
||
| await compile(options); |
There was a problem hiding this comment.
So we're passing the --debug flag when we actually call this script, but I don't see anywhere you're parsing it. I think you need to use yargs and forward argv onto compile(options, argv) which is what the build script does. otherwise adv compilation test will no longer run with the extra debug args.
There was a problem hiding this comment.
is this the right path still?
| /** | ||
| * Build all chunks, compressed files, sourcemaps, shims, and langfiles. | ||
| * | ||
| * Prerequisite: tsc (handled by nx). |
There was a problem hiding this comment.
this says tsc is a prereq handled by nx, but the npm script starts with npm run tsc && so it seems like we're handling it manually, maybe? also for the adv compilation test
| '../../node_modules/@blockly/theme-modern/dist/index.js', | ||
| '../../node_modules/@blockly/block-test/dist/index.js', | ||
| ]; | ||
| return gulp.src(playgroundDeps, {base: '.'}).pipe(gulp.dest(demoStaticTmpDir)); |
There was a problem hiding this comment.
I think this needs to be:
return gulp.src(playgroundDeps, {base: '../..'}).pipe(gulp.dest(`${demoStaticTmpDir}/packages/blockly`));
running the current version puts these files in e.g. packages/blockly/node_modules/@blockly/dev-tools/dist/index.js where the advanced playground is looking for them in _deploy/static/packages/blockly/node_modules/@blockly/dev-tools/dist/index.js
There was a problem hiding this comment.
this needs a similar fix as to the playground deps:
return gulp.src(['build/msg/*', 'dist/*_compressed.js*', 'build/*.loader.mjs'], {base: '.'})
.pipe(gulp.dest(`${demoStaticTmpDir}/packages/blockly`));
| function copyCompressedToOldLocation(done) { | ||
| return gulp.src(['dist/*_compressed.js*']) | ||
| .pipe(gulp.dest(demoStaticTmpDir)); | ||
| .pipe(gulp.dest(demoStaticBlocklyDir)); |
There was a problem hiding this comment.
this and the one below it don't need to change, this function was explicitly copying the files to the top level demo static directory, for legacy reasons. these files are already copied to domeStaticBlocklyDir by copyBuilt so this would be redundant. everything else lgtm!
The basics
The details
Resolves
Moves the build and test-compile-advanced tasks off of gulp and into node-based scripts.
Proposed Changes
scripts/gulpfiles/build_tasks.mjsscripts/build.mjsandtests/compile/test_compile_advanced.mjsADVANCED_OPTIMIZATIONS. As this is only a test and the test is passing as expected, we don't need to be concerned about this change.Reason for Changes
Removing dependency on gulp
Test Coverage
I validated these changes by doing the following:
/distfolder after gulp version of the build command and after the new node commanddevtool: isProduction ? 'source-map' : 'eval-source-map',todevtool: 'source-map')npm ci,npm run build,npm run test,npm run lint, andnpm run formatin addition to running each test script individually and running each changed script individually to ensure they work consistently and as expected.Additional Information
AI was used to build out the function that calls the google-closure-compiler to make the output identical to the old gulp output to give us high confidence in the output. It was also used to help debug some issues encountered during testing. All changes were verified by a human and thoroughly vetted against the gulp version of the output of these tasks.