Use aliasify everywhere instead of browserify-global-shim (#7476)
I already had to aliasify to have better control over the requires so we might as well do it everywhere for consistency. This probably makes it easier to rebase the rollup work too because aliases seems to be how you solve this in that world.
This commit is contained in:
parent
1c5a639c37
commit
c8f7215b20
|
@ -8,39 +8,18 @@ var UglifyJS = require('uglify-js');
|
|||
var uglifyify = require('uglifyify');
|
||||
var derequire = require('derequire');
|
||||
var aliasify = require('aliasify');
|
||||
var globalShim = require('browserify-global-shim');
|
||||
var collapser = require('bundle-collapser/plugin');
|
||||
|
||||
var envifyDev = envify({NODE_ENV: process.env.NODE_ENV || 'development'});
|
||||
var envifyProd = envify({NODE_ENV: process.env.NODE_ENV || 'production'});
|
||||
|
||||
var SECRET_INTERNALS_NAME = 'React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED';
|
||||
|
||||
var shimSharedModulesFiles = {
|
||||
'./ReactCurrentOwner': SECRET_INTERNALS_NAME + '.ReactCurrentOwner',
|
||||
'./ReactComponentTreeHook': SECRET_INTERNALS_NAME + '.ReactComponentTreeHook',
|
||||
// Use the global, anywhere we require React
|
||||
'./React': 'React',
|
||||
};
|
||||
|
||||
// We can access these as absolute or relative. We need to shim both.
|
||||
for (var key in shimSharedModulesFiles) {
|
||||
shimSharedModulesFiles[key.replace(/^\.\//, 'react/lib/')] = shimSharedModulesFiles[key];
|
||||
}
|
||||
|
||||
var shimSharedModules = globalShim.configure(shimSharedModulesFiles);
|
||||
|
||||
// Fiber needs the symbol from ReactElement right now. So we can't shim
|
||||
// ReactElement. Otherwise this would just be the same as above.
|
||||
// TODO: Refactor this so that Fiber can access the symbol without bringing in
|
||||
// the rest of ReactElement.
|
||||
var shimSharedModulesFiberFiles = {};
|
||||
for (var key in shimSharedModulesFiles) {
|
||||
if (!/ReactElement/.test(key)) {
|
||||
shimSharedModulesFiberFiles[key] = shimSharedModulesFiles[key];
|
||||
}
|
||||
}
|
||||
var shimSharedModulesFiber = globalShim.configure(shimSharedModulesFiberFiles);
|
||||
var shimSharedModules = aliasify.configure({
|
||||
'aliases': {
|
||||
'react/lib/React': 'react/lib/ReactUMDShim',
|
||||
'react/lib/ReactCurrentOwner': 'react/lib/ReactCurrentOwnerUMDShim',
|
||||
'react/lib/ReactComponentTreeHook': 'react/lib/ReactComponentTreeHookUMDShim',
|
||||
},
|
||||
});
|
||||
|
||||
var shimDOMModules = aliasify.configure({
|
||||
'aliases': {
|
||||
|
@ -219,7 +198,7 @@ var domFiber = {
|
|||
debug: false,
|
||||
standalone: 'ReactDOMFiber',
|
||||
// Apply as global transform so that we also envify fbjs and any other deps
|
||||
transforms: [shimSharedModulesFiber],
|
||||
transforms: [shimSharedModules],
|
||||
globalTransforms: [envifyDev],
|
||||
plugins: [collapser],
|
||||
after: [derequire, simpleBannerify],
|
||||
|
@ -234,7 +213,7 @@ var domFiberMin = {
|
|||
standalone: 'ReactDOMFiber',
|
||||
// Envify twice. The first ensures that when we uglifyify, we have the right
|
||||
// conditions to exclude requires. The global transform runs on deps.
|
||||
transforms: [shimSharedModulesFiber, envifyProd, uglifyify],
|
||||
transforms: [shimSharedModules, envifyProd, uglifyify],
|
||||
globalTransforms: [envifyProd],
|
||||
plugins: [collapser],
|
||||
// No need to derequire because the minifier will mangle
|
||||
|
|
|
@ -31,7 +31,7 @@ var paths = {
|
|||
src: [
|
||||
'src/umd/ReactUMDEntry.js',
|
||||
'src/umd/ReactWithAddonsUMDEntry.js',
|
||||
'src/umd/shims/ReactAddonsDOMDependenciesUMDShim.js',
|
||||
'src/umd/shims/**/*.js',
|
||||
|
||||
'src/isomorphic/**/*.js',
|
||||
'src/addons/**/*.js',
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
"babel-traverse": "^6.9.0",
|
||||
"babylon": "6.8.0",
|
||||
"browserify": "^13.0.0",
|
||||
"browserify-global-shim": "^1.0.3",
|
||||
"bundle-collapser": "^1.1.1",
|
||||
"coffee-script": "^1.8.0",
|
||||
"core-js": "^2.2.1",
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Copyright 2013-present, 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.
|
||||
*
|
||||
* @providesModule ReactComponentTreeHookUMDShim
|
||||
*/
|
||||
|
||||
/* globals React */
|
||||
|
||||
'use strict';
|
||||
|
||||
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
||||
module.exports = ReactInternals.ReactComponentTreeHook;
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Copyright 2013-present, 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.
|
||||
*
|
||||
* @providesModule ReactCurrentOwnerUMDShim
|
||||
*/
|
||||
|
||||
/* globals React */
|
||||
|
||||
'use strict';
|
||||
|
||||
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
||||
module.exports = ReactInternals.ReactCurrentOwner;
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright 2013-present, 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.
|
||||
*
|
||||
* @providesModule ReactUMDShim
|
||||
*/
|
||||
|
||||
/* globals React */
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = React;
|
Loading…
Reference in New Issue