diff --git a/front_end/rollup.config.js b/front_end/rollup.config.js new file mode 100644 index 0000000000..48761bf16a --- /dev/null +++ b/front_end/rollup.config.js @@ -0,0 +1,20 @@ +// Copyright 2020 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. + +import * as fs from 'fs'; +import * as path from 'path'; + +const external = fs.readdirSync(__dirname, {withFileTypes: true}) + .filter(dirent => dirent.isDirectory()) + .map(dirent => path.join(__dirname, dirent.name, dirent.name + '.js')); + +// eslint-disable-next-line import/no-default-export +export default { + external, + treeshake: false, + context: 'self', + output: { + format: 'esm', + }, +}; diff --git a/scripts/build/build_release_applications.py b/scripts/build/build_release_applications.py index 9a128cc6ae..6e2bcab657 100644 --- a/scripts/build/build_release_applications.py +++ b/scripts/build/build_release_applications.py @@ -40,17 +40,6 @@ finally: FRONT_END_DIRECTORY = path.join(os.path.dirname(path.abspath(__file__)), '..', '..', 'front_end') -MODULE_LIST = [ - path.join(FRONT_END_DIRECTORY, subfolder, subfolder + '.js') - for subfolder in os.listdir(FRONT_END_DIRECTORY) - if path.isdir(os.path.join(FRONT_END_DIRECTORY, subfolder)) -] - -ROLLUP_ARGS = [ - '--no-treeshake', '--format', 'esm', '--context', 'self', '--external', - ','.join([path.abspath(module) for module in MODULE_LIST]) -] - def main(argv): try: @@ -221,10 +210,14 @@ class ReleaseBuilder(object): js_entrypoint = join(self.application_dir, module_name, module_name + '.js') out = '' if self.use_rollup: - rollup_process = subprocess.Popen( - [devtools_paths.node_path(), devtools_paths.rollup_path()] + ROLLUP_ARGS + ['--input', js_entrypoint], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + rollup_process = subprocess.Popen([ + devtools_paths.node_path(), + devtools_paths.rollup_path(), '--config', + join(FRONT_END_DIRECTORY, 'rollup.config.js'), '--input', + js_entrypoint + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, error = rollup_process.communicate() else: out = read_file(js_entrypoint)