diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2022-05-16 21:25:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 21:25:05 -0400 |
commit | 9941d583a07dd0ec8c7740783ca8665f52331f3d (patch) | |
tree | c7d024231b33e63aed9cde47796466824f1ca333 /dev | |
parent | 5a723034b8ac9eb86854bdcb16f624d18fa17178 (diff) |
Parse5 update (#2140)
* Update build-libs.js
* Add a test for build-libs.js
* Update parse5
* Rebuild parse5
* Update build-libs.js to generate consistent path names
* Rebuild
Diffstat (limited to 'dev')
-rw-r--r-- | dev/build-libs.js | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/dev/build-libs.js b/dev/build-libs.js index 37d74851..189a967d 100644 --- a/dev/build-libs.js +++ b/dev/build-libs.js @@ -19,21 +19,47 @@ const fs = require('fs'); const path = require('path'); const browserify = require('browserify'); -async function main() { - const extLibPath = path.join(__dirname, '..', 'ext', 'lib'); +async function buildParse5() { const parse5Path = require.resolve('parse5'); - - const content = await new Promise((resolve, reject) => { - browserify([parse5Path], {standalone: 'parse5', debug: true}).bundle((error, result) => { - if (error) { - reject(error); - } else { - resolve(result); - } + const cwd = process.cwd(); + try { + const baseDir = path.dirname(parse5Path); + process.chdir(baseDir); // This is necessary to ensure relative source map file names are consistent + return await new Promise((resolve, reject) => { + browserify({ + entries: [parse5Path], + standalone: 'parse5', + debug: true, + baseDir + }).bundle((error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); }); - }); + } finally { + process.chdir(cwd); + } +} - fs.writeFileSync(path.join(extLibPath, 'parse5.js'), content); +function getBuildTargets() { + const extLibPath = path.join(__dirname, '..', 'ext', 'lib'); + return [ + {path: path.join(extLibPath, 'parse5.js'), build: buildParse5} + ]; } -main(); +async function main() { + for (const {path: path2, build} of getBuildTargets()) { + const content = await build(); + fs.writeFileSync(path2, content); + } +} + +if (require.main === module) { main(); } + +module.exports = { + getBuildTargets +}; |