feat(tests): Write Closure Compiler output directly to dist/

Since they are already UMD-wrapped, have Closure Compiler write
output chunks directly to RELEASE_DIR, i.e. dist/.
This commit is contained in:
Christopher Allen
2022-10-03 17:29:30 +01:00
parent 16c71659f6
commit 4d150ff8d7
4 changed files with 27 additions and 38 deletions

View File

@@ -25,7 +25,7 @@ var closureDeps = require('google-closure-deps');
var argv = require('yargs').argv;
var rimraf = require('rimraf');
var {BUILD_DIR, DEPS_FILE, TEST_DEPS_FILE, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config');
var {BUILD_DIR, DEPS_FILE, RELEASE_DIR, TEST_DEPS_FILE, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config');
var {getPackageJson} = require('./helper_tasks');
////////////////////////////////////////////////////////////
@@ -668,7 +668,7 @@ function buildCompiled() {
.pipe(compile(options))
.pipe(gulp.rename({suffix: COMPILED_SUFFIX}))
.pipe(gulp.sourcemaps.write('.'))
.pipe(gulp.dest(BUILD_DIR));
.pipe(gulp.dest(RELEASE_DIR));
}
/**
@@ -705,17 +705,17 @@ function buildAdvancedCompilationTest() {
}
/**
* This task copies built files from BUILD_DIR back to the repository
* so they can be committed to git.
* This task copies built files from BUILD_DIR and RELEASE_DIR back to
* the repository so they can be committed to git.
*
* Prerequisite: buildCompiled, buildLangfiles.
*/
function checkinBuilt() {
return gulp.src([
`${BUILD_DIR}/*_compressed.js`,
`${BUILD_DIR}/*_compressed.js.map`,
`${BUILD_DIR}/msg/js/*.js`,
], {base: BUILD_DIR}).pipe(gulp.dest('.'));
`${RELEASE_DIR}/*_compressed.js`,
`${RELEASE_DIR}/*_compressed.js.map`,
// `${BUILD_DIR}/msg/js/*.js`, // Temporarily disabled (base mismatch).
], {base: RELEASE_DIR}).pipe(gulp.dest('.'));
}
/**

View File

@@ -54,15 +54,6 @@ function packageCommonJS(namespace, dependencies) {
});
};
/**
* This task copies the compressed files and their source maps into
* the release directory.
*/
function packageCompressed() {
return gulp.src('*_compressed.js?(.map)', {cwd: BUILD_DIR})
.pipe(gulp.dest(RELEASE_DIR));
};
/**
* This task wraps scripts/package/blockly.js into a UMD module.
* @example import 'blockly/blockly';
@@ -300,10 +291,10 @@ function packageLocales() {
*/
function packageUMDBundle() {
var srcs = [
`${BUILD_DIR}/blockly_compressed.js`,
`${BUILD_DIR}/msg/js/en.js`,
`${BUILD_DIR}/blocks_compressed.js`,
`${BUILD_DIR}/javascript_compressed.js`,
`${RELEASE_DIR}/blockly_compressed.js`,
`${RELEASE_DIR}/msg/en.js`,
`${RELEASE_DIR}/blocks_compressed.js`,
`${RELEASE_DIR}/javascript_compressed.js`,
];
return gulp.src(srcs)
.pipe(gulp.concat('blockly.min.js'))
@@ -384,7 +375,6 @@ const package = gulp.series(
build.build,
gulp.parallel(
packageIndex,
packageCompressed,
packageBrowser,
packageNode,
packageCore,
@@ -396,9 +386,8 @@ const package = gulp.series(
packageLua,
packageDart,
packagePHP,
packageLocales,
packageMedia,
packageUMDBundle,
gulp.series(packageLocales, packageUMDBundle),
packageJSON,
packageReadme,
packageDTS)

View File

@@ -10,7 +10,7 @@
#
# (TODO(#5007): Should fetch this from scripts/gulpfiles/config.js
# instead of hardcoding it here.
readonly BUILD_DIR='build'
readonly RELEASE_DIR='dist'
# These values should be updated with each release. (Note that the
# historic values are tab-delimited.)
@@ -101,8 +101,8 @@ trap fail ERR
# GZip them for additional size comparisons (keep originals, force
# overwite previously-gzipped copies).
echo "Zipping the compressed files"
gzip -kf "${BUILD_DIR}/blockly_compressed.js"
gzip -kf "${BUILD_DIR}/blocks_compressed.js"
gzip -kf "${RELEASE_DIR}/blockly_compressed.js"
gzip -kf "${RELEASE_DIR}/blocks_compressed.js"
# Check the sizes of the files
@@ -126,9 +126,9 @@ compare_size() {
fi
}
compare_size "${BUILD_DIR}/blockly_compressed.js" $BLOCKLY_SIZE_EXPECTED
compare_size "${BUILD_DIR}/blocks_compressed.js" $BLOCKS_SIZE_EXPECTED
compare_size "${BUILD_DIR}/blockly_compressed.js.gz" $BLOCKLY_GZ_SIZE_EXPECTED
compare_size "${BUILD_DIR}/blocks_compressed.js.gz" $BLOCKS_GZ_SIZE_EXPECTED
compare_size "${RELEASE_DIR}/blockly_compressed.js" $BLOCKLY_SIZE_EXPECTED
compare_size "${RELEASE_DIR}/blocks_compressed.js" $BLOCKS_SIZE_EXPECTED
compare_size "${RELEASE_DIR}/blockly_compressed.js.gz" $BLOCKLY_GZ_SIZE_EXPECTED
compare_size "${RELEASE_DIR}/blocks_compressed.js.gz" $BLOCKS_GZ_SIZE_EXPECTED
exit $has_failed

View File

@@ -7,15 +7,15 @@
#
# (TODO(#5007): Should fetch this from scripts/gulpfiles/config.js
# instead of hardcoding it here.
readonly BUILD_DIR='build'
readonly RELEASE_DIR='dist'
gzip -k "${BUILD_DIR}/blockly_compressed.js"
gzip -k "${BUILD_DIR}/blocks_compressed.js"
gzip -k "${RELEASE_DIR}/blockly_compressed.js"
gzip -k "${RELEASE_DIR}/blocks_compressed.js"
blockly_size=$(wc -c < "${BUILD_DIR}/blockly_compressed.js")
blocks_size=$(wc -c < "${BUILD_DIR}/blocks_compressed.js")
blockly_gz_size=$(wc -c < "${BUILD_DIR}/blockly_compressed.js.gz")
blocks_gz_size=$(wc -c < "${BUILD_DIR}/blocks_compressed.js.gz")
blockly_size=$(wc -c < "${RELEASE_DIR}/blockly_compressed.js")
blocks_size=$(wc -c < "${RELEASE_DIR}/blocks_compressed.js")
blockly_gz_size=$(wc -c < "${RELEASE_DIR}/blockly_compressed.js.gz")
blocks_gz_size=$(wc -c < "${RELEASE_DIR}/blocks_compressed.js.gz")
quarters=(1 1 1 2 2 2 3 3 3 4 4 4)
month=$(date +%-m)
quarter=$(echo Q${quarters[$month - 1]} $(date +%Y))