This script expects that -legacy.js files are in place for a
given module. So, for example, if migrating front_end/search
one would run move-side-effects-to-legacy for search, then follow
that with this script, replace-internal-references, which will
step through the files in front_end/search and update all globals
to refer to imports.
This script also supports cross-module rewrites, such that if a
namespace is passed through, the -legacy.js file for the namespace
will be loaded instead and used for the replacements.
Bug: 1006759
Change-Id: I7af5e1343a028aed82d5c3f536be886011cf9a2c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1958525
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Closure was unhappy with the `Object.assign` solution. Instead, use
individual assignments and add the relevant comments, so that Closure
can understand what is going on.
Sample output:
```
/*Legacy exported object*/
self.UI = self.UI || {};
/*Legacy exported object*/
UI = UI || {};
//TODO(http://crbug.com/1006759): Add type information if necessary
UI.TextEditor = TextEditor;
//TODO(http://crbug.com/1006759): Add type information if necessary
UI.TextEditor.prototype = prototype;
/** @enum {symbol} */
UI.TextEditor.Events = Events;
```
Bug: 1006759
Change-Id: Ib0e571cc027f544b316a3e3ccf8c3d606273d887
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819248
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Tim Van der Lippe <tvanderlippe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#698878}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c1c9f965bfcf2dbcd8f868414874c085f4ff9515
Example invocation of the script:
./refactor-folder-to-es-modules.sh ui
It will consequently refactor all files in the ui folder to JavaScript
modules. It will also update the BUILD.gn variables to remove the
references from the old all_devtools_files into the new modules
variables.
Change-Id: I35ad6360b15d1aff250afffc8a28774c4e8cc1ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808867
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
Cr-Original-Commit-Position: refs/heads/master@{#697602}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6d48f36bc75c558ac1ee899ccb20877b800e9410