mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
This provides consistency of how imports are order, reducing differences in authored files. Bug: none Change-Id: I45ddd71e3e0004aca32f101cb926101544a34157 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6218490 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
// Copyright 2022 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.
|
|
|
|
// @ts-check
|
|
|
|
const os = require('os');
|
|
const path = require('path');
|
|
|
|
const devtools_paths = require('../devtools_paths.js');
|
|
|
|
const devtools_plugin = require('./devtools_plugin.js');
|
|
|
|
// esbuild module uses binary in this path.
|
|
const binaryName = os.type() === 'Windows_NT' ? 'esbuild.exe' : 'esbuild';
|
|
process.env.ESBUILD_BINARY_PATH = path.join(devtools_paths.devtoolsRootPath(), 'third_party', 'esbuild', binaryName);
|
|
|
|
const entryPoints = [process.argv[2]];
|
|
const outfile = process.argv[3];
|
|
const useSourceMaps = process.argv.slice(4).includes('--configSourcemaps');
|
|
|
|
const outdir = path.dirname(outfile);
|
|
|
|
const plugin = {
|
|
name: 'devtools-plugin',
|
|
setup(build) {
|
|
// https://esbuild.github.io/plugins/#on-resolve
|
|
build.onResolve({filter: /.*/}, devtools_plugin.esbuildPlugin(outdir));
|
|
},
|
|
};
|
|
|
|
require('esbuild')
|
|
.build({
|
|
entryPoints,
|
|
outfile,
|
|
bundle: true,
|
|
format: 'esm',
|
|
platform: 'browser',
|
|
plugins: [plugin],
|
|
sourcemap: useSourceMaps,
|
|
})
|
|
.catch(err => {
|
|
console.error('failed to run esbuild:', err);
|
|
process.exit(1);
|
|
});
|