diff --git a/package.json b/package.json index d14755ec823..4bdf03697c3 100644 --- a/package.json +++ b/package.json @@ -54,5 +54,8 @@ "ts_library-test": "./third_party/typescript/tests/verify_ts_libary.sh", "unittest": "scripts/test/run_unittests.py --no-text-coverage", "watch": "third_party/node/node.py --output scripts/watch_build.js" + }, + "devDependencies": { + "sync-fetch": "latest" } } diff --git a/scripts/build/generate_css_js_files.js b/scripts/build/generate_css_js_files.js index bd1770528de..0a81027f743 100644 --- a/scripts/build/generate_css_js_files.js +++ b/scripts/build/generate_css_js_files.js @@ -3,6 +3,7 @@ // found in the LICENSE file. const fs = require('fs'); const path = require('path'); +const fetch = require('sync-fetch'); const CleanCSS = require('clean-css'); const [, , isDebugString, targetName, srcDir, targetGenDir, files] = process.argv; @@ -11,6 +12,8 @@ const configFiles = []; const cleanCSS = new CleanCSS(); const isDebug = isDebugString === 'true'; +const constructibleStyleSheetsPolyfill = fetch('https://unpkg.com/construct-style-sheets-polyfill@3.0.0/dist/adoptedStyleSheets.js').text(); + for (const fileName of filenames) { let output = fs.readFileSync(path.join(srcDir, fileName), {encoding: 'utf8', flag: 'r'}); output = output.replace(/\`/g, '\\\''); @@ -18,9 +21,12 @@ for (const fileName of filenames) { fs.writeFileSync( path.join(targetGenDir, fileName + '.js'), - `// Copyright ${new Date().getFullYear()} The Chromium Authors. All rights reserved. + `${constructibleStyleSheetsPolyfill} + +// Copyright ${new Date().getFullYear()} The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + const styles = new CSSStyleSheet(); styles.replaceSync( \`${isDebug ? output : cleanCSS.minify(output).styles}