Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable EsbuildCompilation on EXP_C #36105

Merged
merged 5 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build-system/global-configs/experiments-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"expiration_date_utc": "2021-06-30",
"define_experiment_constant": "R1_IMG_DEFERRED_BUILD"
},
"experimentC": {}
"experimentC": {
"name": "EsbuildCompilation",
"environment": "AMP",
"issue": "https://github.com/ampproject/amphtml/issues/35264",
"expiration_date_utc": "2021-10-30",
"define_experiment_constant": "ESBUILD_COMPILATION"
}
}
12 changes: 9 additions & 3 deletions build-system/tasks/check-sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@ function checkSourcemapMappings(sourcemapJson, map) {
throw new Error('Could not find mappings array');
}

// Zeroth sub-array corresponds to ';' and has no mappings.
// See https://www.npmjs.com/package/sourcemap-codec#usage
const firstLineMapping = decode(sourcemapJson.mappings)[1][0];
// In closure builds there is a newline immediately after the AMP_CONFIG.
// This whole segment has no mapping to the original source.
// Therefore we must skip the zeroth sub-array, indicated by a ';'.
// In esbuild builds there is no newline after the config, so the
// first line is fair game.
const firstLineIndex = shouldUseClosure() ? 1 : 0;

// See https://www.npmjs.com/package/sourcemap-codec#usage.
const firstLineMapping = decode(sourcemapJson.mappings)[firstLineIndex][0];
const [, sourceIndex = 0, sourceCodeLine = 0, sourceCodeColumn] =
firstLineMapping;

Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ async function esbuildCompile(srcDir, srcFilename, destDir, options) {
};
}
const {banner, footer} = splitWrapper();
const config = await getAmpConfigForFile(srcFilename, options);
const config = await getAmpConfigForFile(destFilename, options);
samouri marked this conversation as resolved.
Show resolved Hide resolved
const compiledFile = await getCompiledFile(srcFilename);
banner.js = config + banner.js + compiledFile;

Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/visual-diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ async function ensureOrBuildAmpRuntimeInTestMode_() {
}

if (argv.nobuild) {
const isInTestMode = /AMP_CONFIG=\{(?:.+,)?"test":true\b/.test(
const isInTestMode = /AMP_CONFIG=\{(?:.+,)?"test":(!0|true)\b/.test(
fs.readFileSync('dist/v0.js', 'utf8')
);
if (!isInTestMode) {
Expand Down