Skip to content

Commit 5cd1844

Browse files
AnshulMalikjasonLaster
authored andcommitted
Convert utils to es6 modules (firefox-devtools#2910)
* Fix event listeners checkboxes * Convert utils to es6 modules
1 parent 4dcf905 commit 5cd1844

9 files changed

Lines changed: 24 additions & 28 deletions

File tree

src/utils/clipboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ function copyToTheClipboard(string) {
1313
document.removeEventListener("copy", doCopy);
1414
}
1515

16-
module.exports = { copyToTheClipboard };
16+
export { copyToTheClipboard };

src/utils/frame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22

3-
const get = require("lodash/get");
3+
import get from "lodash/get";
44
import { isEnabled } from "devtools-config";
55
import { endTruncateStr } from "./utils";
66
import { getFilename } from "./source";

src/utils/fromJS.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @module utils/fromJS
77
*/
88

9-
const Immutable = require("immutable");
10-
const isFunction = require("lodash/isFunction");
9+
import * as I from "immutable";
10+
import isFunction from "lodash/isFunction";
1111

1212
// hasOwnProperty is defensive because it is possible that the
1313
// object that we're creating a map for has a `hasOwnProperty` field
@@ -38,7 +38,7 @@ function createMap(value) {
3838
value.length = `${value.length}`;
3939
}
4040

41-
let map = Immutable.Seq(value).map(fromJS).toMap();
41+
let map = I.Seq(value).map(fromJS).toMap();
4242

4343
if (hasLength) {
4444
map = map.set("length", length);
@@ -49,7 +49,7 @@ function createMap(value) {
4949
}
5050

5151
function createList(value) {
52-
return Immutable.Seq(value).map(fromJS).toList();
52+
return I.Seq(value).map(fromJS).toList();
5353
}
5454

5555
/**

src/utils/makeRecord.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @module utils/makeRecord
99
*/
1010

11-
const I = require("immutable");
11+
import * as I from "immutable";
1212

1313
/**
1414
* @memberof utils/makeRecord
@@ -39,4 +39,4 @@ function makeRecord<T>(spec: T & Object): (init: $Shape<T>) => Record<T> {
3939
return I.Record(spec);
4040
}
4141

42-
module.exports = makeRecord;
42+
export default makeRecord;

src/utils/object-inspector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const get = require("lodash/get");
2-
const { maybeEscapePropertyName } = require("devtools-reps");
1+
import get from "lodash/get";
2+
import { maybeEscapePropertyName } from "devtools-reps";
33

44
let WINDOW_PROPERTIES = {};
55

@@ -244,7 +244,7 @@ function getChildren({ getObjectProperties, actors, item }) {
244244
return children;
245245
}
246246

247-
module.exports = {
247+
export {
248248
nodeHasChildren,
249249
nodeIsOptimizedOut,
250250
nodeIsMissingArguments,

src/utils/parser/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22

3-
const { workerUtils: { WorkerDispatcher } } = require("devtools-utils");
3+
import { workerUtils } from "devtools-utils";
4+
const { WorkerDispatcher } = workerUtils;
45

56
const dispatcher = new WorkerDispatcher();
67

src/utils/parser/utils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// @flow
22

3-
const babylon = require("babylon");
4-
const traverse = require("babel-traverse").default;
5-
const t = require("babel-types");
6-
const { isDevelopment } = require("devtools-config");
7-
const toPairs = require("lodash/toPairs");
8-
const isEmpty = require("lodash/isEmpty");
9-
const uniq = require("lodash/uniq");
3+
import * as babylon from "babylon";
4+
import traverse from "babel-traverse";
5+
import * as t from "babel-types";
6+
import { isDevelopment } from "devtools-config";
7+
import toPairs from "lodash/toPairs";
8+
import isEmpty from "lodash/isEmpty";
9+
import uniq from "lodash/uniq";
1010
import parseScriptTags from "parse-script-tags";
1111

1212
import type { SourceText, Location, Frame, TokenResolution } from "../../types";

src/utils/path.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,4 @@ function join(base: string, dir: string) {
2121
return `${base}/${dir}`;
2222
}
2323

24-
module.exports = {
25-
basename,
26-
dirname,
27-
isURL,
28-
isAbsolute,
29-
join
30-
};
24+
export { basename, dirname, isURL, isAbsolute, join };

src/utils/pretty-print/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// @flow
22

3-
const { workerUtils: { WorkerDispatcher } } = require("devtools-utils");
4-
const { isJavaScript } = require("../source");
3+
import { workerUtils } from "devtools-utils";
4+
const { WorkerDispatcher } = workerUtils;
5+
import { isJavaScript } from "../source";
56
import assert from "../assert";
67

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

0 commit comments

Comments
 (0)