Skip to content

Commit 0e341fa

Browse files
peterschussheimjasonLaster
authored andcommitted
Convert to ES modules (firefox-devtools#2777)
* Convert utils/utils.js to ES module * Convert utils/worker.js to ES module * Convert utils/text.js to ES modules * Convert utils/task.js to ES module * Convert utils/sources-tree.js to ES module * Convert utils/source.js to ES modules * Convert utils/result-list.js to ES modules
1 parent a1ca324 commit 0e341fa

7 files changed

Lines changed: 15 additions & 22 deletions

File tree

src/utils/result-list.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { isFirefox } = require("devtools-config");
1+
import { isFirefox } from "devtools-config";
22

33
function scrollList(resultList, index) {
44
if (!resultList.hasOwnProperty(index)) {
@@ -64,7 +64,4 @@ function handleKeyDown(e: SyntheticKeyboardEvent) {
6464
}
6565
}
6666

67-
module.exports = {
68-
scrollList,
69-
handleKeyDown
70-
};
67+
export { scrollList, handleKeyDown };

src/utils/source.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* @module utils/source
66
*/
77

8-
const { endTruncateStr } = require("./utils");
9-
const { basename } = require("../utils/path");
8+
import { endTruncateStr } from "./utils";
9+
import { basename } from "../utils/path";
1010

1111
import type { Source, SourceText } from "../types";
1212

@@ -143,7 +143,7 @@ function getMode(sourceText: SourceText) {
143143
return { name: "text" };
144144
}
145145

146-
module.exports = {
146+
export {
147147
isJavaScript,
148148
isPretty,
149149
getPrettySourceURL,

src/utils/sources-tree.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* @module utils/sources-tree
66
*/
77

8-
const { parse } = require("url");
8+
import { parse } from "url";
99
import assert from "./DevToolsUtils";
10-
const { isPretty } = require("./source");
11-
const merge = require("lodash/merge");
10+
import { isPretty } from "./source";
11+
import merge from "lodash/merge";
1212

1313
const IGNORED_URLS = ["debugger eval code", "XStringBundle"];
1414

@@ -388,7 +388,7 @@ function getDirectories(sourceUrl: string, sourceTree: any) {
388388
}
389389
}
390390

391-
module.exports = {
391+
export {
392392
createNode,
393393
nodeHasChildren,
394394
createParentMap,

src/utils/task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ const Task = {
4545
}
4646
};
4747

48-
module.exports = { Task };
48+
export { Task };

src/utils/text.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* Utils for keyboard command strings
55
* @module utils/text
66
*/
7+
import { Services } from "devtools-modules";
8+
const { appinfo } = Services;
79

8-
const { Services: { appinfo } } = require("devtools-modules");
910
const isMacOS = appinfo.OS === "Darwin";
1011

1112
/**
@@ -35,6 +36,4 @@ function formatKeyShortcut(shortcut: string): string {
3536
);
3637
}
3738

38-
module.exports = {
39-
formatKeyShortcut
40-
};
39+
export { formatKeyShortcut };

src/utils/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function filterDuplicates(list: Object[], predicate: duplicatesPredicate) {
8383
return pairs.filter(predicate).map(([prev, item]) => item).concat(lastItem);
8484
}
8585

86-
module.exports = {
86+
export {
8787
handleError,
8888
promisify,
8989
endTruncateStr,

src/utils/worker.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,4 @@ function workerHandler(publicInterface) {
5050
};
5151
}
5252

53-
module.exports = {
54-
workerTask,
55-
workerHandler
56-
};
53+
export { workerTask, workerHandler };

0 commit comments

Comments
 (0)