From 4222a51e784f29947e1fc27ee5737e62b3daa894 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 6 Mar 2019 03:12:49 +0000 Subject: [PATCH] Bug 1497839 - Provide method for NetMonitor to use JSX r=jlast Differential Revision: https://phabricator.services.mozilla.com/D20888 --HG-- rename : devtools/client/debugger/new/build/babel.js => devtools/client/shared/build/babel.js rename : devtools/client/debugger/new/build/copy-module.js => devtools/client/shared/build/build-debugger.js extra : moz-landing-system : lando --- devtools/client/debugger/new/moz.build | 2 +- .../debugger/new/node-templates.mozbuild | 35 -------- .../debugger/new/src/actions/ast/moz.build | 2 +- .../new/src/actions/breakpoints/moz.build | 2 +- .../client/debugger/new/src/actions/moz.build | 2 +- .../debugger/new/src/actions/pause/moz.build | 2 +- .../new/src/actions/sources/moz.build | 2 +- .../src/actions/utils/middleware/moz.build | 2 +- .../debugger/new/src/actions/utils/moz.build | 2 +- .../debugger/new/src/client/chrome/moz.build | 2 +- .../debugger/new/src/client/firefox/moz.build | 2 +- .../client/debugger/new/src/client/moz.build | 2 +- .../src/components/Editor/Preview/moz.build | 2 +- .../new/src/components/Editor/menus/moz.build | 2 +- .../new/src/components/Editor/moz.build | 2 +- .../new/src/components/PrimaryPanes/moz.build | 2 +- .../SecondaryPanes/Breakpoints/moz.build | 2 +- .../SecondaryPanes/Frames/moz.build | 2 +- .../src/components/SecondaryPanes/moz.build | 2 +- .../debugger/new/src/components/moz.build | 2 +- .../src/components/shared/Button/moz.build | 2 +- .../components/shared/Button/styles/moz.build | 2 +- .../new/src/components/shared/moz.build | 2 +- devtools/client/debugger/new/src/moz.build | 2 +- .../debugger/new/src/reducers/moz.build | 2 +- .../debugger/new/src/selectors/moz.build | 2 +- .../new/src/utils/breakpoint/moz.build | 2 +- .../debugger/new/src/utils/editor/moz.build | 2 +- .../client/debugger/new/src/utils/moz.build | 2 +- .../new/src/utils/pause/frames/moz.build | 2 +- .../new/src/utils/pause/mapScopes/moz.build | 2 +- .../debugger/new/src/utils/pause/moz.build | 2 +- .../new/src/utils/pause/scopes/moz.build | 2 +- .../new/src/utils/sources-tree/moz.build | 2 +- .../client/debugger/new/src/workers/moz.build | 2 +- .../debugger/new/src/workers/parser/moz.build | 2 +- .../new/src/workers/pretty-print/moz.build | 2 +- .../debugger/new/src/workers/search/moz.build | 2 +- .../{debugger/new => shared}/build/babel.js | 0 .../build/build-debugger.js} | 79 ++++++------------- devtools/client/shared/build/build.js | 43 ++++++++++ .../shared/build/node-templates.mozbuild | 41 ++++++++++ python/mozbuild/mozbuild/action/node.py | 2 +- tools/rewriting/ThirdPartyPaths.txt | 1 + 44 files changed, 149 insertions(+), 126 deletions(-) delete mode 100644 devtools/client/debugger/new/node-templates.mozbuild rename devtools/client/{debugger/new => shared}/build/babel.js (100%) rename devtools/client/{debugger/new/build/copy-module.js => shared/build/build-debugger.js} (79%) create mode 100644 devtools/client/shared/build/build.js create mode 100644 devtools/client/shared/build/node-templates.mozbuild diff --git a/devtools/client/debugger/new/moz.build b/devtools/client/debugger/new/moz.build index 0710104e8103..12b43a7c2176 100644 --- a/devtools/client/debugger/new/moz.build +++ b/devtools/client/debugger/new/moz.build @@ -9,7 +9,7 @@ DIRS += [ 'src', ] -include('node-templates.mozbuild') +include('../../shared/build/node-templates.mozbuild') DevToolsModules( 'panel.js', diff --git a/devtools/client/debugger/new/node-templates.mozbuild b/devtools/client/debugger/new/node-templates.mozbuild deleted file mode 100644 index 3933bbc77f53..000000000000 --- a/devtools/client/debugger/new/node-templates.mozbuild +++ /dev/null @@ -1,35 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -@template -def DebuggerModules(*modules): - # Compute where to put transpiled files into omni.ja package - # All DevTools modules are used via resource://devtools/ URI - # See devtools/shared/jar.mn for how this resource is mapped into jar package. - base = FINAL_TARGET_FILES.chrome.devtools.modules - - # Now, navigate to the right sub-directory into devtools root modules folder - for dir in RELATIVEDIR.split('/'): - base = base[dir] - - size = 0 - for m in modules: - base += ["!" + m] - size += 1 - - if size == 0: - return - - # For the same reason as https://searchfox.org/mozilla-central/source/mobile/android/base/moz.build#180-184 - # we have to insert a first entry as recursivemake overrides the first entry and we end up with empty files - # for the first file only. - outputs = tuple(("node.stub",) + modules) - GENERATED_FILES += [outputs] - - bundle = GENERATED_FILES[outputs] - bundle.script = '/python/mozbuild/mozbuild/action/node.py:generate' - bundle.inputs = ['/devtools/client/debugger/new/build/copy-module.js'] - bundle.inputs.extend(modules) diff --git a/devtools/client/debugger/new/src/actions/ast/moz.build b/devtools/client/debugger/new/src/actions/ast/moz.build index 9b3166090103..d446fc14e7c9 100644 --- a/devtools/client/debugger/new/src/actions/ast/moz.build +++ b/devtools/client/debugger/new/src/actions/ast/moz.build @@ -7,6 +7,6 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'setInScopeLines.js', ) diff --git a/devtools/client/debugger/new/src/actions/breakpoints/moz.build b/devtools/client/debugger/new/src/actions/breakpoints/moz.build index dc4084c38c95..f21ab1db64e7 100644 --- a/devtools/client/debugger/new/src/actions/breakpoints/moz.build +++ b/devtools/client/debugger/new/src/actions/breakpoints/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'addBreakpoint.js', 'breakpointPositions.js', 'index.js', diff --git a/devtools/client/debugger/new/src/actions/moz.build b/devtools/client/debugger/new/src/actions/moz.build index 216bf406db94..632e95eb6245 100644 --- a/devtools/client/debugger/new/src/actions/moz.build +++ b/devtools/client/debugger/new/src/actions/moz.build @@ -11,7 +11,7 @@ DIRS += [ 'utils', ] -DebuggerModules( +CompiledModules( 'ast.js', 'debuggee.js', 'event-listeners.js', diff --git a/devtools/client/debugger/new/src/actions/pause/moz.build b/devtools/client/debugger/new/src/actions/pause/moz.build index a29be685fc0c..54a22a2d51ce 100644 --- a/devtools/client/debugger/new/src/actions/pause/moz.build +++ b/devtools/client/debugger/new/src/actions/pause/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'breakOnNext.js', 'commands.js', 'continueToHere.js', diff --git a/devtools/client/debugger/new/src/actions/sources/moz.build b/devtools/client/debugger/new/src/actions/sources/moz.build index 05444fa488a7..20989c0d024b 100644 --- a/devtools/client/debugger/new/src/actions/sources/moz.build +++ b/devtools/client/debugger/new/src/actions/sources/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'blackbox.js', 'index.js', 'loadSourceText.js', diff --git a/devtools/client/debugger/new/src/actions/utils/middleware/moz.build b/devtools/client/debugger/new/src/actions/utils/middleware/moz.build index 4bbcb3d04eec..491002b5c493 100644 --- a/devtools/client/debugger/new/src/actions/utils/middleware/moz.build +++ b/devtools/client/debugger/new/src/actions/utils/middleware/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'history.js', 'log.js', 'promise.js', diff --git a/devtools/client/debugger/new/src/actions/utils/moz.build b/devtools/client/debugger/new/src/actions/utils/moz.build index f9b7cee1eb06..bd1580d4d577 100644 --- a/devtools/client/debugger/new/src/actions/utils/moz.build +++ b/devtools/client/debugger/new/src/actions/utils/moz.build @@ -7,6 +7,6 @@ DIRS += [ 'middleware', ] -DebuggerModules( +CompiledModules( 'create-store.js', ) diff --git a/devtools/client/debugger/new/src/client/chrome/moz.build b/devtools/client/debugger/new/src/client/chrome/moz.build index f69a5514b1a7..2a9cedee9272 100644 --- a/devtools/client/debugger/new/src/client/chrome/moz.build +++ b/devtools/client/debugger/new/src/client/chrome/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'commands.js', 'create.js', 'events.js', diff --git a/devtools/client/debugger/new/src/client/firefox/moz.build b/devtools/client/debugger/new/src/client/firefox/moz.build index dfefde1481b8..911c81378a7f 100644 --- a/devtools/client/debugger/new/src/client/firefox/moz.build +++ b/devtools/client/debugger/new/src/client/firefox/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'commands.js', 'create.js', 'events.js', diff --git a/devtools/client/debugger/new/src/client/moz.build b/devtools/client/debugger/new/src/client/moz.build index 9b58410d213b..80adc0a71cb0 100644 --- a/devtools/client/debugger/new/src/client/moz.build +++ b/devtools/client/debugger/new/src/client/moz.build @@ -8,7 +8,7 @@ DIRS += [ 'firefox', ] -DebuggerModules( +CompiledModules( 'chrome.js', 'firefox.js', 'index.js', diff --git a/devtools/client/debugger/new/src/components/Editor/Preview/moz.build b/devtools/client/debugger/new/src/components/Editor/Preview/moz.build index 68e367edef14..ffdad73a01d7 100644 --- a/devtools/client/debugger/new/src/components/Editor/Preview/moz.build +++ b/devtools/client/debugger/new/src/components/Editor/Preview/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'index.js', 'Popup.js', ) diff --git a/devtools/client/debugger/new/src/components/Editor/menus/moz.build b/devtools/client/debugger/new/src/components/Editor/menus/moz.build index 8fdcc8699c32..779cd711b3a0 100644 --- a/devtools/client/debugger/new/src/components/Editor/menus/moz.build +++ b/devtools/client/debugger/new/src/components/Editor/menus/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'breakpoints.js', 'editor.js', 'source.js', diff --git a/devtools/client/debugger/new/src/components/Editor/moz.build b/devtools/client/debugger/new/src/components/Editor/moz.build index c5e8e296db87..3920c824642b 100644 --- a/devtools/client/debugger/new/src/components/Editor/moz.build +++ b/devtools/client/debugger/new/src/components/Editor/moz.build @@ -8,7 +8,7 @@ DIRS += [ 'Preview', ] -DebuggerModules( +CompiledModules( 'Breakpoint.js', 'Breakpoints.js', 'ColumnBreakpoint.js', diff --git a/devtools/client/debugger/new/src/components/PrimaryPanes/moz.build b/devtools/client/debugger/new/src/components/PrimaryPanes/moz.build index 3d184211aead..74109f29921c 100644 --- a/devtools/client/debugger/new/src/components/PrimaryPanes/moz.build +++ b/devtools/client/debugger/new/src/components/PrimaryPanes/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'index.js', 'Outline.js', 'OutlineFilter.js', diff --git a/devtools/client/debugger/new/src/components/SecondaryPanes/Breakpoints/moz.build b/devtools/client/debugger/new/src/components/SecondaryPanes/Breakpoints/moz.build index e3a8d83da87f..41c50f67965d 100644 --- a/devtools/client/debugger/new/src/components/SecondaryPanes/Breakpoints/moz.build +++ b/devtools/client/debugger/new/src/components/SecondaryPanes/Breakpoints/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'Breakpoint.js', 'BreakpointHeading.js', 'BreakpointHeadingsContextMenu.js', diff --git a/devtools/client/debugger/new/src/components/SecondaryPanes/Frames/moz.build b/devtools/client/debugger/new/src/components/SecondaryPanes/Frames/moz.build index ca04f256efd2..1fb24f4295eb 100644 --- a/devtools/client/debugger/new/src/components/SecondaryPanes/Frames/moz.build +++ b/devtools/client/debugger/new/src/components/SecondaryPanes/Frames/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'Frame.js', 'FrameIndent.js', 'FrameMenu.js', diff --git a/devtools/client/debugger/new/src/components/SecondaryPanes/moz.build b/devtools/client/debugger/new/src/components/SecondaryPanes/moz.build index 5f340bc1a402..a772ee6bd3f4 100644 --- a/devtools/client/debugger/new/src/components/SecondaryPanes/moz.build +++ b/devtools/client/debugger/new/src/components/SecondaryPanes/moz.build @@ -8,7 +8,7 @@ DIRS += [ 'Frames', ] -DebuggerModules( +CompiledModules( 'CommandBar.js', 'EventListeners.js', 'Expressions.js', diff --git a/devtools/client/debugger/new/src/components/moz.build b/devtools/client/debugger/new/src/components/moz.build index 185b917d1188..8630b23e7841 100644 --- a/devtools/client/debugger/new/src/components/moz.build +++ b/devtools/client/debugger/new/src/components/moz.build @@ -10,7 +10,7 @@ DIRS += [ 'shared', ] -DebuggerModules( +CompiledModules( 'A11yIntention.js', 'App.js', 'ProjectSearch.js', diff --git a/devtools/client/debugger/new/src/components/shared/Button/moz.build b/devtools/client/debugger/new/src/components/shared/Button/moz.build index 2a7962d35e94..4b60be57ad3a 100644 --- a/devtools/client/debugger/new/src/components/shared/Button/moz.build +++ b/devtools/client/debugger/new/src/components/shared/Button/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'CloseButton.js', 'CommandBarButton.js', 'index.js', diff --git a/devtools/client/debugger/new/src/components/shared/Button/styles/moz.build b/devtools/client/debugger/new/src/components/shared/Button/styles/moz.build index e97ebe50f17b..e32d46b4b0d4 100644 --- a/devtools/client/debugger/new/src/components/shared/Button/styles/moz.build +++ b/devtools/client/debugger/new/src/components/shared/Button/styles/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'CloseButton.css', 'CommandBarButton.css', 'PaneToggleButton.css', diff --git a/devtools/client/debugger/new/src/components/shared/moz.build b/devtools/client/debugger/new/src/components/shared/moz.build index 4f032035ac69..80a6b73a7b6c 100644 --- a/devtools/client/debugger/new/src/components/shared/moz.build +++ b/devtools/client/debugger/new/src/components/shared/moz.build @@ -7,7 +7,7 @@ DIRS += [ 'Button', ] -DebuggerModules( +CompiledModules( 'AccessibleImage.js', 'Accordion.js', 'Badge.js', diff --git a/devtools/client/debugger/new/src/moz.build b/devtools/client/debugger/new/src/moz.build index faa33777e5cb..92737286e344 100644 --- a/devtools/client/debugger/new/src/moz.build +++ b/devtools/client/debugger/new/src/moz.build @@ -13,7 +13,7 @@ DIRS += [ 'workers', ] -DebuggerModules( +CompiledModules( 'main.development.js', 'main.js', 'vendors.js', diff --git a/devtools/client/debugger/new/src/reducers/moz.build b/devtools/client/debugger/new/src/reducers/moz.build index f69481ad0c62..55988991cee8 100644 --- a/devtools/client/debugger/new/src/reducers/moz.build +++ b/devtools/client/debugger/new/src/reducers/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'ast.js', 'async-requests.js', 'breakpoints.js', diff --git a/devtools/client/debugger/new/src/selectors/moz.build b/devtools/client/debugger/new/src/selectors/moz.build index 476b36348fd6..cc6ffb892fe2 100644 --- a/devtools/client/debugger/new/src/selectors/moz.build +++ b/devtools/client/debugger/new/src/selectors/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'breakpointAtLocation.js', 'breakpoints.js', 'breakpointSources.js', diff --git a/devtools/client/debugger/new/src/utils/breakpoint/moz.build b/devtools/client/debugger/new/src/utils/breakpoint/moz.build index af85a0c47c6b..52a874c7a0e9 100644 --- a/devtools/client/debugger/new/src/utils/breakpoint/moz.build +++ b/devtools/client/debugger/new/src/utils/breakpoint/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'astBreakpointLocation.js', 'index.js', ) diff --git a/devtools/client/debugger/new/src/utils/editor/moz.build b/devtools/client/debugger/new/src/utils/editor/moz.build index eb66ee386324..2727b06ffc46 100644 --- a/devtools/client/debugger/new/src/utils/editor/moz.build +++ b/devtools/client/debugger/new/src/utils/editor/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'create-editor.js', 'get-expression.js', 'get-token-location.js', diff --git a/devtools/client/debugger/new/src/utils/moz.build b/devtools/client/debugger/new/src/utils/moz.build index 126e89a8dca5..6af83f364cf9 100644 --- a/devtools/client/debugger/new/src/utils/moz.build +++ b/devtools/client/debugger/new/src/utils/moz.build @@ -10,7 +10,7 @@ DIRS += [ 'sources-tree', ] -DebuggerModules( +CompiledModules( 'assert.js', 'ast.js', 'asyncStoreHelper.js', diff --git a/devtools/client/debugger/new/src/utils/pause/frames/moz.build b/devtools/client/debugger/new/src/utils/pause/frames/moz.build index c8fe1ed8ae8c..98e5dfdde917 100644 --- a/devtools/client/debugger/new/src/utils/pause/frames/moz.build +++ b/devtools/client/debugger/new/src/utils/pause/frames/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'annotateFrames.js', 'collapseFrames.js', 'displayName.js', diff --git a/devtools/client/debugger/new/src/utils/pause/mapScopes/moz.build b/devtools/client/debugger/new/src/utils/pause/mapScopes/moz.build index 5550957a00ba..dc46f2e66564 100644 --- a/devtools/client/debugger/new/src/utils/pause/mapScopes/moz.build +++ b/devtools/client/debugger/new/src/utils/pause/mapScopes/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'buildGeneratedBindingList.js', 'filtering.js', 'findGeneratedBindingFromPosition.js', diff --git a/devtools/client/debugger/new/src/utils/pause/moz.build b/devtools/client/debugger/new/src/utils/pause/moz.build index a1c9b13218ff..c5c0b2215910 100644 --- a/devtools/client/debugger/new/src/utils/pause/moz.build +++ b/devtools/client/debugger/new/src/utils/pause/moz.build @@ -9,7 +9,7 @@ DIRS += [ 'scopes', ] -DebuggerModules( +CompiledModules( 'index.js', 'why.js', ) diff --git a/devtools/client/debugger/new/src/utils/pause/scopes/moz.build b/devtools/client/debugger/new/src/utils/pause/scopes/moz.build index c0e888e8ab81..0e44a6feea82 100644 --- a/devtools/client/debugger/new/src/utils/pause/scopes/moz.build +++ b/devtools/client/debugger/new/src/utils/pause/scopes/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'getScope.js', 'getVariables.js', 'index.js', diff --git a/devtools/client/debugger/new/src/utils/sources-tree/moz.build b/devtools/client/debugger/new/src/utils/sources-tree/moz.build index 19443736178b..4550973c166b 100644 --- a/devtools/client/debugger/new/src/utils/sources-tree/moz.build +++ b/devtools/client/debugger/new/src/utils/sources-tree/moz.build @@ -7,7 +7,7 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'addToTree.js', 'collapseTree.js', 'createTree.js', diff --git a/devtools/client/debugger/new/src/workers/moz.build b/devtools/client/debugger/new/src/workers/moz.build index 51698d677abb..659379c30c46 100644 --- a/devtools/client/debugger/new/src/workers/moz.build +++ b/devtools/client/debugger/new/src/workers/moz.build @@ -9,6 +9,6 @@ DIRS += [ 'search', ] -DebuggerModules( +CompiledModules( ) diff --git a/devtools/client/debugger/new/src/workers/parser/moz.build b/devtools/client/debugger/new/src/workers/parser/moz.build index be59b65c7d8d..244c4f2b980d 100644 --- a/devtools/client/debugger/new/src/workers/parser/moz.build +++ b/devtools/client/debugger/new/src/workers/parser/moz.build @@ -7,6 +7,6 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'index.js', ) diff --git a/devtools/client/debugger/new/src/workers/pretty-print/moz.build b/devtools/client/debugger/new/src/workers/pretty-print/moz.build index be59b65c7d8d..244c4f2b980d 100644 --- a/devtools/client/debugger/new/src/workers/pretty-print/moz.build +++ b/devtools/client/debugger/new/src/workers/pretty-print/moz.build @@ -7,6 +7,6 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'index.js', ) diff --git a/devtools/client/debugger/new/src/workers/search/moz.build b/devtools/client/debugger/new/src/workers/search/moz.build index be59b65c7d8d..244c4f2b980d 100644 --- a/devtools/client/debugger/new/src/workers/search/moz.build +++ b/devtools/client/debugger/new/src/workers/search/moz.build @@ -7,6 +7,6 @@ DIRS += [ ] -DebuggerModules( +CompiledModules( 'index.js', ) diff --git a/devtools/client/debugger/new/build/babel.js b/devtools/client/shared/build/babel.js similarity index 100% rename from devtools/client/debugger/new/build/babel.js rename to devtools/client/shared/build/babel.js diff --git a/devtools/client/debugger/new/build/copy-module.js b/devtools/client/shared/build/build-debugger.js similarity index 79% rename from devtools/client/debugger/new/build/copy-module.js rename to devtools/client/shared/build/build-debugger.js index 943d84313058..542fc090e77a 100644 --- a/devtools/client/debugger/new/build/copy-module.js +++ b/devtools/client/shared/build/build-debugger.js @@ -1,17 +1,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at . */ +/* globals process, __filename, __dirname */ const Babel = require("./babel"); const fs = require("fs"); const _path = require("path"); -const { execFileSync } = require("child_process"); const EXCLUDED_FILES = { "../assets/panel/debugger.properties": "devtools/shared/flags", "devtools-connection": "devtools/shared/flags", "chrome-remote-interface": "devtools/shared/flags", - "devtools-launchpad": "devtools/shared/flags" + "devtools-launchpad": "devtools/shared/flags", }; const mappings = Object.assign( @@ -46,10 +46,6 @@ function isRequire(t, node) { return node && t.isCallExpression(node) && node.callee.name == "require"; } -function isImport(t, node) { - return node && t.isImportDeclaration(node); -} - // List of vendored modules. // Should be synchronized with vendors.js const VENDORS = [ @@ -75,18 +71,18 @@ const moduleMapping = { }; /* - * Updates devtools-modules imports such as - * `import { Telemetry } from "devtools-modules"` - * so that we can customize how we resolve certain modules in the package - * - * In the case of multiple declarations we need to move - * the telemetry module into its own import. - */ +* Updates devtools-modules imports such as +* `import { Telemetry } from "devtools-modules"` +* so that we can customize how we resolve certain modules in the package +* +* In the case of multiple declarations we need to move +* the telemetry module into its own import. +*/ function updateDevtoolsModulesImport(path, t) { const specifiers = path.node.specifiers; for (let i = 0; i < specifiers.length; i++) { - let specifier = specifiers[i]; + const specifier = specifiers[i]; const localName = specifier.local.name; if (localName in moduleMapping) { const newImport = t.importDeclaration( @@ -108,9 +104,9 @@ function updateDevtoolsModulesImport(path, t) { } /** - * This Babel plugin is used to transpile a single Debugger module into a module that - * can be loaded in Firefox via the regular DevTools loader. - */ +* This Babel plugin is used to transpile a single Debugger module into a module that +* can be loaded in Firefox via the regular DevTools loader. +*/ function transformMC({ types: t }) { return { visitor: { @@ -195,45 +191,22 @@ function transformMC({ types: t }) { !(value.startsWith("devtools") || mappingValues.includes(value)) ) { path.replaceWith(t.stringLiteral(`${value}/index`)); - return; } - } - } + }, + }, }; }; Babel.registerPlugin("transform-mc", transformMC); -function transform(filePath) { - const doc = fs.readFileSync(filePath, "utf8"); - const out = Babel.transform(doc, { - plugins: [ - "transform-flow-strip-types", - "syntax-trailing-function-commas", - "transform-class-properties", - "transform-es2015-modules-commonjs", - "transform-react-jsx", - "syntax-object-rest-spread", - ["transform-mc", { mappings, vendors: VENDORS, filePath }] - ] - }); - - return out.code; -} - -const deps = [ - __filename, - _path.resolve(__dirname, "babel.js") -]; - -for (let i = 2; i < process.argv.length; i++) { - const srcPath = process.argv[i]; - const code = transform(srcPath); - const filePath = _path.basename(srcPath); - fs.writeFileSync(filePath, code); - deps.push(srcPath); -} - -// Print all dependencies prefixed with 'dep:' in order to help node.py, the script that -// calls this module, to report back the precise list of all dependencies. -console.log(deps.map(file => "dep:" + file).join("\n")); +module.exports = function(filePath) { + return [ + "transform-flow-strip-types", + "syntax-trailing-function-commas", + "transform-class-properties", + "transform-es2015-modules-commonjs", + "transform-react-jsx", + "syntax-object-rest-spread", + ["transform-mc", { mappings, vendors: VENDORS, filePath }], + ]; +} \ No newline at end of file diff --git a/devtools/client/shared/build/build.js b/devtools/client/shared/build/build.js new file mode 100644 index 000000000000..dd71ae27ca42 --- /dev/null +++ b/devtools/client/shared/build/build.js @@ -0,0 +1,43 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . */ +/* globals process, __filename, __dirname */ + +const Babel = require("./babel"); +const fs = require("fs"); +const _path = require("path"); + +const defaultPlugins = [ + "transform-flow-strip-types", + "transform-class-properties", + "transform-react-jsx", +]; + +function transform(filePath) { +// Use the extra plugins only for the debugger + const plugins = filePath.includes("devtools/client/debugger/new") + ? require("./build-debugger")(filePath) + : defaultPlugins; + + const doc = fs.readFileSync(filePath, "utf8"); + const out = Babel.transform(doc, { plugins }); + + return out.code; +} + +const deps = [ + __filename, + _path.resolve(__dirname, "babel.js"), +]; + +for (let i = 2; i < process.argv.length; i++) { + const srcPath = process.argv[i]; + const code = transform(srcPath); + const filePath = _path.basename(srcPath); + fs.writeFileSync(filePath, code); + deps.push(srcPath); +} + +// Print all dependencies prefixed with 'dep:' in order to help node.py, the script that +// calls this module, to report back the precise list of all dependencies. +console.log(deps.map(file => "dep:" + file).join("\n")); diff --git a/devtools/client/shared/build/node-templates.mozbuild b/devtools/client/shared/build/node-templates.mozbuild new file mode 100644 index 000000000000..3156d192f026 --- /dev/null +++ b/devtools/client/shared/build/node-templates.mozbuild @@ -0,0 +1,41 @@ +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +@template +def CompiledModules(*modules): + # Compute where to put compiled files into omni.ja package + # All DevTools modules are used via resource://devtools/ URI + # See devtools/shared/jar.mn for how this resource is mapped into jar package. + base = FINAL_TARGET_FILES.chrome.devtools.modules + + compiled_directory_whitelist = ( + "devtools/client/debugger/new/src", + ) + + if not RELATIVEDIR.startswith(compiled_directory_whitelist): + error("File in directory provided to CompiledModules not allowed: " + RELATIVEDIR) + + # Now, navigate to the right sub-directory into devtools root modules folder + for dir in RELATIVEDIR.split('/'): + base = base[dir] + + size = 0 + for m in modules: + base += ["!" + m] + size += 1 + + if size == 0: + return + + # For the same reason as https://searchfox.org/mozilla-central/source/mobile/android/base/moz.build#180-184 + # we have to insert a first entry as recursivemake overrides the first entry and we end up with empty files + # for the first file only. + outputs = tuple(("node.stub",) + modules) + GENERATED_FILES += [outputs] + + bundle = GENERATED_FILES[outputs] + bundle.script = '/python/mozbuild/mozbuild/action/node.py:generate' + bundle.inputs = ['/devtools/client/shared/build/build.js',] + bundle.inputs.extend(modules) diff --git a/python/mozbuild/mozbuild/action/node.py b/python/mozbuild/mozbuild/action/node.py index dcd6a89e5b01..de4e094a9471 100644 --- a/python/mozbuild/mozbuild/action/node.py +++ b/python/mozbuild/mozbuild/action/node.py @@ -10,7 +10,7 @@ import subprocess import sys SCRIPT_ALLOWLIST = [ - buildconfig.topsrcdir + "/devtools/client/debugger/new/build/copy-module.js" + buildconfig.topsrcdir + "/devtools/client/shared/build/build.js" ] ALLOWLIST_ERROR = ''' diff --git a/tools/rewriting/ThirdPartyPaths.txt b/tools/rewriting/ThirdPartyPaths.txt index 3cbe1dc4258f..68a98afe0eb2 100644 --- a/tools/rewriting/ThirdPartyPaths.txt +++ b/tools/rewriting/ThirdPartyPaths.txt @@ -1,5 +1,6 @@ browser/components/translation/cld2/ db/sqlite3/src/ +devtools/client/shared/build/babel.js devtools/client/shared/sourceeditor/codemirror/ devtools/client/shared/sourceeditor/tern/ devtools/shared/heapsnapshot/CoreDump.pb.cc