Bug 1224765 - add production version of React for devtools and use it in release modes r=fitzgen

This commit is contained in:
James Long 2016-01-19 16:55:06 -05:00
Родитель d558566d6f
Коммит 8b55567bdc
8 изменённых файлов: 21725 добавлений и 816 удалений

Просмотреть файл

@ -557,8 +557,24 @@ const resolveURI = iced(function resolveURI(id, mapping) {
while (index < count) {
let [ path, uri ] = mapping[index++];
if (id.indexOf(path) === 0)
// Strip off any trailing slashes to make comparisons simpler
let stripped = path.endsWith('/') ? path.slice(0, -1) : path;
// We only want to match path segments explicitly. Examples:
// * "foo/bar" matches for "foo/bar"
// * "foo/bar" matches for "foo/bar/baz"
// * "foo/bar" does not match for "foo/bar-1"
// * "foo/bar/" does not match for "foo/bar"
// * "foo/bar/" matches for "foo/bar/baz"
//
// Check for an empty path, an exact match, or a substring match
// with the next character being a forward slash.
if(stripped === "" ||
(id.indexOf(stripped) === 0 &&
(id.length === path.length || id[stripped.length] === '/'))) {
return normalizeExt(id.replace(path, uri));
}
}
return void 0; // otherwise we raise a warning, see bug 910304
});

Просмотреть файл

@ -387,6 +387,19 @@ exports["test require#resolve"] = function(assert) {
assert.equal(foundRoot + "sdk/tabs.js", require.resolve("sdk/tabs"), "correct resolution of sdk module");
assert.equal(foundRoot + "toolkit/loader.js", require.resolve("toolkit/loader"), "correct resolution of sdk module");
const localLoader = Loader({
paths: { "foo/bar": "bizzle",
"foo/bar2/": "bizzle2",
// Just to make sure this doesn't match the first entry,
// let use resolve this module
"foo/bar-bar": "foo/bar-bar" }
});
const localRequire = Require(localLoader, module);
assert.equal(localRequire.resolve("foo/bar"), "bizzle.js");
assert.equal(localRequire.resolve("foo/bar/baz"), "bizzle/baz.js");
assert.equal(localRequire.resolve("foo/bar-bar"), "foo/bar-bar.js");
assert.equal(localRequire.resolve("foo/bar2/"), "bizzle2.js");
};
const modulesURI = require.resolve("toolkit/loader").replace("toolkit/loader.js", "");

Просмотреть файл

@ -8,6 +8,8 @@ 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");
Cu.import("resource://gre/modules/AppConstants.jsm");
const BROWSER_BASED_DIRS = [
"resource://devtools/client/jsonview",
"resource://devtools/client/shared/vendor",
@ -42,12 +44,18 @@ const BROWSER_BASED_DIRS = [
*/
function BrowserLoader(baseURI, window) {
const loaderOptions = devtools.require("@loader/options");
const dynamicPaths = {};
if(AppConstants.DEBUG || AppConstants.DEBUG_JS_MODULES) {
dynamicPaths["devtools/client/shared/vendor/react"] =
"resource://devtools/client/shared/vendor/react-dev";
};
const opts = {
id: "browser-loader",
sharedGlobal: true,
sandboxPrototype: window,
paths: Object.assign({}, loaderOptions.paths),
paths: Object.assign({}, dynamicPaths, loaderOptions.paths),
invisibleToDebugger: loaderOptions.invisibleToDebugger,
require: (id, require) => {
const uri = require.resolve(id);

25
devtools/client/shared/vendor/REACT_UPGRADING поставляемый
Просмотреть файл

@ -1,24 +1,23 @@
React has a dev and prod version. The dev version includes additional
sanity checks and better errors, but at a slight perf cost. The prod
version available on the web is by default minified, but we don't want
a minified version, so we need to build it ourselves.
We have a version of React that has a few minor patches on top of it:
https://github.com/mozilla/react. These instructions are how to
upgrade to the latest version of React.
In bug 1217979, we are only using react in development environment for now until
we can think of a way to conditionally build these different versions, so
the `react.js` here is the dev environment one and generated with the following steps:
First, rebase our fork on top of the latest version and publish it to
our repo.
Next, build React. You should already have our fork locally; make sure
you are building our fork: https://github.com/mozilla/react
* git clone https://github.com/facebook/react.git && cd react
* npm install
* grunt build
* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react.js
* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react-dev.js
Note that the last command above adds a `react-dev.js` file. You also
need to generated a production version of React:
For production, which we do not currently have:
* NODE_ENV=production grunt build
* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react.js
The second build produces a non-minified React file but with all the
sanity checks that incur a perf hit removed.
You also need to copy the ReactDOM package. It requires React, so
right now we are just manually changing the path from `react` to
`devtools/client/shared/vendor/react`.

11
devtools/client/shared/vendor/moz.build поставляемый
Просмотреть файл

@ -4,10 +4,17 @@
# 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/.
DevToolsModules(
modules = []
if CONFIG['DEBUG_JS_MODULES'] or CONFIG['MOZ_DEBUG']:
modules += ['react-dev.js']
modules += [
'react-dom.js',
'react-redux.js',
'react.js',
'redux.js',
'seamless-immutable.js'
)
]
DevToolsModules(*modules)

20762
devtools/client/shared/vendor/react-dev.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

11
devtools/client/shared/vendor/react-dom.js поставляемый
Просмотреть файл

@ -1,3 +1,14 @@
/**
* ReactDOM v0.14.1
*
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
;(function(f) {
// CommonJS

1691
devtools/client/shared/vendor/react.js поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу