| # Copyright 2021 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("../../../third_party/typescript/typescript.gni") |
| import("./node.gni") |
| import("./vars.gni") |
| |
| declare_args() { |
| # If this is enabled, devtools build uses esbuild instead of rollup.js to |
| # bundle JavaScript files. |
| devtools_fast_bundle = devtools_skip_typecheck |
| } |
| |
| assert(!(devtools_fast_bundle && is_official_build), |
| "Official build should not bundle with esbuild") |
| |
| template("bundle") { |
| assert(defined(invoker.entrypoint), |
| "You must define the 'entrypoint' for a bundle target") |
| |
| if (devtools_fast_bundle) { |
| node_action(target_name) { |
| script = "scripts/build/esbuild.js" |
| forward_variables_from(invoker, |
| [ |
| "visibility", |
| "deps", |
| "public_deps", |
| ]) |
| |
| inputs = [ |
| invoker.entrypoint, |
| devtools_location_prepend + "scripts/build/devtools_plugin.js", |
| devtools_location_prepend + "scripts/devtools_paths.js", |
| ] |
| |
| _esbuild = devtools_location_prepend + "third_party/esbuild/esbuild" |
| if (host_os == "win") { |
| inputs += [ _esbuild + ".exe" ] |
| } else { |
| inputs += [ _esbuild ] |
| } |
| |
| args = [ |
| rebase_path(invoker.entrypoint, root_build_dir), |
| rebase_path(invoker.output_file_location, root_build_dir), |
| ] |
| |
| outputs = [ invoker.output_file_location ] |
| } |
| } else { |
| node_action(target_name) { |
| script = "node_modules/rollup/dist/bin/rollup" |
| |
| forward_variables_from(invoker, |
| [ |
| "visibility", |
| "deps", |
| "public_deps", |
| ]) |
| |
| inputs = [ |
| invoker.entrypoint, |
| devtools_location_prepend + "scripts/build/rollup.config.js", |
| devtools_location_prepend + "scripts/build/devtools_plugin.js", |
| devtools_location_prepend + "scripts/devtools_paths.js", |
| ] |
| |
| args = [ |
| # TODO(crbug.com/1098074): We need to hide warnings that are written stderr, |
| # as Chromium does not process the returncode of the subprocess correctly |
| # and instead looks if `stderr` is empty. |
| "--silent", |
| "--config", |
| rebase_path( |
| devtools_location_prepend + "scripts/build/rollup.config.js", |
| root_build_dir), |
| "--input", |
| rebase_path(invoker.entrypoint, root_build_dir), |
| "--file", |
| rebase_path(invoker.output_file_location, root_build_dir), |
| ] |
| |
| if (!devtools_dcheck_always_on) { |
| args += [ "--configDCHECK" ] |
| } |
| |
| outputs = [ invoker.output_file_location ] |
| } |
| } |
| } |