2017-04-05 23:47:29 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const resolve = require('path').resolve;
|
|
|
|
|
const basename = require('path').basename;
|
|
|
|
|
const sync = require('glob').sync;
|
|
|
|
|
const bundleTypes = require('./bundles').bundleTypes;
|
2017-10-12 02:29:26 +08:00
|
|
|
const moduleTypes = require('./bundles').moduleTypes;
|
2017-04-05 23:47:29 +08:00
|
|
|
const extractErrorCodes = require('../error-codes/extract-errors');
|
|
|
|
|
|
|
|
|
|
const exclude = [
|
2017-10-19 07:22:21 +08:00
|
|
|
'**/__benchmarks__/**/*.js',
|
|
|
|
|
'**/__tests__/**/*.js',
|
|
|
|
|
'**/__mocks__/**/*.js',
|
2017-04-05 23:47:29 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const UMD_DEV = bundleTypes.UMD_DEV;
|
|
|
|
|
const UMD_PROD = bundleTypes.UMD_PROD;
|
|
|
|
|
const NODE_DEV = bundleTypes.NODE_DEV;
|
|
|
|
|
const NODE_PROD = bundleTypes.NODE_PROD;
|
|
|
|
|
const FB_DEV = bundleTypes.FB_DEV;
|
|
|
|
|
const FB_PROD = bundleTypes.FB_PROD;
|
|
|
|
|
const RN_DEV = bundleTypes.RN_DEV;
|
|
|
|
|
const RN_PROD = bundleTypes.RN_PROD;
|
|
|
|
|
|
2017-10-12 02:29:26 +08:00
|
|
|
const ISOMORPHIC = moduleTypes.ISOMORPHIC;
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-20 02:50:24 +08:00
|
|
|
const RENDERER = moduleTypes.RENDERER;
|
2017-10-12 02:29:26 +08:00
|
|
|
|
2017-04-05 23:47:29 +08:00
|
|
|
const errorCodeOpts = {
|
|
|
|
|
errorMapFilePath: 'scripts/error-codes/codes.json',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// these are the FBJS modules that are used throughout our bundles
|
|
|
|
|
const fbjsModules = [
|
|
|
|
|
'fbjs/lib/warning',
|
|
|
|
|
'fbjs/lib/invariant',
|
|
|
|
|
'fbjs/lib/emptyFunction',
|
|
|
|
|
'fbjs/lib/emptyObject',
|
|
|
|
|
'fbjs/lib/hyphenateStyleName',
|
|
|
|
|
'fbjs/lib/getUnboundedScrollPosition',
|
|
|
|
|
'fbjs/lib/camelizeStyleName',
|
|
|
|
|
'fbjs/lib/containsNode',
|
|
|
|
|
'fbjs/lib/shallowEqual',
|
|
|
|
|
'fbjs/lib/getActiveElement',
|
|
|
|
|
'fbjs/lib/focusNode',
|
|
|
|
|
'fbjs/lib/EventListener',
|
|
|
|
|
'fbjs/lib/memoizeStringOnly',
|
|
|
|
|
'fbjs/lib/ExecutionEnvironment',
|
|
|
|
|
'fbjs/lib/createNodesFromMarkup',
|
|
|
|
|
'fbjs/lib/performanceNow',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const devOnlyFilesToStubOut = [
|
2017-04-08 00:03:22 +08:00
|
|
|
"'ReactDebugCurrentFrame'",
|
2017-04-05 23:47:29 +08:00
|
|
|
"'ReactComponentTreeHook'",
|
2017-04-08 05:07:10 +08:00
|
|
|
"'ReactPerf'",
|
|
|
|
|
"'ReactTestUtils'",
|
2017-04-05 23:47:29 +08:00
|
|
|
];
|
|
|
|
|
|
2017-04-12 05:28:03 +08:00
|
|
|
const legacyModules = [
|
|
|
|
|
'create-react-class',
|
|
|
|
|
'create-react-class/factory',
|
|
|
|
|
'prop-types',
|
|
|
|
|
'prop-types/checkPropTypes',
|
|
|
|
|
];
|
|
|
|
|
|
2017-04-05 23:47:29 +08:00
|
|
|
// 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
|
|
|
|
|
// bundle them
|
|
|
|
|
function createModuleMap(paths, extractErrors, bundleType) {
|
|
|
|
|
const moduleMap = {};
|
|
|
|
|
|
|
|
|
|
paths.forEach(path => {
|
2017-04-06 03:24:30 +08:00
|
|
|
const files = sync(path, {ignore: exclude});
|
2017-04-05 23:47:29 +08:00
|
|
|
|
|
|
|
|
files.forEach(file => {
|
|
|
|
|
if (extractErrors) {
|
|
|
|
|
extractErrors(file);
|
|
|
|
|
}
|
|
|
|
|
const moduleName = basename(file, '.js');
|
|
|
|
|
|
|
|
|
|
moduleMap[moduleName] = resolve(file);
|
|
|
|
|
});
|
|
|
|
|
});
|
2017-05-27 01:35:39 +08:00
|
|
|
// if this is FB, we want to remove ReactCurrentOwner and lowPriorityWarning,
|
|
|
|
|
// so we can handle it with a different case
|
2017-04-05 23:47:29 +08:00
|
|
|
if (bundleType === FB_DEV || bundleType === FB_PROD) {
|
|
|
|
|
delete moduleMap.ReactCurrentOwner;
|
2017-05-27 01:35:39 +08:00
|
|
|
delete moduleMap.lowPriorityWarning;
|
2017-04-05 23:47:29 +08:00
|
|
|
}
|
|
|
|
|
return moduleMap;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 02:29:26 +08:00
|
|
|
function getNodeModules(bundleType, moduleType) {
|
2017-04-05 23:47:29 +08:00
|
|
|
// rather than adding the rollup node resolve plugin,
|
|
|
|
|
// we can instead deal with the only node module that is used
|
|
|
|
|
// for UMD bundles - object-assign
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case UMD_DEV:
|
|
|
|
|
case UMD_PROD:
|
|
|
|
|
return {
|
2017-09-12 02:22:59 +08:00
|
|
|
// Bundle object-assign once in the isomorphic React, and then use
|
|
|
|
|
// that from the renderer UMD. Avoids bundling it in both UMDs.
|
2017-10-12 02:29:26 +08:00
|
|
|
'object-assign': moduleType === ISOMORPHIC
|
|
|
|
|
? resolve('./node_modules/object-assign/index.js')
|
|
|
|
|
: resolve('./scripts/rollup/shims/rollup/assign.js'),
|
2017-04-05 23:47:29 +08:00
|
|
|
// include the ART package modules directly by aliasing them from node_modules
|
|
|
|
|
'art/modes/current': resolve('./node_modules/art/modes/current.js'),
|
|
|
|
|
'art/modes/fast-noSideEffects': resolve(
|
|
|
|
|
'./node_modules/art/modes/fast-noSideEffects.js'
|
|
|
|
|
),
|
|
|
|
|
'art/core/transform': resolve('./node_modules/art/core/transform.js'),
|
|
|
|
|
};
|
|
|
|
|
case NODE_DEV:
|
|
|
|
|
case NODE_PROD:
|
|
|
|
|
case FB_DEV:
|
|
|
|
|
case FB_PROD:
|
|
|
|
|
case RN_DEV:
|
|
|
|
|
case RN_PROD:
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ignoreFBModules() {
|
|
|
|
|
return [
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-20 02:50:24 +08:00
|
|
|
// These are FB-specific aliases to react and react-dom.
|
|
|
|
|
// Don't attempt to bundle them into other bundles.
|
|
|
|
|
'React',
|
|
|
|
|
'ReactDOM',
|
2017-04-05 23:47:29 +08:00
|
|
|
// At FB, we don't know them statically:
|
|
|
|
|
'ReactFeatureFlags',
|
|
|
|
|
// In FB bundles, we preserve an inline require to ReactCurrentOwner.
|
|
|
|
|
// See the explanation in FB version of ReactCurrentOwner in www:
|
|
|
|
|
'ReactCurrentOwner',
|
2017-05-27 01:35:39 +08:00
|
|
|
'lowPriorityWarning',
|
2017-04-05 23:47:29 +08:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ignoreReactNativeModules() {
|
|
|
|
|
return [
|
2017-08-18 23:26:11 +08:00
|
|
|
// This imports NativeMethodsMixin, causing a circular dependency.
|
2017-04-05 23:47:29 +08:00
|
|
|
'View',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 02:29:26 +08:00
|
|
|
function getExternalModules(externals, bundleType, moduleType) {
|
2017-04-05 23:47:29 +08:00
|
|
|
// external modules tell Rollup that we should not attempt
|
|
|
|
|
// to bundle these modules and instead treat them as
|
2017-09-27 18:13:21 +08:00
|
|
|
// external dependencies to the bundle. so for CJS bundles
|
2017-04-05 23:47:29 +08:00
|
|
|
// this means having a require("name-of-external-module") at
|
|
|
|
|
// the top of the bundle. for UMD bundles this means having
|
|
|
|
|
// both a require and a global check for them
|
2017-09-14 08:24:31 +08:00
|
|
|
let externalModules = externals.slice();
|
2017-04-05 23:47:29 +08:00
|
|
|
switch (bundleType) {
|
|
|
|
|
case UMD_DEV:
|
|
|
|
|
case UMD_PROD:
|
2017-10-12 02:29:26 +08:00
|
|
|
if (moduleType !== ISOMORPHIC) {
|
2017-04-05 23:47:29 +08:00
|
|
|
externalModules.push('react');
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NODE_DEV:
|
|
|
|
|
case NODE_PROD:
|
|
|
|
|
case RN_DEV:
|
|
|
|
|
case RN_PROD:
|
|
|
|
|
fbjsModules.forEach(module => externalModules.push(module));
|
|
|
|
|
externalModules.push('object-assign');
|
2017-10-12 02:29:26 +08:00
|
|
|
if (moduleType !== ISOMORPHIC) {
|
2017-04-05 23:47:29 +08:00
|
|
|
externalModules.push('react');
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FB_DEV:
|
|
|
|
|
case FB_PROD:
|
|
|
|
|
fbjsModules.forEach(module => externalModules.push(module));
|
2017-09-14 08:24:31 +08:00
|
|
|
externalModules.push('object-assign');
|
2017-04-08 05:07:10 +08:00
|
|
|
externalModules.push('ReactCurrentOwner');
|
Downgrade deprecation warnings from errors to warnings (#9650)
* Initial regeneration of results.json
**what is the change?:**
We ran `yarn build` and updated the perf. stats record.
**why make this change?:**
Some commits have landed without updating this. By getting an initial update, I can run the build script again after my changes and see any size regressions.
* Downgrade deprecation warnings from errors to warnings
**what is the change?:**
Swapping out `warning` module for a fork that uses `console.warn`.
It looks like we were using the `warning` module for deprecation notices, *but* there is also a 'deprecated' module designed specifically for deprecation notices.
However, we could not find any place that it was currently used.
Since React's build process is not 100% clear to me, I assume it could still be used somewhere by something and just updated it along with other deprecation notices.
We might consider a follow-up diff that does some clean up here;
- remove 'deprecated' module if it's unused, OR
- use 'deprecated' module for all our current deprecation warnings
**why make this change?:**
- We have had complaints about noisy warnings, in particular after introducing new deprecations
- They potentially cause CI failures
- Deprecations are not really time-sensitive, can ship without breaking your app, etc.
For more context - https://github.com/facebook/react/issues/9395
**test plan:**
`npm run test`
and unit tests for the new modules
and manual testing (WIP)
**issue:**
https://github.com/facebook/react/issues/9395
* Add 'lowPriorityWarning' to ReactExternals
**what is the change?:**
We won't bundle 'lowPriorityWarning' with the rest of React when building for Facebook.
NOTE: A parallel commit will introduce an internal implementation of 'lowPriorityWarning' in Facebook's codebase, to compensate. Will post a comment with the diff number once that is up.
**why make this change?:**
So that the sync between github and Facebook can go more smoothly!
**test plan:**
We will see when I run the sync! But this is a reasonable first step imo.
**issue:**
https://github.com/facebook/react/issues/9398
* Make state mutations an error, not low-pri warning
**what is the change?:**
Even though this is a "deprecation" warning, we still want to use 'console.error' for it.
**why make this change?:**
- It's not likely to come up now, hopefully, because this warning has been present for some time
- This will cause real issues in production if ignored
**test plan:**
`yarn test` - we did fix one test which failed bc of this change
**issue:**
https://github.com/facebook/react/issues/9398
* Fix test of assigning to this.state that was only passing in fiber
**what is the change?:**
updated a unit test for assigning directly to state; it once again raises an error and not a warning.
**why make this change?:**
So that tests pass
**test plan:**
REACT_DOM_JEST_USE_FIBER=1 yarn run test
**issue:**
* Update results.json
2017-05-24 00:35:42 +08:00
|
|
|
externalModules.push('lowPriorityWarning');
|
2017-10-12 02:29:26 +08:00
|
|
|
if (moduleType !== ISOMORPHIC) {
|
2017-04-05 23:47:29 +08:00
|
|
|
externalModules.push('React');
|
2017-04-27 09:10:19 +08:00
|
|
|
if (externalModules.indexOf('react-dom') > -1) {
|
2017-04-27 09:07:53 +08:00
|
|
|
externalModules.push('ReactDOM');
|
|
|
|
|
}
|
2017-04-05 23:47:29 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return externalModules;
|
|
|
|
|
}
|
|
|
|
|
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-20 02:50:24 +08:00
|
|
|
function getInternalModules(moduleType) {
|
2017-04-05 23:47:29 +08:00
|
|
|
// we tell Rollup where these files are located internally, otherwise
|
|
|
|
|
// it doesn't pick them up and assumes they're external
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-20 02:50:24 +08:00
|
|
|
let aliases = {
|
2017-10-20 19:59:57 +08:00
|
|
|
reactProdInvariant: resolve('./packages/shared/reactProdInvariant.js'),
|
2017-04-05 23:47:29 +08:00
|
|
|
};
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-20 02:50:24 +08:00
|
|
|
if (moduleType === RENDERER) {
|
|
|
|
|
// Renderers bundle the whole reconciler.
|
|
|
|
|
aliases['react-reconciler'] = resolve(
|
|
|
|
|
'./packages/react-reconciler/index.js'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return aliases;
|
2017-04-05 23:47:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFbjsModuleAliases(bundleType) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case UMD_DEV:
|
|
|
|
|
case UMD_PROD:
|
|
|
|
|
// we want to bundle these modules, so we re-alias them to the actual
|
|
|
|
|
// file so Rollup can bundle them up
|
|
|
|
|
const fbjsModulesAlias = {};
|
|
|
|
|
fbjsModules.forEach(fbjsModule => {
|
|
|
|
|
fbjsModulesAlias[fbjsModule] = resolve(`./node_modules/${fbjsModule}`);
|
|
|
|
|
});
|
|
|
|
|
return fbjsModulesAlias;
|
|
|
|
|
case NODE_DEV:
|
|
|
|
|
case NODE_PROD:
|
|
|
|
|
case FB_DEV:
|
|
|
|
|
case FB_PROD:
|
|
|
|
|
case RN_DEV:
|
|
|
|
|
case RN_PROD:
|
|
|
|
|
// for FB we don't want to bundle the above modules, instead keep them
|
|
|
|
|
// as external require() calls in the bundle
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function replaceFbjsModuleAliases(bundleType) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case FB_DEV:
|
|
|
|
|
case FB_PROD:
|
2017-04-08 05:07:10 +08:00
|
|
|
// Haste at FB doesn't currently allow case sensitive names,
|
|
|
|
|
// and product code already uses "React". In the future,
|
|
|
|
|
// we will either allow both variants or migrate to lowercase.
|
2017-04-05 23:47:29 +08:00
|
|
|
return {
|
|
|
|
|
"'react'": "'React'",
|
2017-04-26 04:30:48 +08:00
|
|
|
"'react-dom'": "'ReactDOM'",
|
2017-04-05 23:47:29 +08:00
|
|
|
};
|
2017-04-08 05:07:10 +08:00
|
|
|
default:
|
|
|
|
|
return {};
|
2017-04-08 00:03:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 23:47:29 +08:00
|
|
|
const devOnlyModuleStub = `'${resolve('./scripts/rollup/shims/rollup/DevOnlyStubShim.js')}'`;
|
|
|
|
|
|
|
|
|
|
function replaceDevOnlyStubbedModules(bundleType) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case UMD_DEV:
|
|
|
|
|
case NODE_DEV:
|
|
|
|
|
case FB_DEV:
|
|
|
|
|
case RN_DEV:
|
|
|
|
|
case RN_PROD:
|
|
|
|
|
return {};
|
|
|
|
|
case FB_PROD:
|
|
|
|
|
case UMD_PROD:
|
|
|
|
|
case NODE_PROD:
|
|
|
|
|
const devOnlyModuleAliases = {};
|
|
|
|
|
devOnlyFilesToStubOut.forEach(devOnlyModule => {
|
|
|
|
|
devOnlyModuleAliases[devOnlyModule] = devOnlyModuleStub;
|
|
|
|
|
});
|
|
|
|
|
return devOnlyModuleAliases;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-12 05:28:03 +08:00
|
|
|
function replaceLegacyModuleAliases(bundleType) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case UMD_DEV:
|
|
|
|
|
case UMD_PROD:
|
|
|
|
|
const modulesAlias = {};
|
|
|
|
|
legacyModules.forEach(legacyModule => {
|
|
|
|
|
const modulePath = legacyModule.includes('/')
|
|
|
|
|
? legacyModule
|
|
|
|
|
: `${legacyModule}/index`;
|
|
|
|
|
const resolvedPath = resolve(`./node_modules/${modulePath}`);
|
|
|
|
|
modulesAlias[`'${legacyModule}'`] = `'${resolvedPath}'`;
|
|
|
|
|
});
|
|
|
|
|
return modulesAlias;
|
|
|
|
|
case NODE_DEV:
|
|
|
|
|
case NODE_PROD:
|
|
|
|
|
case FB_DEV:
|
|
|
|
|
case FB_PROD:
|
|
|
|
|
case RN_DEV:
|
|
|
|
|
case RN_PROD:
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 01:14:46 +08:00
|
|
|
function replaceBundleStubModules(bundleModulesToStub) {
|
|
|
|
|
const stubbedModules = {};
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(bundleModulesToStub)) {
|
|
|
|
|
bundleModulesToStub.forEach(module => {
|
2017-07-19 23:28:55 +08:00
|
|
|
stubbedModules[`'${module}'`] = devOnlyModuleStub;
|
2017-05-26 01:14:46 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return stubbedModules;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 02:29:26 +08:00
|
|
|
function getAliases(paths, bundleType, moduleType, extractErrors) {
|
2017-04-05 23:47:29 +08:00
|
|
|
return Object.assign(
|
|
|
|
|
createModuleMap(
|
|
|
|
|
paths,
|
|
|
|
|
extractErrors && extractErrorCodes(errorCodeOpts),
|
|
|
|
|
bundleType
|
|
|
|
|
),
|
Reorganize code structure (#11288)
* Move files and tests to more meaningful places
* Fix the build
Now that we import reconciler via react-reconciler, I needed to make a few tweaks.
* Update sizes
* Move @preventMunge directive to FB header
* Revert unintentional change
* Fix Flow coverage
I forgot to @flow-ify those files. This uncovered some issues.
* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down
Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime
Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink
Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out
Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown
And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right
And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-20 02:50:24 +08:00
|
|
|
getInternalModules(moduleType),
|
2017-10-12 02:29:26 +08:00
|
|
|
getNodeModules(bundleType, moduleType),
|
2017-04-05 23:47:29 +08:00
|
|
|
getFbjsModuleAliases(bundleType)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-19 01:40:52 +08:00
|
|
|
function replaceFeatureFlags(featureFlags) {
|
|
|
|
|
if (!featureFlags) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
"'ReactFeatureFlags'": `'${resolve(featureFlags)}'`,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDefaultReplaceModules(
|
|
|
|
|
bundleType,
|
|
|
|
|
bundleModulesToStub,
|
|
|
|
|
featureFlags
|
|
|
|
|
) {
|
2017-04-05 23:47:29 +08:00
|
|
|
return Object.assign(
|
|
|
|
|
{},
|
|
|
|
|
replaceFbjsModuleAliases(bundleType),
|
2017-04-12 05:28:03 +08:00
|
|
|
replaceDevOnlyStubbedModules(bundleType),
|
2017-05-26 01:14:46 +08:00
|
|
|
replaceLegacyModuleAliases(bundleType),
|
2017-10-19 01:40:52 +08:00
|
|
|
replaceBundleStubModules(bundleModulesToStub),
|
|
|
|
|
replaceFeatureFlags(featureFlags)
|
2017-04-05 23:47:29 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-06 02:51:19 +08:00
|
|
|
function getExcludedHasteGlobs() {
|
|
|
|
|
return exclude;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 23:47:29 +08:00
|
|
|
module.exports = {
|
2017-04-06 02:51:19 +08:00
|
|
|
getExcludedHasteGlobs,
|
2017-04-05 23:47:29 +08:00
|
|
|
getDefaultReplaceModules,
|
|
|
|
|
getAliases,
|
|
|
|
|
ignoreFBModules,
|
|
|
|
|
ignoreReactNativeModules,
|
|
|
|
|
getExternalModules,
|
|
|
|
|
};
|