mirror of
https://github.com/facebook/react.git
synced 2026-02-24 20:53:03 +00:00
Fixed rollup UMD modules
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import semver from 'semver';
|
||||
|
||||
const React = window.React;
|
||||
|
||||
export function semverString (props, propName, componentName) {
|
||||
let version = props[propName];
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@ const bundles = [
|
||||
config: {
|
||||
destDir: 'build/',
|
||||
globals: {
|
||||
'prop-types': 'PropTypes',
|
||||
react: 'React',
|
||||
},
|
||||
moduleName: 'ReactDOM',
|
||||
@@ -102,7 +101,6 @@ const bundles = [
|
||||
config: {
|
||||
destDir: 'build/',
|
||||
globals: {
|
||||
'prop-types': 'PropTypes',
|
||||
react: 'React',
|
||||
},
|
||||
moduleName: 'ReactDOM',
|
||||
@@ -134,7 +132,6 @@ const bundles = [
|
||||
config: {
|
||||
destDir: 'build/',
|
||||
globals: {
|
||||
'prop-types': 'PropTypes',
|
||||
react: 'React',
|
||||
},
|
||||
moduleName: 'ReactDOMServer',
|
||||
|
||||
@@ -52,6 +52,17 @@ const devOnlyFilesToStubOut = [
|
||||
"'ReactTestUtils'",
|
||||
];
|
||||
|
||||
// Ordering of these imports is important;
|
||||
// The default import must follow deep imports or Rollup breaks.
|
||||
// eg 'prop-types/index.js/checkPropTypes.js'
|
||||
const legacyModules = {
|
||||
'create-react-class/factory': 'create-react-class/factory.js',
|
||||
'create-react-class': 'create-react-class/index.js',
|
||||
'prop-types/checkPropTypes': 'prop-types/checkPropTypes.js',
|
||||
'prop-types/factory': 'prop-types/factory.js',
|
||||
'prop-types': 'prop-types/index.js',
|
||||
};
|
||||
|
||||
// this function builds up a very niave Haste-like moduleMap
|
||||
// that works to create up an alias map for modules to link
|
||||
// up to their actual disk location so Rollup can properly
|
||||
@@ -230,6 +241,27 @@ function replaceDevOnlyStubbedModules(bundleType) {
|
||||
}
|
||||
}
|
||||
|
||||
function replaceLegacyModuleAliases(bundleType) {
|
||||
switch (bundleType) {
|
||||
case UMD_DEV:
|
||||
case UMD_PROD:
|
||||
const modulesAlias = {};
|
||||
for (var legacyModule in legacyModules) {
|
||||
modulesAlias[legacyModule] = resolve(
|
||||
`./node_modules/${legacyModules[legacyModule]}`
|
||||
);
|
||||
}
|
||||
return modulesAlias;
|
||||
case NODE_DEV:
|
||||
case NODE_PROD:
|
||||
case FB_DEV:
|
||||
case FB_PROD:
|
||||
case RN_DEV:
|
||||
case RN_PROD:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function getAliases(paths, bundleType, isRenderer, extractErrors) {
|
||||
return Object.assign(
|
||||
createModuleMap(
|
||||
@@ -247,7 +279,8 @@ function getDefaultReplaceModules(bundleType) {
|
||||
return Object.assign(
|
||||
{},
|
||||
replaceFbjsModuleAliases(bundleType),
|
||||
replaceDevOnlyStubbedModules(bundleType)
|
||||
replaceDevOnlyStubbedModules(bundleType),
|
||||
replaceLegacyModuleAliases(bundleType)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
"branch": "prop-types",
|
||||
"bundleSizes": {
|
||||
"react.development.js (UMD_DEV)": {
|
||||
"size": 76661,
|
||||
"gzip": 19565
|
||||
"size": 120940,
|
||||
"gzip": 30496
|
||||
},
|
||||
"react.production.min.js (UMD_PROD)": {
|
||||
"size": 10467,
|
||||
"gzip": 4074
|
||||
"size": 15685,
|
||||
"gzip": 5764
|
||||
},
|
||||
"react-dom.development.js (UMD_DEV)": {
|
||||
"size": 563910,
|
||||
"gzip": 130211
|
||||
"size": 583318,
|
||||
"gzip": 134555
|
||||
},
|
||||
"react-dom.production.min.js (UMD_PROD)": {
|
||||
"size": 120247,
|
||||
"gzip": 37891
|
||||
"size": 120740,
|
||||
"gzip": 38092
|
||||
},
|
||||
"react-dom-server.development.js (UMD_DEV)": {
|
||||
"size": 476115,
|
||||
"gzip": 115286
|
||||
"size": 495519,
|
||||
"gzip": 119683
|
||||
},
|
||||
"react-dom-server.production.min.js (UMD_PROD)": {
|
||||
"size": 106540,
|
||||
"gzip": 33071
|
||||
"size": 107033,
|
||||
"gzip": 33273
|
||||
},
|
||||
"react-art.development.js (UMD_DEV)": {
|
||||
"size": 339929,
|
||||
|
||||
Reference in New Issue
Block a user