Bug 1237253 - Support define in BrowserLoader; r=jlongster r=jryans

This commit is contained in:
Jan Odvarko 2016-01-15 14:15:28 +01:00
parent 5082deee54
commit 8633136aa0
24 changed files with 41 additions and 26 deletions

View File

@ -6,7 +6,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./reps/rep-utils");
const { Headers } = createFactories(require("./headers"));
const { Toolbar, ToolbarButton } = createFactories(require("./reps/toolbar"));

View File

@ -6,7 +6,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
// Constants
const DOM = React.DOM;

View File

@ -6,7 +6,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./reps/rep-utils");
const { TreeView } = createFactories(require("./reps/tree-view"));
const { SearchBox } = createFactories(require("./search-box"));

View File

@ -8,7 +8,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./reps/rep-utils");
const { JsonPanel } = createFactories(require("./json-panel"));
const { TextPanel } = createFactories(require("./text-panel"));

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { Rep } = createFactories(require("./rep"));
const { ObjectBox } = createFactories(require("./object-box"));

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const DOM = React.DOM;
/**

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { ObjectBox } = createFactories(require("./object-box"));

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { ObjectBox } = createFactories(require("./object-box"));

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const DOM = React.DOM;
/**

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const DOM = React.DOM;
/**

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { ObjectBox } = createFactories(require("./object-box"));
const { Caption } = createFactories(require("./caption"));

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
/**
* Create React factories for given arguments.

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
// Load all existing rep templates
const { Undefined } = require("./undefined");

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { ObjectBox } = createFactories(require("./object-box"));

View File

@ -8,7 +8,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const DOM = React.DOM;
/**

View File

@ -8,7 +8,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const DOM = React.DOM;
/**

View File

@ -7,7 +7,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { Rep } = createFactories(require("./rep"));
const { StringRep } = require("./string");

View File

@ -9,7 +9,7 @@
define(function(require, exports, module) {
// Dependencies
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./rep-utils");
const { ObjectBox } = createFactories(require("./object-box"));

View File

@ -8,7 +8,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const DOM = React.DOM;

View File

@ -6,7 +6,7 @@
define(function(require, exports, module) {
const React = require("react");
const React = require("devtools/client/shared/vendor/react");
const { createFactories } = require("./reps/rep-utils");
const { Toolbar, ToolbarButton } = createFactories(require("./reps/toolbar"));
const DOM = React.DOM;

View File

@ -7,9 +7,7 @@
define(function(require, exports, module) {
// ReactJS
const ReactDOM = require("react-dom");
// RDP Inspector
const ReactDOM = require("devtools/client/shared/vendor/react-dom");
const { createFactories } = require("./components/reps/rep-utils");
const { MainTabbedArea } = createFactories(require("./components/main-tabbed-area"));

View File

@ -16,15 +16,19 @@
*
* The path mapping uses paths fallback (a feature supported by RequireJS)
* See also: http://requirejs.org/docs/api.html#pathsfallbacks
*
* React module ID is using exactly the same (relative) path as the rest
* of the code base, so it's consistent and modules can be easily reused.
*/
require.config({
baseUrl: ".",
paths: {
"react": [
"devtools/client/shared/vendor/react": [
"resource://devtools/client/shared/vendor/react-dev",
"resource://devtools/client/shared/vendor/react"
],
"react-dom": "resource://devtools/client/shared/vendor/react-dom"
"devtools/client/shared/vendor/react-dom":
"resource://devtools/client/shared/vendor/react-dom"
}
});

View File

@ -1,9 +1,15 @@
/* 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/. */
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const loaders = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
const { devtools, DevToolsLoader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { joinURI } = devtools.require("devtools/shared/path");
const BROWSER_BASED_DIRS = [
"resource://devtools/client/jsonview",
"resource://devtools/client/shared/vendor",
"resource://devtools/client/shared/components",
"resource://devtools/client/shared/redux"
@ -54,6 +60,13 @@ function BrowserLoader(baseURI, window) {
}
return require(uri);
},
globals: {
// Make sure 'define' function exists. This allows reusing AMD modules.
define: function(callback) {
callback(this.require, this.exports, this.module);
return this.exports;
}
}
};

View File

@ -6,7 +6,7 @@
// RequireJS
} else if (typeof define === "function" && define.amd) {
define(['react'], f);
define(['devtools/client/shared/vendor/react'], f);
// <script>
} else {