From 8d645ff7895c020a83cde28b741981c6c14a5448 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Thu, 8 Jun 2017 10:50:46 -0400 Subject: [PATCH] replace commonjs with imports --- src/client/firefox.js | 4 ++-- src/main.js | 17 +++++++++-------- src/test/fixtures/index.js | 2 +- src/test/integration/runner.js | 4 ++-- src/test/tests-framework.js | 14 +++++--------- src/test/tests-setup.js | 9 ++++----- src/utils/parser/tests/helpers/index.js | 4 ++-- src/utils/prefs.js | 6 ++++-- src/utils/scopes.js | 2 +- src/utils/tests/build-query.js | 4 ++-- src/utils/tests/fromJS.js | 2 +- src/utils/tests/scopes.js | 2 +- src/utils/tests/source-search.js | 4 ++-- src/utils/tests/source.js | 2 +- src/utils/tests/sources-tree.js | 6 +++--- 15 files changed, 40 insertions(+), 42 deletions(-) diff --git a/src/client/firefox.js b/src/client/firefox.js index 31083e2718..e8f9586f4e 100644 --- a/src/client/firefox.js +++ b/src/client/firefox.js @@ -1,7 +1,7 @@ // @flow -const { setupCommands, clientCommands } = require("./firefox/commands"); -const { setupEvents, clientEvents } = require("./firefox/events"); +import { setupCommands, clientCommands } from "./firefox/commands"; +import { setupEvents, clientEvents } from "./firefox/events"; export async function onConnect(connection: any, actions: Object) { const { diff --git a/src/main.js b/src/main.js index ade5ac3db8..64d0fbc09c 100644 --- a/src/main.js +++ b/src/main.js @@ -1,19 +1,20 @@ // @flow -const React = require("react"); -const ReactDOM = require("react-dom"); +import React from "react"; +import ReactDOM from "react-dom"; + +import { bootstrap, L10N, unmountRoot } from "devtools-launchpad"; +import { isFirefoxPanel } from "devtools-config"; + +import { onConnect } from "./client"; +import { teardownWorkers } from "./utils/bootstrap"; + // // if (process.env.NODE_ENV !== "production") { // const Perf = require("react-addons-perf"); // window.Perf = Perf; // } -const { bootstrap, L10N, unmountRoot } = require("devtools-launchpad"); -const { isFirefoxPanel } = require("devtools-config"); - -const { onConnect } = require("./client"); -const { teardownWorkers } = require("./utils/bootstrap"); - if (isFirefoxPanel()) { module.exports = { bootstrap: ({ diff --git a/src/test/fixtures/index.js b/src/test/fixtures/index.js index 5d8177f534..b35fb08314 100644 --- a/src/test/fixtures/index.js +++ b/src/test/fixtures/index.js @@ -1,4 +1,4 @@ -const foobar = require("./foobar.json"); +import foobar from "./foobar.json"; module.exports = { foobar diff --git a/src/test/integration/runner.js b/src/test/integration/runner.js index 352b9df84f..5674f30cff 100644 --- a/src/test/integration/runner.js +++ b/src/test/integration/runner.js @@ -1,8 +1,8 @@ require("mocha/mocha"); -const expect = require("expect.js"); +import expect from "expect.js"; let { prefs } = require("../../utils/prefs"); -const tests = require("./tests/index"); +import tests from "./tests/index"; Object.assign(window, { prefs }, tests); window.ok = function ok(expected) { diff --git a/src/test/tests-framework.js b/src/test/tests-framework.js index fdebd078ba..41231f99b2 100644 --- a/src/test/tests-framework.js +++ b/src/test/tests-framework.js @@ -1,16 +1,12 @@ -const { - startSourceMapWorker, - stopSourceMapWorker -} = require("devtools-source-map"); +import { startSourceMapWorker, stopSourceMapWorker } from "devtools-source-map"; -const { +import { startPrettyPrintWorker, stopPrettyPrintWorker -} = require("../utils/pretty-print"); +} from "../utils/pretty-print"; -const { startParserWorker, stopParserWorker } = require("../utils/parser"); - -const { getValue } = require("devtools-config"); +import { startParserWorker, stopParserWorker } from "../utils/parser"; +import { getValue } from "devtools-config"; beforeAll(() => { startSourceMapWorker(getValue("workers.sourceMapURL")); diff --git a/src/test/tests-setup.js b/src/test/tests-setup.js index d12b3f0773..627f466aba 100644 --- a/src/test/tests-setup.js +++ b/src/test/tests-setup.js @@ -1,10 +1,9 @@ global.Worker = require("workerjs"); -const path = require("path"); -const getConfig = require("../../bin/getConfig"); -const { setConfig } = require("devtools-config"); -const { readFileSync } = require("fs"); - +import path from "path"; +import getConfig from "../../bin/getConfig"; +import { setConfig } from "devtools-config"; +import { readFileSync } from "fs"; const rootPath = path.join(__dirname, "../../"); const envConfig = getConfig(); diff --git a/src/utils/parser/tests/helpers/index.js b/src/utils/parser/tests/helpers/index.js index eea6156126..af9406b58a 100644 --- a/src/utils/parser/tests/helpers/index.js +++ b/src/utils/parser/tests/helpers/index.js @@ -1,5 +1,5 @@ -const fs = require("fs"); -const path = require("path"); +import fs from "fs"; +import path from "path"; export function getSourceText(name, type = "js") { const text = fs.readFileSync( diff --git a/src/utils/prefs.js b/src/utils/prefs.js index 3b55553b4a..7cdefcf9c2 100644 --- a/src/utils/prefs.js +++ b/src/utils/prefs.js @@ -1,10 +1,12 @@ // @flow -var { PrefsHelper } = require("devtools-modules"); -const { Services: { pref } } = require("devtools-modules"); const { isDevelopment } = require("devtools-config"); +const { Services, PrefsHelper } = require("devtools-modules"); + const prefsSchemaVersion = "1.0.0"; +const pref = Services.pref; + if (isDevelopment()) { pref("devtools.debugger.client-source-maps-enabled", true); pref("devtools.debugger.pause-on-exceptions", false); diff --git a/src/utils/scopes.js b/src/utils/scopes.js index 931c295670..7b4bd52024 100644 --- a/src/utils/scopes.js +++ b/src/utils/scopes.js @@ -1,7 +1,7 @@ // @flow import toPairs from "lodash/toPairs"; -const get = require("lodash/get"); +import get from "lodash/get"; import type { Frame, Pause, Scope } from "debugger-html"; diff --git a/src/utils/tests/build-query.js b/src/utils/tests/build-query.js index daaf0106c8..d5ea98d752 100644 --- a/src/utils/tests/build-query.js +++ b/src/utils/tests/build-query.js @@ -1,5 +1,5 @@ -const escapeRegExp = require("lodash/escapeRegExp"); -const { buildQuery } = require("../editor"); +import escapeRegExp from "lodash/escapeRegExp"; +import { buildQuery } from "../editor"; describe("build-query", () => { it("case-sensitive, whole-word, regex search", () => { diff --git a/src/utils/tests/fromJS.js b/src/utils/tests/fromJS.js index 2bc6d2ae9d..53ceae4300 100644 --- a/src/utils/tests/fromJS.js +++ b/src/utils/tests/fromJS.js @@ -1,4 +1,4 @@ -const fromJS = require("../fromJS"); +import fromJS from "../fromJS"; const preview = { kind: "ArrayLike", diff --git a/src/utils/tests/scopes.js b/src/utils/tests/scopes.js index d91c067ca3..c9b07327e0 100644 --- a/src/utils/tests/scopes.js +++ b/src/utils/tests/scopes.js @@ -1,4 +1,4 @@ -const { getSpecialVariables, getScopes } = require("../scopes"); +import { getSpecialVariables, getScopes } from "../scopes"; const errorGrip = { type: "object", diff --git a/src/utils/tests/source-search.js b/src/utils/tests/source-search.js index 63a48c5a89..e49e17b449 100644 --- a/src/utils/tests/source-search.js +++ b/src/utils/tests/source-search.js @@ -1,5 +1,5 @@ -const { countMatches } = require("../editor"); -const { getMatchIndex } = require("../editor/source-search"); +import { countMatches } from "../editor"; +import { getMatchIndex } from "../editor/source-search"; describe("source-search", () => { describe("countMatches", () => { diff --git a/src/utils/tests/source.js b/src/utils/tests/source.js index 734a0588a5..f2fcc98115 100644 --- a/src/utils/tests/source.js +++ b/src/utils/tests/source.js @@ -1,4 +1,4 @@ -const { getFilename, getMode } = require("../source.js"); +import { getFilename, getMode } from "../source.js"; describe("sources", () => { describe("getFilename", () => { diff --git a/src/utils/tests/sources-tree.js b/src/utils/tests/sources-tree.js index b1c6bd8178..c37006e9bd 100644 --- a/src/utils/tests/sources-tree.js +++ b/src/utils/tests/sources-tree.js @@ -1,5 +1,5 @@ -const { Map } = require("immutable"); -const { +import { Map } from "immutable"; +import { createNode, nodeHasChildren, addToTree, @@ -8,7 +8,7 @@ const { getURL, isExactUrlMatch, isDirectory -} = require("../sources-tree.js"); +} from "../sources-tree.js"; describe("sources-tree", () => { const abcSource = Map({