mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-29 16:57:00 +08:00
Stop rewriting html entrypoints
This adds the necessary ES imports to the various entrypoints to properly load their dependencies. This means that we can stop rewriting the HTML entrypoints and simply copy them over to the build directory. Bug: 1046596 Change-Id: If1182ed051a22cc2bb0c77456456ab039f63cec2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2035791 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
4eb885a01e
commit
e894e9c586
@@ -5,6 +5,7 @@
|
||||
import("//third_party/blink/public/public_features.gni")
|
||||
|
||||
all_devtools_files = [
|
||||
"front_end/shell.js",
|
||||
"front_end/accessibility_test_runner/AccessibilityPaneTestRunner.js",
|
||||
"front_end/accessibility_test_runner/module.json",
|
||||
"front_end/accessibility/accessibilityNode.css",
|
||||
@@ -902,7 +903,6 @@ all_devtools_modules = [
|
||||
"front_end/resources/ApplicationCacheItemsView.js",
|
||||
"front_end/resources/AppManifestView.js",
|
||||
"front_end/root.js",
|
||||
"front_end/root.js",
|
||||
"front_end/Runtime.js",
|
||||
"front_end/screencast/InputModel.js",
|
||||
"front_end/screencast/screencast.js",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="devtools_app.js"></script>
|
||||
<script type="module" src="devtools_app.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2018 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 './shell.js';
|
||||
|
||||
Root.Runtime.startApplication('devtools_app');
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="inspector.js"></script>
|
||||
<script type="module" src="inspector.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2014 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 './devtools_app.js';
|
||||
|
||||
Root.Runtime.startApplication('inspector');
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<meta charset="utf-8">
|
||||
<!-- <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com"> -->
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="integration_test_runner.js"></script>
|
||||
<script type="module" src="integration_test_runner.js"></script>
|
||||
</head>
|
||||
<body id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import './devtools_app.js';
|
||||
|
||||
if (self.testRunner) {
|
||||
testRunner.dumpAsText();
|
||||
testRunner.waitUntilDone();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="js_app.js"></script>
|
||||
<script type="module" src="js_app.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2018 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 './shell.js';
|
||||
|
||||
Root.Runtime.startApplication('js_app');
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="ndb_app.js"></script>
|
||||
<script type="module" src="ndb_app.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2018 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 './shell.js';
|
||||
|
||||
Root.Runtime.startApplication('ndb_app');
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="node_app.js"></script>
|
||||
<script type="module" src="node_app.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright 2018 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 './shell.js';
|
||||
|
||||
Root.Runtime.startApplication('node_app');
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// 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 './Runtime.js';
|
||||
// We generate the descriptors in this file, which depend on the runtime.
|
||||
@@ -9,7 +9,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' ">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="toolbox.js"></script>
|
||||
<script type="module" src="toolbox.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script type="module" src="root.js"></script>
|
||||
<script defer src="worker_app.js"></script>
|
||||
<script type="module" src="worker_app.js"></script>
|
||||
</head>
|
||||
<body class="undocked" id="-blink-dev-tools"></body>
|
||||
</html>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright 2018 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 './shell.js';
|
||||
|
||||
Root.Runtime.startApplication('worker_app');
|
||||
|
||||
@@ -121,34 +121,13 @@ class ReleaseBuilder(object):
|
||||
|
||||
def build_app(self):
|
||||
if self.descriptors.has_html:
|
||||
self._build_html()
|
||||
html_entrypoint = self.app_file('html')
|
||||
write_file(join(self.output_dir, html_entrypoint), read_file(join(self.application_dir, html_entrypoint)))
|
||||
self._build_app_script()
|
||||
for module in filter(lambda desc: (not desc.get('type') or desc.get('type') == 'remote'),
|
||||
self.descriptors.application.values()):
|
||||
self._concatenate_dynamic_module(module['name'])
|
||||
|
||||
def _write_include_tags(self, descriptors, output):
|
||||
if descriptors.extends:
|
||||
self._write_include_tags(descriptors.extends, output)
|
||||
output.write(self._generate_include_tag(descriptors.application_name + '.js'))
|
||||
|
||||
def _build_html(self):
|
||||
html_name = self.app_file('html')
|
||||
output = StringIO()
|
||||
with open(join(self.application_dir, html_name), 'r') as app_input_html:
|
||||
for line in app_input_html:
|
||||
if ('<script ' in line and 'type="module"' not in line) or '<link ' in line:
|
||||
continue
|
||||
if '</head>' in line:
|
||||
self._write_include_tags(self.descriptors, output)
|
||||
js_file = join(self.application_dir, self.app_file('js'))
|
||||
if path.exists(js_file):
|
||||
output.write(' <script type="module">%s</script>\n' % minify_js(read_file(js_file)))
|
||||
output.write(line)
|
||||
|
||||
write_file(join(self.output_dir, html_name), output.getvalue())
|
||||
output.close()
|
||||
|
||||
def _build_app_script(self):
|
||||
script_name = self.app_file('js')
|
||||
output = StringIO()
|
||||
@@ -156,12 +135,6 @@ class ReleaseBuilder(object):
|
||||
write_file(join(self.output_dir, script_name), minify_js(output.getvalue()))
|
||||
output.close()
|
||||
|
||||
def _generate_include_tag(self, resource_path):
|
||||
if resource_path.endswith('.js'):
|
||||
return ' <script defer src="%s"></script>\n' % resource_path
|
||||
else:
|
||||
assert resource_path
|
||||
|
||||
def _release_module_descriptors(self):
|
||||
module_descriptors = self.descriptors.modules
|
||||
result = []
|
||||
@@ -210,10 +183,6 @@ class ReleaseBuilder(object):
|
||||
if len(non_autostart_deps):
|
||||
bail_error(
|
||||
'Non-autostart dependencies specified for the autostarted module "%s": %s' % (name, non_autostart_deps))
|
||||
namespace = self._map_module_to_namespace(name)
|
||||
output.write('\n/* Module %s */\n' % name)
|
||||
output.write('\nself[\'%s\'] = self[\'%s\'] || {};\n' % (namespace, namespace))
|
||||
modular_build.concatenate_scripts(desc.get('scripts'), join(self.application_dir, name), self.output_dir, output)
|
||||
else:
|
||||
non_autostart.add(name)
|
||||
|
||||
@@ -222,22 +191,15 @@ class ReleaseBuilder(object):
|
||||
return self._special_case_namespaces.get(module, camel_case_namespace)
|
||||
|
||||
def _concatenate_application_script(self, output):
|
||||
if not self.descriptors.extends:
|
||||
output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors())
|
||||
output.write('/* Application descriptor %s */\n' % self.app_file('json'))
|
||||
output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json())
|
||||
else:
|
||||
output.write('/* Additional descriptors */\n')
|
||||
output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors())
|
||||
output.write('/* Additional descriptors %s */\n' % self.app_file('json'))
|
||||
output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors())
|
||||
if self.descriptors.extends:
|
||||
output.write('Root.applicationDescriptor.modules.push(...%s);' % json.dumps(self.descriptors.application.values()))
|
||||
|
||||
output.write('\n/* Autostart modules */\n')
|
||||
if (self.descriptors.worker):
|
||||
output.write(minify_js(read_file(join(self.application_dir, self.app_file('js')))))
|
||||
else:
|
||||
self._concatenate_autostart_modules(output)
|
||||
output.write(';\n/* Autostart resources */\n')
|
||||
output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json())
|
||||
|
||||
output.write(minify_js(read_file(join(self.application_dir, self.app_file('js')))))
|
||||
self._concatenate_autostart_modules(output)
|
||||
|
||||
self._write_module_resources(self.autorun_resource_names(), output)
|
||||
if not self.descriptors.has_html and not self.descriptors.worker:
|
||||
js_file = join(self.application_dir, self.app_file('js'))
|
||||
|
||||
Reference in New Issue
Block a user