mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 13:13:37 +08:00
Since we have the major version jump, we needed to update quite
a few things to make this work:
1. rollup4 ships with native binaries. We can't check them into
our node_modules for all platforms. Luckily they also ship a
a wasm version. This requires us to adjust the 'binary' path
to `node_modules/@rollup/wasm-node/dist/bin/rollup` instead.
2. rollup4 is more strict when it comes to ES modules vs
CommonJS. We adjust this by renaming the rollup config files.
3. Some plugins got deprecated so we had to replace them with
the newer versions (source maps and terser).
Bug: None
Change-Id: If13d590c8185db6ad85b3992d0a869111909dc8c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5999255
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
124 lines
3.7 KiB
Python
124 lines
3.7 KiB
Python
# Copyright 2019 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.
|
|
"""
|
|
Helper to find the path to the correct third_party directory
|
|
"""
|
|
|
|
from os import path
|
|
import sys
|
|
import platform
|
|
|
|
|
|
# Find the root path of the checkout.
|
|
# In the Chromium repository, this is the src/chromium directory.
|
|
# In the external repository, standalone build, this is the devtools-frontend directory.
|
|
# In the external repository, integrated build, this is the src/chromium directory.
|
|
def root_path():
|
|
SCRIPTS_PATH = path.dirname(path.abspath(__file__))
|
|
ABS_DEVTOOLS_PATH = path.dirname(SCRIPTS_PATH)
|
|
PARENT_PATH = path.dirname(ABS_DEVTOOLS_PATH)
|
|
# TODO(1011259): remove Chromium repository handling
|
|
if path.basename(PARENT_PATH) == 'renderer':
|
|
# Chromium repository
|
|
return path.dirname(path.dirname(path.dirname(PARENT_PATH)))
|
|
elif path.basename(PARENT_PATH) == 'devtools-frontend' or path.basename(
|
|
PARENT_PATH) == 'devtools-frontend-internal':
|
|
# External repository, integrated build
|
|
return path.dirname(path.dirname(PARENT_PATH))
|
|
else:
|
|
# External repository, standalone build
|
|
return ABS_DEVTOOLS_PATH
|
|
|
|
|
|
# This is the third_party path relative to the root of the checkout.
|
|
def third_party_path():
|
|
return path.join(root_path(), 'third_party')
|
|
|
|
|
|
# This points to the node binary downloaded as part of the checkout.
|
|
def node_path():
|
|
try:
|
|
old_sys_path = sys.path[:]
|
|
sys.path.append(path.join(third_party_path(), 'node'))
|
|
import node
|
|
finally:
|
|
sys.path = old_sys_path
|
|
return node.GetBinaryPath()
|
|
|
|
|
|
def devtools_root_path():
|
|
return path.dirname((path.dirname(path.abspath(__file__))))
|
|
|
|
|
|
def node_modules_path():
|
|
return path.join(devtools_root_path(), 'node_modules')
|
|
|
|
|
|
def eslint_path():
|
|
return path.join(node_modules_path(), 'eslint', 'bin', 'eslint.js')
|
|
|
|
|
|
def mocha_path():
|
|
return path.join(node_modules_path(), 'mocha', 'bin', 'mocha')
|
|
|
|
|
|
def karma_path():
|
|
return path.join(node_modules_path(), 'karma', 'bin', 'karma')
|
|
|
|
|
|
def typescript_compiler_path():
|
|
return path.join(node_modules_path(), 'typescript', 'bin', 'tsc')
|
|
|
|
|
|
def hosted_mode_script_path():
|
|
return path.join(devtools_root_path(), 'scripts', 'hosted_mode',
|
|
'server.js')
|
|
|
|
|
|
def esbuild_path():
|
|
return path.join(devtools_root_path(), 'third_party', 'esbuild', 'esbuild')
|
|
|
|
|
|
def downloaded_chrome_binary_path():
|
|
return path.abspath(
|
|
path.join(
|
|
*{
|
|
'Linux': (devtools_root_path(), 'third_party', 'chrome',
|
|
'chrome-linux', 'chrome'),
|
|
'Darwin': (devtools_root_path(), 'third_party', 'chrome',
|
|
'chrome-mac', 'Google Chrome for Testing.app',
|
|
'Contents', 'MacOS', 'Google Chrome for Testing'),
|
|
'Windows': (devtools_root_path(), 'third_party', 'chrome',
|
|
'chrome-win', 'chrome.exe'),
|
|
}[platform.system()]))
|
|
|
|
|
|
def license_checker_path():
|
|
return path.join(node_modules_path(), 'license-checker', 'bin',
|
|
'license-checker')
|
|
|
|
|
|
def rollup_path():
|
|
return path.join(
|
|
node_modules_path(),
|
|
'@rollup',
|
|
'wasm-node',
|
|
'dist',
|
|
'bin',
|
|
'rollup',
|
|
)
|
|
|
|
|
|
def package_lock_json_path():
|
|
return path.join(devtools_root_path(), 'package-lock.json')
|
|
|
|
|
|
def package_json_path():
|
|
return path.join(devtools_root_path(), 'package.json')
|
|
|
|
|
|
def browser_protocol_path():
|
|
return path.join(third_party_path(), 'blink', 'public',
|
|
'devtools_protocol', 'browser_protocol.pdl')
|