mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Convert current build system to Rollup and adopt flat bundles (#9327)
* WIP * fbjs support * WIP * dev/prod mode WIP * More WIP * builds a cjs bundle * adding forwarding modules * more progress on forwarding modules and FB config * improved how certain modules get inlined for fb and cjs * more forwarding modules * added comments to the module aliasing code * made ReactPerf and ReactTestUtils bundle again * Use -core suffix for all bundles This makes it easier to override things in www. * Add a lazy shim for ReactPerf This prevents a circular dependency between ReactGKJSModule and ReactDOM * Fix forwarding module for ReactCurrentOwner * Revert "Add a lazy shim for ReactPerf" This reverts commit 723b402c07116a70ce8ff1e43a1f4d92052e8f43. * Rename -core suffix to -fb for clarity * Change forwarding modules to import from -fb This is another, more direct fix for ReactPerf circular dependency * should fix fb and cjs bundles for ReactCurrentOwner * added provides module for ReactCurrentOwner * should improve console output * fixed typo with argument passing on functon call * Revert "should improve console output" This breaks the FB bundles. This reverts commit 65f11ee64f678c387cb3cfef9a8b28b89a6272b9. * Work around internal FB transform require() issue * moved ReactInstanceMap out of React and into ReactDOM and ReactDOMFiber * Expose more internal modules to www * Add missing modules to Stack ReactDOM to fix UFI * Fix onlyChild module * improved the build tool * Add a rollup npm script * Rename ReactDOM-fb to ReactDOMStack-fb * Fix circular dependencies now that ReactDOM-fb is a GK switch * Revert "Work around internal FB transform require() issue" This reverts commit 0a50b6a90bffc59f8f5416ef36000b5e3a44d253. * Bump rollup-plugin-commonjs to include a fix for rollup/rollup-plugin-commonjs#176 * Add more forwarding modules that are used on www * Add even more forwarding modules that are used on www * Add DOMProperty to hidden exports * Externalize feature flags This lets www specify them dynamically. * Remove forwarding modules with implementations Instead I'm adding them to react-fb in my diff. * Add all injection necessary for error logging * Add missing forwarding module (oops) * Add ReactART builds * Add ReactDOMServer bundle * Fix UMD build of ReactDOMFiber * Work in progress: start adding ReactNative bundle * tidied up the options for bundles, so they can define what types they output and exclude * Add a working RN build * further improved and tidied up build process * improved how bundles are built by exposing externals and making the process less "magical", also tidied up code and added more comments * better handling of bundling ReactCurrentOwner and accessing it from renderer modules * added NODE_DEV and NODE_PROD * added NPM package creation and copying into build chain * Improved UMD bundles, added better fixture testing and doc plus prod builds * updated internal modules (WIP) * removed all react/lib/* dependencies from appearing in bundles created on build * added react-test-renderer bundles * renamed bundles and paths * fixed fixture path changes * added extract-errors support * added extractErrors warning * moved shims to shims directory in rollup scripts * changed pathing to use build rather than build/rollup * updated release doc to reflect some rollup changes * Updated ReactNative findNodeHandle() to handle number case (#9238) * Add dynamic injection to ReactErrorUtils (#9246) * Fix ReactErrorUtils injection (#9247) * Fix Haste name * Move files around * More descriptive filenames * Add missing ReactErrorUtils shim * Tweak reactComponentExpect to make it standalone-ish in www * Unflowify shims * facebook-www shims now get copied over correctly to build * removed unnecessary resolve * building facebook-www/build is now all sync to prevent IO issues plus handles extra facebook-www src assets * removed react-native-renderer package and made build make a react-native build dir instead * 😭😭😭 * Add more SSR unit tests for elements and children. (#9221) * Adding more SSR unit tests for elements and children. * Some of my SSR tests were testing for react-text and react-empty elements that no longer exist in Fiber. Fixed the tests so that they expect correct markup in Fiber. * Tweaked some test names after @gaearon review comment https://github.com/facebook/react/pull/9221#discussion_r107045673 . Also realized that one of the tests was essentially a direct copy of another, so deleted it. * Responding to code review https://github.com/facebook/react/pull/9221#pullrequestreview-28996315 . Thanks @spicyj! * ReactElementValidator uses temporary ReactNative View propTypes getter (#9256) * Updating packages for 16.0.0-alpha.6 release * Revert "😭😭😭" This reverts commit 7dba33b2cfc67246881f6d57633a80e628ea05ec. * Work around Jest issue with CurrentOwner shared state in www * updated error codes * splits FB into FB_DEV and FB_PROD * Remove deps on specific builds from shims * should no longer mangle FB_PROD output * Added init() dev block to ReactTestUtils * added shims for DEV only code so it does not get included in prod bundles * added a __DEV__ wrapping code to FB_DEV * added __DEV__ flag behind a footer/header * Use right haste names * keeps comments in prod * added external babel helpers plugin * fixed fixtures and updated cjs/umd paths * Fixes Jest so it run tests correctly * fixed an issue with stubbed modules not properly being replaced due to greedy replacement * added a WIP solution for ReactCurrentOwner on FB DEV * adds a FB_TEST bundle * allows both ReactCurrentOwner and react/lib/ReactCurrentOwner * adds -test to provides module name * Remove TEST env * Ensure requires stay at the top * added basic mangle support (disbaled by default) * per bundle property mangling added * moved around plugin order to try and fix deadcode requires as per https://github.com/rollup/rollup/issues/855 * Fix flow issues * removed gulp and grunt and moved tasks to standalone node script * configured circleci to use new paths * Fix lint * removed gulp-extract-errors * added test_build.sh back in * added missing newline to flow.js * fixed test coverage command * changed permissions on test_build.sh * fixed test_html_generations.sh * temp removed html render test * removed the warning output from test_build, the build should do this instead * fixed test_build * fixed broken npm script * Remove unused ViewportMetrics shim * better error output * updated circleci to node 7 for async/await * Fixes * removed coverage test from circleci run * circleci run tets * removed build from circlci * made a dedicated jest script in a new process * moved order around of circlci tasks * changing path to jest in more circleci tests * re-enabled code coverage * Add file header to prod bundles * Remove react-dom/server.js (WIP: decide on the plan) * Only UMD bundles need version header * Merge with master * disabled const evaluation by uglify for <script></script> string literal * deal with ART modules for UMD bundles * improved how bundle output gets printed * fixed filesize difference reporting * added filesize dep * Update yarn lockfile for some reason * now compares against the last run branch built on * added react-dom-server * removed un-needed comment * results only get saved on full builds * moved the rollup sized plugin into a plugins directory * added a missing commonjs() * fixed missing ignore * Hack around to fix RN bundle * Partially fix RN bundles * added react-art bundle and a fixture for it * Point UMD bundle to Fiber and add EventPluginHub to exported internals * Make it build on Node 4 * fixed eslint error with resolve being defined in outer scope * Tweak how build results are calculated and stored * Tweak fixtures build to work on Node 4 * Include LICENSE/PATENTS and fix up package.json files * Add Node bundle for react-test-renderer * Revert "Hack around to fix RN bundle" We'll do this later. This reverts commit 59445a625962d7be4c7c3e98defc8a31f8761ec1. * Revert more RN changes We'll do them separately later * Revert more unintentional changes * Revert changes to error codes * Add accidentally deleted RN externals * added RN_DEV/RN_PROD bundles * fixed typo where RN_DEV and RN_PROD were the wrong way around * Delete/ignore fixture build outputs * Format scripts/ with Prettier * tidied up the Rollup build process and split functions into various different files to improve readability * Copy folder before files * updated yarn.lock * updated results and yarn dependencies to the latest versions
This commit is contained in:
parent
d99b3fc6d6
commit
4b2eac3de7
5
.babelrc
5
.babelrc
|
|
@ -19,10 +19,7 @@
|
|||
"transform-es2015-parameters",
|
||||
["transform-es2015-destructuring", { "loose": true }],
|
||||
["transform-es2015-block-scoping", { "throwIfClosureRequired": true }],
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-es3-member-expression-literals",
|
||||
"transform-es3-property-literals",
|
||||
"./scripts/babel/transform-object-assign-require",
|
||||
"transform-react-jsx-source"
|
||||
"transform-es3-property-literals"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
<PROJECT_ROOT>/fixtures/.*
|
||||
<PROJECT_ROOT>/build/.*
|
||||
<PROJECT_ROOT>/scripts/.*
|
||||
<PROJECT_ROOT>/.*/node_modules/y18n/.*
|
||||
<PROJECT_ROOT>/.*/__mocks__/.*
|
||||
<PROJECT_ROOT>/.*/__tests__/.*
|
||||
|
|
|
|||
202
Gruntfile.js
202
Gruntfile.js
|
|
@ -1,202 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var GULP_EXE = 'gulp';
|
||||
if (process.platform === 'win32') {
|
||||
GULP_EXE += '.cmd';
|
||||
}
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
browserify: require('./grunt/config/browserify'),
|
||||
npm: require('./grunt/config/npm'),
|
||||
clean: [
|
||||
'./build',
|
||||
'./*.gem',
|
||||
'./docs/_site',
|
||||
'./examples/shared/*.js',
|
||||
'.module-cache',
|
||||
],
|
||||
'compare_size': require('./grunt/config/compare_size'),
|
||||
});
|
||||
|
||||
function spawnGulp(args, opts, done) {
|
||||
|
||||
grunt.util.spawn({
|
||||
// This could be more flexible (require.resolve & lookup bin in package)
|
||||
// but if it breaks we'll fix it then.
|
||||
cmd: path.join('node_modules', '.bin', GULP_EXE),
|
||||
args: args,
|
||||
opts: Object.assign({stdio: 'inherit'}, opts),
|
||||
}, function(err, result, code) {
|
||||
if (err) {
|
||||
grunt.fail.fatal('Something went wrong running gulp: ', result);
|
||||
}
|
||||
done(code === 0);
|
||||
});
|
||||
}
|
||||
|
||||
Object.keys(grunt.file.readJSON('package.json').devDependencies)
|
||||
.filter(function(npmTaskName) {
|
||||
return npmTaskName.indexOf('grunt-') === 0;
|
||||
})
|
||||
.filter(function(npmTaskName) {
|
||||
return npmTaskName !== 'grunt-cli';
|
||||
})
|
||||
.forEach(function(npmTaskName) {
|
||||
grunt.loadNpmTasks(npmTaskName);
|
||||
});
|
||||
|
||||
grunt.registerTask('eslint', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['eslint'], null, this.async());
|
||||
});
|
||||
|
||||
grunt.registerTask('lint', ['eslint']);
|
||||
|
||||
grunt.registerTask('flow', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['flow'], null, this.async());
|
||||
});
|
||||
|
||||
grunt.registerTask('delete-build-modules', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['react:clean'], null, this.async());
|
||||
});
|
||||
|
||||
// Our own browserify-based tasks to build a single JS file build.
|
||||
grunt.registerMultiTask('browserify', require('./grunt/tasks/browserify'));
|
||||
|
||||
grunt.registerMultiTask('npm', require('./grunt/tasks/npm'));
|
||||
|
||||
var npmReactTasks = require('./grunt/tasks/npm-react');
|
||||
grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
|
||||
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
|
||||
|
||||
var npmReactDOMTasks = require('./grunt/tasks/npm-react-dom');
|
||||
grunt.registerTask('npm-react-dom:release', npmReactDOMTasks.buildRelease);
|
||||
grunt.registerTask('npm-react-dom:pack', npmReactDOMTasks.packRelease);
|
||||
|
||||
var npmReactNativeTasks = require('./grunt/tasks/npm-react-native');
|
||||
grunt.registerTask('npm-react-native:release', npmReactNativeTasks.buildRelease);
|
||||
grunt.registerTask('npm-react-native:pack', npmReactNativeTasks.packRelease);
|
||||
|
||||
var npmReactTestRendererTasks = require('./grunt/tasks/npm-react-test');
|
||||
grunt.registerTask('npm-react-test:release', npmReactTestRendererTasks.buildRelease);
|
||||
grunt.registerTask('npm-react-test:pack', npmReactTestRendererTasks.packRelease);
|
||||
|
||||
var npmReactNoopRendererTasks = require('./grunt/tasks/npm-react-noop');
|
||||
grunt.registerTask('npm-react-noop:release', npmReactNoopRendererTasks.buildRelease);
|
||||
grunt.registerTask('npm-react-noop:pack', npmReactNoopRendererTasks.packRelease);
|
||||
|
||||
grunt.registerTask('version-check', function() {
|
||||
// Use gulp here.
|
||||
spawnGulp(['version-check'], null, this.async());
|
||||
});
|
||||
|
||||
grunt.registerTask('build:basic', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:basic',
|
||||
]);
|
||||
grunt.registerTask('build:min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:min',
|
||||
]);
|
||||
grunt.registerTask('build:dom', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:dom',
|
||||
]);
|
||||
grunt.registerTask('build:dom-min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domMin',
|
||||
]);
|
||||
grunt.registerTask('build:dom-server', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domServer',
|
||||
]);
|
||||
grunt.registerTask('build:dom-server-min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domServerMin',
|
||||
]);
|
||||
grunt.registerTask('build:dom-fiber', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domFiber',
|
||||
]);
|
||||
grunt.registerTask('build:dom-fiber-min', [
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:domFiberMin',
|
||||
]);
|
||||
grunt.registerTask('build:npm-react', [
|
||||
'version-check',
|
||||
'build-modules',
|
||||
'npm-react:release',
|
||||
]);
|
||||
|
||||
var jestTasks = require('./grunt/tasks/jest');
|
||||
grunt.registerTask('jest:normal', jestTasks.normal);
|
||||
grunt.registerTask('jest:coverage', jestTasks.coverage);
|
||||
|
||||
grunt.registerTask('test', ['jest:normal']);
|
||||
grunt.registerTask('npm:test', ['build', 'npm:pack']);
|
||||
|
||||
// Optimized build task that does all of our builds. The subtasks will be run
|
||||
// in order so we can take advantage of that and only run build-modules once.
|
||||
grunt.registerTask('build', [
|
||||
'delete-build-modules',
|
||||
'build-modules',
|
||||
'version-check',
|
||||
'browserify:basic',
|
||||
'browserify:min',
|
||||
'browserify:dom',
|
||||
'browserify:domMin',
|
||||
'browserify:domServer',
|
||||
'browserify:domServerMin',
|
||||
'browserify:domFiber',
|
||||
'browserify:domFiberMin',
|
||||
'npm-react:release',
|
||||
'npm-react:pack',
|
||||
'npm-react-dom:release',
|
||||
'npm-react-dom:pack',
|
||||
'npm-react-native:release',
|
||||
'npm-react-native:pack',
|
||||
'npm-react-test:release',
|
||||
'npm-react-test:pack',
|
||||
'npm-react-noop:release',
|
||||
'npm-react-noop:pack',
|
||||
'compare_size',
|
||||
]);
|
||||
|
||||
// Automate the release!
|
||||
var releaseTasks = require('./grunt/tasks/release');
|
||||
grunt.registerTask('release:setup', releaseTasks.setup);
|
||||
grunt.registerTask('release:bower', releaseTasks.bower);
|
||||
grunt.registerTask('release:docs', releaseTasks.docs);
|
||||
grunt.registerTask('release:msg', releaseTasks.msg);
|
||||
|
||||
grunt.registerTask('release', [
|
||||
'release:setup',
|
||||
'clean',
|
||||
'build',
|
||||
'release:bower',
|
||||
'release:docs',
|
||||
'release:msg',
|
||||
]);
|
||||
|
||||
grunt.registerTask('build-modules', function() {
|
||||
spawnGulp(['react:modules'], null, this.async());
|
||||
});
|
||||
|
||||
// The default task - build - to keep setup easy.
|
||||
grunt.registerTask('default', ['build']);
|
||||
};
|
||||
|
|
@ -33,7 +33,6 @@ dependencies:
|
|||
# - npm ls --depth=0
|
||||
cache_directories:
|
||||
- docs/vendor/bundle
|
||||
- .grunt # Show size comparisons between builds
|
||||
- ~/react-gh-pages # docs checkout
|
||||
- ~/.yarn
|
||||
- ~/.yarn-cache
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ ruleTester.run('eslint-rules/no-primitive-constructors', rule, {
|
|||
code: 'String(obj)',
|
||||
errors: [
|
||||
{
|
||||
message: 'Do not use the String constructor. To cast a value to a string, concat it with the empty string (unless it\'s a symbol, which has different semantics): \'\' + value',
|
||||
message: 'Do not use the String constructor. To cast a value to a string, ' +
|
||||
'concat it with the empty string (unless it\'s a symbol, which has different semantics): \'\' + value',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
1
fixtures/art/.gitignore
vendored
Normal file
1
fixtures/art/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
bundle.js
|
||||
10
fixtures/art/README.md
Normal file
10
fixtures/art/README.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# VectorWidget example
|
||||
|
||||
To try this example, run:
|
||||
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
in this directory, then open index.html in your browser.
|
||||
132
fixtures/art/VectorWidget.js
Normal file
132
fixtures/art/VectorWidget.js
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/**
|
||||
* Copyright 2013 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.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
var React = require('react');
|
||||
var ReactART = require('react-art');
|
||||
var Group = ReactART.Group;
|
||||
var Shape = ReactART.Shape;
|
||||
var Surface = ReactART.Surface;
|
||||
var Transform = ReactART.Transform;
|
||||
|
||||
var MOUSE_UP_DRAG = 0.978;
|
||||
var MOUSE_DOWN_DRAG = 0.9;
|
||||
var MAX_VEL = 11;
|
||||
var CLICK_ACCEL = 3;
|
||||
var BASE_VEL = 0.15;
|
||||
|
||||
/**
|
||||
* An animated SVG component.
|
||||
*/
|
||||
var VectorWidget = React.createClass({
|
||||
/**
|
||||
* Initialize state members.
|
||||
*/
|
||||
getInitialState: function() {
|
||||
return {degrees: 0, velocity: 0, drag: MOUSE_UP_DRAG};
|
||||
},
|
||||
|
||||
/**
|
||||
* When the component is mounted into the document - this is similar to a
|
||||
* constructor, but invoked when the instance is actually mounted into the
|
||||
* document. Here's, we'll just set up an animation loop that invokes our
|
||||
* method. Binding of `this.onTick` is not needed because all React methods
|
||||
* are automatically bound before being mounted.
|
||||
*/
|
||||
componentDidMount: function() {
|
||||
this._interval = window.setInterval(this.onTick, 20);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
window.clearInterval(this._interval);
|
||||
},
|
||||
|
||||
onTick: function() {
|
||||
var nextDegrees = this.state.degrees + BASE_VEL + this.state.velocity;
|
||||
var nextVelocity = this.state.velocity * this.state.drag;
|
||||
this.setState({degrees: nextDegrees, velocity: nextVelocity});
|
||||
},
|
||||
|
||||
/**
|
||||
* When mousing down, we increase the friction down the velocity.
|
||||
*/
|
||||
handleMouseDown: function() {
|
||||
this.setState({drag: MOUSE_DOWN_DRAG});
|
||||
},
|
||||
|
||||
/**
|
||||
* Cause the rotation to "spring".
|
||||
*/
|
||||
handleMouseUp: function() {
|
||||
var nextVelocity = Math.min(this.state.velocity + CLICK_ACCEL, MAX_VEL);
|
||||
this.setState({velocity: nextVelocity, drag: MOUSE_UP_DRAG});
|
||||
},
|
||||
|
||||
/**
|
||||
* This is the "main" method for any component. The React API allows you to
|
||||
* describe the structure of your UI component at *any* point in time.
|
||||
*/
|
||||
render: function() {
|
||||
return (
|
||||
<Surface
|
||||
width={700}
|
||||
height={700}
|
||||
style={{cursor: 'pointer'}}>
|
||||
{this.renderGraphic(this.state.degrees)}
|
||||
</Surface>
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Better SVG support for React coming soon.
|
||||
*/
|
||||
renderGraphic: function(rotation) {
|
||||
|
||||
return (
|
||||
<Group
|
||||
onMouseDown={this.handleMouseDown}
|
||||
onMouseUp={this.handleMouseUp}>
|
||||
<Group x={210} y={135}>
|
||||
<Shape fill="rgba(0,0,0,0.1)" d={BORDER_PATH} />
|
||||
<Shape fill="#7BC7BA" d={BG_PATH} />
|
||||
<Shape fill="#DCDCDC" d={BAR_PATH} />
|
||||
<Shape fill="#D97B76" d={RED_DOT_PATH} />
|
||||
<Shape fill="#DBBB79" d={YELLOW_DOT_PATH} />
|
||||
<Shape fill="#A6BD8A" d={GREEN_DOT_PATH} />
|
||||
<Group x={55} y={29}>
|
||||
<Group rotation={rotation} originX={84} originY={89}>
|
||||
<Shape fill="#FFFFFF" d={CENTER_DOT_PATH} />
|
||||
<Group>
|
||||
<Shape d={RING_ONE_PATH} stroke="#FFFFFF" strokeWidth={8} />
|
||||
<Shape d={RING_TWO_PATH} transform={RING_TWO_ROTATE} stroke="#FFFFFF" strokeWidth={8} />
|
||||
<Shape d={RING_THREE_PATH} transform={RING_THREE_ROTATE} stroke="#FFFFFF" strokeWidth={8} />
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var BORDER_PATH = "M3.00191459,4 C1.34400294,4 0,5.34785514 0,7.00550479 L0,220.994495 C0,222.65439 1.34239483,224 3.00191459,224 L276.998085,224 C278.655997,224 280,222.652145 280,220.994495 L280,7.00550479 C280,5.34561033 278.657605,4 276.998085,4 L3.00191459,4 Z M3.00191459,4";
|
||||
var BG_PATH = "M3.00191459,1 C1.34400294,1 0,2.34785514 0,4.00550479 L0,217.994495 C0,219.65439 1.34239483,221 3.00191459,221 L276.998085,221 C278.655997,221 280,219.652145 280,217.994495 L280,4.00550479 C280,2.34561033 278.657605,1 276.998085,1 L3.00191459,1 Z M3.00191459,1";
|
||||
var BAR_PATH = "M3.00191459,0 C1.34400294,0 0,1.34559019 0,3.00878799 L0,21 C0,21 0,21 0,21 L280,21 C280,21 280,21 280,21 L280,3.00878799 C280,1.34708027 278.657605,0 276.998085,0 L3.00191459,0 Z M3.00191459,0";
|
||||
var RED_DOT_PATH = "M12.5,17 C16.0898511,17 19,14.0898511 19,10.5 C19,6.91014895 16.0898511,4 12.5,4 C8.91014895,4 6,6.91014895 6,10.5 C6,14.0898511 8.91014895,17 12.5,17 Z M12.5,17";
|
||||
var YELLOW_DOT_PATH = "M31.5,17 C35.0898511,17 38,14.0898511 38,10.5 C38,6.91014895 35.0898511,4 31.5,4 C27.9101489,4 25,6.91014895 25,10.5 C25,14.0898511 27.9101489,17 31.5,17 Z M31.5,17";
|
||||
var GREEN_DOT_PATH = "M50.5,17 C54.0898511,17 57,14.0898511 57,10.5 C57,6.91014895 54.0898511,4 50.5,4 C46.9101489,4 44,6.91014895 44,10.5 C44,14.0898511 46.9101489,17 50.5,17 Z M50.5,17";
|
||||
var CENTER_DOT_PATH = "M84,105 C92.8365564,105 100,97.8365564 100,89 C100,80.1634436 92.8365564,73 84,73 C75.1634436,73 68,80.1634436 68,89 C68,97.8365564 75.1634436,105 84,105 Z M84,105";
|
||||
var RING_ONE_PATH = "M84,121 C130.391921,121 168,106.673113 168,89 C168,71.3268871 130.391921,57 84,57 C37.6080787,57 0,71.3268871 0,89 C0,106.673113 37.6080787,121 84,121 Z M84,121";
|
||||
var RING_TWO_PATH = "M84,121 C130.391921,121 168,106.673113 168,89 C168,71.3268871 130.391921,57 84,57 C37.6080787,57 0,71.3268871 0,89 C0,106.673113 37.6080787,121 84,121 Z M84,121";
|
||||
var RING_THREE_PATH = "M84,121 C130.391921,121 168,106.673113 168,89 C168,71.3268871 130.391921,57 84,57 C37.6080787,57 0,71.3268871 0,89 C0,106.673113 37.6080787,121 84,121 Z M84,121";
|
||||
var RING_TWO_ROTATE = new Transform().translate(84.000000, 89.000000).rotate(-240.000000).translate(-84.000000, -89.000000);
|
||||
var RING_THREE_ROTATE = new Transform().translate(84.000000, 89.000000).rotate(-300.000000).translate(-84.000000, -89.000000);
|
||||
|
||||
module.exports = VectorWidget;
|
||||
|
||||
7
fixtures/art/app.js
Normal file
7
fixtures/art/app.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
var VectorWidget = require('./VectorWidget');
|
||||
|
||||
ReactDOM.render(<VectorWidget />, document.getElementById('container'));
|
||||
22
fixtures/art/index.html
Normal file
22
fixtures/art/index.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>VectorWidget</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
<p>If you're seeing this message, it means you haven't generated the bundle file for this example. Try running:</p>
|
||||
|
||||
<pre><code>
|
||||
npm install
|
||||
npm run build
|
||||
</code></pre>
|
||||
|
||||
<p>then reload the page.</p>
|
||||
</div>
|
||||
|
||||
<script src="bundle.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
12
fixtures/art/package.json
Normal file
12
fixtures/art/package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.24.0",
|
||||
"babel-loader": "^6.4.1",
|
||||
"babel-preset-es2015": "^6.6.0",
|
||||
"babel-preset-react": "^6.5.0",
|
||||
"webpack": "^1.14.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ln -fs ../../build/packages/react node_modules/react && ln -fs ../../build/packages/react-dom node_modules/react-dom && ln -fs ../../build/packages/react-art node_modules/react-art && webpack app.js bundle.js"
|
||||
}
|
||||
}
|
||||
34
fixtures/art/webpack.config.js
Normal file
34
fixtures/art/webpack.config.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
var webpack = require('webpack');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
context: __dirname,
|
||||
entry: './app.js',
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
loader: require.resolve('babel-loader'),
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
query: {
|
||||
presets: [
|
||||
require.resolve('babel-preset-es2015'),
|
||||
require.resolve('babel-preset-react'),
|
||||
],
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
NODE_ENV: JSON.stringify('development'),
|
||||
},
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
react: require.resolve('react')
|
||||
}
|
||||
}
|
||||
};
|
||||
2079
fixtures/art/yarn.lock
Normal file
2079
fixtures/art/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
4
fixtures/dom/.gitignore
vendored
4
fixtures/dom/.gitignore
vendored
|
|
@ -8,8 +8,8 @@ coverage
|
|||
|
||||
# production
|
||||
build
|
||||
public/react.js
|
||||
public/react-dom.js
|
||||
public/react.development.js
|
||||
public/react-dom.development.js
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"react-scripts": "0.8.4"
|
||||
"react-scripts": "0.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"prestart": "cp ../../build/{react,react-dom}.js public/",
|
||||
"prestart": "cp ../../build/dist/{react,react-dom}.development.js public/",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject"
|
||||
|
|
|
|||
4
fixtures/dom/public/react-loader.js
vendored
4
fixtures/dom/public/react-loader.js
vendored
|
|
@ -7,8 +7,8 @@
|
|||
* (Loads React 15.4.1)
|
||||
*/
|
||||
|
||||
var REACT_PATH = 'react.js';
|
||||
var DOM_PATH = 'react-dom.js';
|
||||
var REACT_PATH = 'react.development.js';
|
||||
var DOM_PATH = 'react-dom.development.js';
|
||||
|
||||
function parseQuery(qstr) {
|
||||
var query = {};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,7 @@
|
|||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"react-scripts": "0.9.0"
|
||||
"react-scripts": "0.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"dagre": "^0.7.4",
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import React, { Component } from 'react';
|
||||
import Draggable from 'react-draggable';
|
||||
import ReactNoop from 'react-noop-renderer';
|
||||
import ReactFiberInstrumentation from 'react-noop-renderer/lib/ReactFiberInstrumentation';
|
||||
import Editor from './Editor';
|
||||
import Fibers from './Fibers';
|
||||
import describeFibers from './describeFibers';
|
||||
|
||||
// The only place where we use it.
|
||||
const ReactFiberInstrumentation = ReactNoop.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactFiberInstrumentation;
|
||||
|
||||
function getFiberState(root, workInProgress) {
|
||||
if (!root) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import React from 'react';
|
||||
import { Motion, spring } from 'react-motion';
|
||||
import dagre from 'dagre';
|
||||
import prettyFormat from 'pretty-format';
|
||||
import reactElement from 'pretty-format/plugins/ReactElement';
|
||||
// import prettyFormat from 'pretty-format';
|
||||
// import reactElement from 'pretty-format/plugins/ReactElement';
|
||||
|
||||
function getFiberColor(fibers, id) {
|
||||
if (fibers.currentIDs.indexOf(id) > -1) {
|
||||
|
|
@ -232,7 +232,7 @@ export default function Fibers({ fibers, show, ...rest }) {
|
|||
);
|
||||
|
||||
const isDragging = rest.className.indexOf('dragging') > -1;
|
||||
const [_, sdx, sdy] = rest.style.transform.match(/translate\((\-?\d+)px,(\-?\d+)px\)/) || [];
|
||||
const [_, sdx, sdy] = rest.style.transform.match(/translate\((-?\d+)px,(-?\d+)px\)/) || [];
|
||||
const dx = Number(sdx);
|
||||
const dy = Number(sdy);
|
||||
|
||||
|
|
@ -264,7 +264,10 @@ export default function Fibers({ fibers, show, ...rest }) {
|
|||
height: '100%',
|
||||
backgroundColor: getFiberColor(fibers, fiber.id)
|
||||
}}
|
||||
title={prettyFormat(fiber, { plugins: [reactElement ]})}>
|
||||
title={
|
||||
/*prettyFormat(fiber, { plugins: [reactElement ]})*/
|
||||
'todo: this was hanging last time I tried to pretty print'
|
||||
}>
|
||||
<small>{fiber.tag} #{fiber.id}</small>
|
||||
<br />
|
||||
{fiber.type}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,6 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fiber Example</title>
|
||||
<link rel="stylesheet" href="../shared/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Fiber Example</h1>
|
||||
|
|
@ -14,12 +13,12 @@
|
|||
</p>
|
||||
<p>
|
||||
If you can see this, React is <strong>not</strong> working right.
|
||||
If you checked out the source from GitHub make sure to run <code>grunt</code>.
|
||||
If you checked out the source from GitHub make sure to run <code>npm run build</code>.
|
||||
</p>
|
||||
</div>
|
||||
<script src="../../build/react.js"></script>
|
||||
<script src="../../build/react-dom-fiber.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js"></script>
|
||||
<script src="../../build/dist/react.development.js"></script>
|
||||
<script src="../../build/dist/react-dom.development.js"></script>
|
||||
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
|
||||
<script type="text/babel">
|
||||
var dotStyle = {
|
||||
position: 'absolute',
|
||||
|
|
@ -139,7 +138,7 @@
|
|||
tick() {
|
||||
if (this.state.useTimeSlicing) {
|
||||
// Update is time-sliced.
|
||||
ReactDOMFiber.unstable_deferredUpdates(() => {
|
||||
ReactDOM.unstable_deferredUpdates(() => {
|
||||
this.setState(state => ({ seconds: (state.seconds % 10) + 1 }));
|
||||
});
|
||||
} else {
|
||||
|
|
@ -210,7 +209,7 @@
|
|||
|
||||
var start = new Date().getTime();
|
||||
function update() {
|
||||
ReactDOMFiber.render(
|
||||
ReactDOM.render(
|
||||
<ExampleApplication elapsed={new Date().getTime() - start} />,
|
||||
document.getElementById('container')
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,21 +30,13 @@ pushstate-server .
|
|||
|
||||
(Too complicated? Send a PR to simplify this :-).
|
||||
|
||||
Then open the corresponding URLs, for example:
|
||||
Then open the following URL in your browser:
|
||||
|
||||
```
|
||||
open http://localhost:9000/fixtures/globals.html
|
||||
open http://localhost:9000/fixtures/requirejs.html
|
||||
open http://localhost:9000/fixtures/systemjs.html
|
||||
open http://localhost:9000/fixtures/browserify/index.html
|
||||
open http://localhost:9000/fixtures/brunch/index.html
|
||||
open http://localhost:9000/fixtures/rjs/index.html
|
||||
open http://localhost:9000/fixtures/systemjs-builder/index.html
|
||||
open http://localhost:9000/fixtures/webpack/index.html
|
||||
open http://localhost:9000/fixtures/webpack-alias/index.html
|
||||
open http://localhost:9000/fixtures/packaging/index.html
|
||||
```
|
||||
|
||||
You should see two things:
|
||||
|
||||
* "Hello World" is rendered.
|
||||
* "Hello World" is rendered in each iframe.
|
||||
* No errors in the console.
|
||||
|
|
|
|||
14
fixtures/packaging/babel-standalone/dev.html
Normal file
14
fixtures/packaging/babel-standalone/dev.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="../../../build/dist/react.development.js"></script>
|
||||
<script src="../../../build/dist/react-dom.development.js"></script>
|
||||
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
|
||||
<div id="container"></div>
|
||||
<script type="text/babel">
|
||||
ReactDOM.render(
|
||||
<h1>Hello World!</h1>,
|
||||
document.getElementById('container')
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -5,6 +5,6 @@
|
|||
"browserify": "^13.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -f output.js && NODE_PATH=../../../build/packages browserify ./input.js -o output.js"
|
||||
"build": "rm -f output.js && NODE_PATH=../../../../build/packages browserify ./input.js -o output.js"
|
||||
}
|
||||
}
|
||||
1
fixtures/packaging/browserify/prod/.gitignore
vendored
Normal file
1
fixtures/packaging/browserify/prod/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
output.js
|
||||
13
fixtures/packaging/browserify/prod/package.json
Normal file
13
fixtures/packaging/browserify/prod/package.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "webpack-test",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"browserify": "^13.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -f output.js && NODE_PATH=../../../../build/packages browserify ./input.js -g [envify --NODE_ENV 'production'] -o output.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"envify": "^4.0.0"
|
||||
}
|
||||
}
|
||||
10
fixtures/packaging/brunch/dev/package.json
Normal file
10
fixtures/packaging/brunch/dev/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "brunch-test",
|
||||
"devDependencies": {
|
||||
"brunch": "^2.9.1",
|
||||
"javascript-brunch": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf public && ln -fs ../../../../../build/packages/react node_modules/react && ln -fs ../../../../../build/packages/react-dom node_modules/react-dom && brunch build"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "brunch-test",
|
||||
"devDependencies": {
|
||||
"brunch": "^2.9.1",
|
||||
"javascript-brunch": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf public && ln -fs ../../../../build/packages/react node_modules/react && ln -fs ../../../../build/packages/react-dom node_modules/react-dom && brunch build"
|
||||
}
|
||||
}
|
||||
2
fixtures/packaging/brunch/prod/.gitignore
vendored
Normal file
2
fixtures/packaging/brunch/prod/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
output.js
|
||||
output.js.map
|
||||
10
fixtures/packaging/brunch/prod/config.js
Normal file
10
fixtures/packaging/brunch/prod/config.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
exports.config = {
|
||||
paths: {
|
||||
public: '.',
|
||||
},
|
||||
files: {
|
||||
javascripts: {
|
||||
joinTo: 'output.js',
|
||||
},
|
||||
},
|
||||
};
|
||||
7
fixtures/packaging/brunch/prod/index.html
Normal file
7
fixtures/packaging/brunch/prod/index.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="output.js"></script>
|
||||
<script>require('initialize');</script>
|
||||
</body>
|
||||
</html>
|
||||
7
fixtures/packaging/brunch/prod/input.js
Normal file
7
fixtures/packaging/brunch/prod/input.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
10
fixtures/packaging/brunch/prod/package.json
Normal file
10
fixtures/packaging/brunch/prod/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "brunch-test",
|
||||
"devDependencies": {
|
||||
"brunch": "^2.9.1",
|
||||
"javascript-brunch": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf public && ln -fs ../../../../../build/packages/react node_modules/react && ln -fs ../../../../../build/packages/react-dom node_modules/react-dom && brunch build -p"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +1,48 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var { spawnSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const child_process = require('child_process');
|
||||
|
||||
var fixtureDirs = fs.readdirSync(__dirname).filter((file) => {
|
||||
const fixtureDirs = fs.readdirSync(__dirname).filter((file) => {
|
||||
return fs.statSync(path.join(__dirname, file)).isDirectory();
|
||||
});
|
||||
|
||||
var cmdArgs = [
|
||||
const cmdArgs = [
|
||||
{cmd: 'npm', args: ['install']},
|
||||
{cmd: 'npm', args: ['run', 'build']},
|
||||
];
|
||||
|
||||
for (const dir of fixtureDirs) {
|
||||
for (const cmdArg of cmdArgs) {
|
||||
function buildFixture(cmdArg, path) {
|
||||
const opts = {
|
||||
cwd: path.join(__dirname, dir),
|
||||
cwd: path,
|
||||
stdio: 'inherit',
|
||||
};
|
||||
let result = spawnSync(cmdArg.cmd, cmdArg.args, opts);
|
||||
const result = child_process.spawnSync(cmdArg.cmd, cmdArg.args, opts);
|
||||
if (result.status !== 0) {
|
||||
throw new Error('Failed to build fixtures.');
|
||||
}
|
||||
throw new Error(`Failed to build fixtures!`);
|
||||
}
|
||||
}
|
||||
|
||||
fixtureDirs.forEach(dir => {
|
||||
cmdArgs.forEach(cmdArg => {
|
||||
// we only care about directories that have DEV and PROD directories in
|
||||
// otherwise they don't need to be built
|
||||
const devPath = path.join(__dirname, dir, 'dev');
|
||||
|
||||
if (fs.existsSync(devPath)) {
|
||||
buildFixture(cmdArg, devPath);
|
||||
}
|
||||
const prodPath = path.join(__dirname, dir, 'prod');
|
||||
|
||||
if (fs.existsSync(prodPath)) {
|
||||
buildFixture(cmdArg, prodPath);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
console.log('-------------------------');
|
||||
console.log('All fixtures were built!');
|
||||
console.log('Now make sure to open each HTML file in this directory and each index.html in subdirectories.');
|
||||
console.log('Now ensure all frames display a welcome message:');
|
||||
console.log(' npm install -g serve');
|
||||
console.log(' serve ../..');
|
||||
console.log(' open http://localhost:5000/fixtures/packaging/');
|
||||
console.log('-------------------------');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="../../build/react.js"></script>
|
||||
<script src="../../build/react-dom.js"></script>
|
||||
<script src="../../../build/dist/react.development.js"></script>
|
||||
<script src="../../../build/dist/react-dom.development.js"></script>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
ReactDOM.render(
|
||||
13
fixtures/packaging/globals/prod.html
Normal file
13
fixtures/packaging/globals/prod.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="../../../build/dist/react.production.min.js"></script>
|
||||
<script src="../../../build/dist/react-dom.production.min.js"></script>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
92
fixtures/packaging/index.html
Normal file
92
fixtures/packaging/index.html
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.frame {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 350px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>bundle packaging</h1>
|
||||
<p>If you see Hello World in each frame with no console errors, all is well!</p>
|
||||
<div class="frame">
|
||||
<h2>babel-standalone (dev only)</h2>
|
||||
<iframe src="/fixtures/packaging/babel-standalone/dev.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>globals (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/globals/dev.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>globals (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/globals/prod.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>requirejs (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/requirejs/dev.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>requirejs (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/requirejs/prod.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>systemjs (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/systemjs/dev.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>systemjs (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/systemjs/dev.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>browserify (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/browserify/dev/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>browserify (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/browserify/prod/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>brunch (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/brunch/dev/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>brunch (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/brunch/prod/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>rjs (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/rjs/dev/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>rjs (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/rjs/prod/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>systemjs-builder (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/systemjs-builder/dev/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>systemjs-builder (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/systemjs-builder/prod/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>webpack (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/webpack/dev/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>webpack (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/webpack/prod/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>webpack-alias (dev)</h2>
|
||||
<iframe src="/fixtures/packaging/webpack-alias/dev/index.html"></iframe>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<h2>webpack-alias (prod)</h2>
|
||||
<iframe src="/fixtures/packaging/webpack-alias/prod/index.html"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
<script>
|
||||
requirejs.config({
|
||||
paths: {
|
||||
react: '../../build/react',
|
||||
'react-dom': '../../build/react-dom'
|
||||
react: '../../../build/dist/react.development',
|
||||
'react-dom': '../../../build/dist/react-dom.development'
|
||||
}
|
||||
});
|
||||
|
||||
21
fixtures/packaging/requirejs/prod.html
Normal file
21
fixtures/packaging/requirejs/prod.html
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="https://unpkg.com/requirejs@2.3.2/require.js"></script>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
requirejs.config({
|
||||
paths: {
|
||||
react: '../../../build/dist/react.production.min',
|
||||
'react-dom': '../../../build/dist/react-dom.production.min'
|
||||
}
|
||||
});
|
||||
|
||||
require(['react', 'react-dom'], function(React, ReactDOM) {
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
module.exports = {
|
||||
baseUrl: '.',
|
||||
name: 'input',
|
||||
out: 'output.js',
|
||||
optimize: 'none',
|
||||
paths: {
|
||||
react: '../../../build/react',
|
||||
'react-dom': '../../../build/react-dom',
|
||||
},
|
||||
};
|
||||
10
fixtures/packaging/rjs/dev/config.js
Normal file
10
fixtures/packaging/rjs/dev/config.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
module.exports = {
|
||||
baseUrl: '.',
|
||||
name: 'input',
|
||||
out: 'output.js',
|
||||
optimize: 'none',
|
||||
paths: {
|
||||
react: '../../../../build/dist/react.development',
|
||||
'react-dom': '../../../../build/dist/react-dom.development',
|
||||
},
|
||||
};
|
||||
10
fixtures/packaging/rjs/prod/config.js
Normal file
10
fixtures/packaging/rjs/prod/config.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
module.exports = {
|
||||
baseUrl: '.',
|
||||
name: 'input',
|
||||
out: 'output.js',
|
||||
optimize: 'none',
|
||||
paths: {
|
||||
react: '../../../../build/dist/react.production.min',
|
||||
'react-dom': '../../../../build/dist/react-dom.production.min',
|
||||
},
|
||||
};
|
||||
7
fixtures/packaging/rjs/prod/index.html
Normal file
7
fixtures/packaging/rjs/prod/index.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="https://unpkg.com/requirejs@2.3.2/require.js"></script>
|
||||
<script src="output.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
6
fixtures/packaging/rjs/prod/input.js
Normal file
6
fixtures/packaging/rjs/prod/input.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
require(['react', 'react-dom'], function(React, ReactDOM) {
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
});
|
||||
10
fixtures/packaging/rjs/prod/package.json
Normal file
10
fixtures/packaging/rjs/prod/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "rjs-test",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"requirejs": "^2.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -f output.js && r.js -o config.js"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
System.config({
|
||||
paths: {
|
||||
react: '../../../build/react.js',
|
||||
'react-dom': '../../../build/react-dom.js',
|
||||
},
|
||||
});
|
||||
6
fixtures/packaging/systemjs-builder/dev/config.js
Normal file
6
fixtures/packaging/systemjs-builder/dev/config.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
System.config({
|
||||
paths: {
|
||||
react: '../../../../build/dist/react.development.js',
|
||||
'react-dom': '../../../../build/dist/react-dom.development.js',
|
||||
},
|
||||
});
|
||||
12
fixtures/packaging/systemjs-builder/prod/build.js
Normal file
12
fixtures/packaging/systemjs-builder/prod/build.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
var Builder = require('systemjs-builder');
|
||||
|
||||
var builder = new Builder('/', './config.js');
|
||||
builder
|
||||
.buildStatic('./input.js', './output.js')
|
||||
.then(function() {
|
||||
console.log('Build complete');
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log('Build error');
|
||||
console.log(err);
|
||||
});
|
||||
6
fixtures/packaging/systemjs-builder/prod/config.js
Normal file
6
fixtures/packaging/systemjs-builder/prod/config.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
System.config({
|
||||
paths: {
|
||||
react: '../../../../build/dist/react.production.min.js',
|
||||
'react-dom': '../../../../build/dist/react-dom.production.min.js',
|
||||
},
|
||||
});
|
||||
7
fixtures/packaging/systemjs-builder/prod/input.js
Normal file
7
fixtures/packaging/systemjs-builder/prod/input.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
10
fixtures/packaging/systemjs-builder/prod/package.json
Normal file
10
fixtures/packaging/systemjs-builder/prod/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "systemjs-builder-test",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"systemjs-builder": "^0.15.34"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -f output.js && node build.js"
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
<script>
|
||||
System.config({
|
||||
paths: {
|
||||
react: '../../build/react.js',
|
||||
'react-dom': '../../build/react-dom.js'
|
||||
react: '../../../build/dist/react.development.js',
|
||||
'react-dom': '../../../build/dist/react-dom.development.js'
|
||||
}
|
||||
});
|
||||
|
||||
27
fixtures/packaging/systemjs/prod.html
Normal file
27
fixtures/packaging/systemjs/prod.html
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="https://unpkg.com/systemjs@0.19.41/dist/system.js"></script>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
System.config({
|
||||
paths: {
|
||||
react: '../../../build/dist/react.production.min.js',
|
||||
'react-dom': '../../../build/dist/react-dom.production.min.js'
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all([
|
||||
System.import("react"),
|
||||
System.import("react-dom")
|
||||
]).then(function (deps) {
|
||||
var React = deps[0];
|
||||
var ReactDOM = deps[1];
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: './input',
|
||||
output: {
|
||||
filename: 'output.js',
|
||||
},
|
||||
resolve: {
|
||||
root: path.resolve('../../../build/packages'),
|
||||
alias: {
|
||||
'react': 'react/dist/react',
|
||||
'react-dom': 'react-dom/dist/react-dom',
|
||||
},
|
||||
},
|
||||
};
|
||||
1
fixtures/packaging/webpack-alias/dev/.gitignore
vendored
Normal file
1
fixtures/packaging/webpack-alias/dev/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
output.js
|
||||
15
fixtures/packaging/webpack-alias/dev/config.js
Normal file
15
fixtures/packaging/webpack-alias/dev/config.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: './input',
|
||||
output: {
|
||||
filename: 'output.js',
|
||||
},
|
||||
resolve: {
|
||||
root: path.resolve('../../../../build/packages'),
|
||||
alias: {
|
||||
'react': 'react/umd/react.development',
|
||||
'react-dom': 'react-dom/umd/react-dom.development',
|
||||
},
|
||||
},
|
||||
};
|
||||
6
fixtures/packaging/webpack-alias/dev/index.html
Normal file
6
fixtures/packaging/webpack-alias/dev/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="output.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
fixtures/packaging/webpack-alias/dev/input.js
Normal file
7
fixtures/packaging/webpack-alias/dev/input.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
1
fixtures/packaging/webpack-alias/prod/.gitignore
vendored
Normal file
1
fixtures/packaging/webpack-alias/prod/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
output.js
|
||||
15
fixtures/packaging/webpack-alias/prod/config.js
Normal file
15
fixtures/packaging/webpack-alias/prod/config.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: './input',
|
||||
output: {
|
||||
filename: 'output.js',
|
||||
},
|
||||
resolve: {
|
||||
root: path.resolve('../../../../build/packages'),
|
||||
alias: {
|
||||
'react': 'react/umd/react.production.min',
|
||||
'react-dom': 'react-dom/umd/react-dom.production.min',
|
||||
},
|
||||
},
|
||||
};
|
||||
6
fixtures/packaging/webpack-alias/prod/index.html
Normal file
6
fixtures/packaging/webpack-alias/prod/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="output.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
fixtures/packaging/webpack-alias/prod/input.js
Normal file
7
fixtures/packaging/webpack-alias/prod/input.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
1
fixtures/packaging/webpack/dev/.gitignore
vendored
Normal file
1
fixtures/packaging/webpack/dev/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
output.js
|
||||
|
|
@ -6,6 +6,6 @@ module.exports = {
|
|||
filename: 'output.js',
|
||||
},
|
||||
resolve: {
|
||||
root: path.resolve('../../../build/packages/'),
|
||||
root: path.resolve('../../../../build/packages/'),
|
||||
},
|
||||
};
|
||||
6
fixtures/packaging/webpack/dev/index.html
Normal file
6
fixtures/packaging/webpack/dev/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="output.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
fixtures/packaging/webpack/dev/input.js
Normal file
7
fixtures/packaging/webpack/dev/input.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
10
fixtures/packaging/webpack/dev/package.json
Normal file
10
fixtures/packaging/webpack/dev/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "webpack-test",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"webpack": "^1.14.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -f output.js && webpack --config config.js"
|
||||
}
|
||||
}
|
||||
1
fixtures/packaging/webpack/prod/.gitignore
vendored
Normal file
1
fixtures/packaging/webpack/prod/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
output.js
|
||||
19
fixtures/packaging/webpack/prod/config.js
Normal file
19
fixtures/packaging/webpack/prod/config.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
entry: './input',
|
||||
output: {
|
||||
filename: 'output.js',
|
||||
},
|
||||
resolve: {
|
||||
root: path.resolve('../../../../build/packages/'),
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env':{
|
||||
'NODE_ENV': JSON.stringify('production')
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
||||
6
fixtures/packaging/webpack/prod/index.html
Normal file
6
fixtures/packaging/webpack/prod/index.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="output.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
7
fixtures/packaging/webpack/prod/input.js
Normal file
7
fixtures/packaging/webpack/prod/input.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement('h1', null, 'Hello World!'),
|
||||
document.getElementById('container')
|
||||
);
|
||||
10
fixtures/packaging/webpack/prod/package.json
Normal file
10
fixtures/packaging/webpack/prod/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "webpack-test",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"webpack": "^1.14.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -f output.js && webpack --config config.js"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,275 +0,0 @@
|
|||
/*eslint-disable no-multi-str */
|
||||
|
||||
'use strict';
|
||||
|
||||
var envify = require('loose-envify/custom');
|
||||
var grunt = require('grunt');
|
||||
var UglifyJS = require('uglify-js');
|
||||
var uglifyify = require('uglifyify');
|
||||
var derequire = require('derequire');
|
||||
var aliasify = require('aliasify');
|
||||
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 shimSharedModules = aliasify.configure({
|
||||
'aliases': {
|
||||
'react/lib/React': 'react/lib/ReactUMDShim',
|
||||
'react/lib/ReactCurrentOwner': 'react/lib/ReactCurrentOwnerUMDShim',
|
||||
'react/lib/ReactComponentTreeHook': 'react/lib/ReactComponentTreeHookUMDShim',
|
||||
},
|
||||
});
|
||||
|
||||
var SIMPLE_TEMPLATE =
|
||||
grunt.file.read('./grunt/data/header-template-short.txt');
|
||||
|
||||
var LICENSE_TEMPLATE =
|
||||
grunt.file.read('./grunt/data/header-template-extended.txt');
|
||||
|
||||
function minify(src) {
|
||||
return UglifyJS.minify(src, {
|
||||
fromString: true,
|
||||
output: {
|
||||
comments(node, comment) {
|
||||
// Preserve license headers in dependencies like object-assign.
|
||||
if (comment.type === 'comment2') {
|
||||
return /@license/i.test(comment.value);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
}).code;
|
||||
}
|
||||
|
||||
// TODO: move this out to another build step maybe.
|
||||
function bannerify(src) {
|
||||
var version = grunt.config.data.pkg.version;
|
||||
var packageName = this.data.packageName || this.data.standalone;
|
||||
return (
|
||||
grunt.template.process(
|
||||
LICENSE_TEMPLATE,
|
||||
{data: {package: packageName, version: version}}
|
||||
) +
|
||||
src
|
||||
);
|
||||
}
|
||||
|
||||
function simpleBannerify(src) {
|
||||
var version = grunt.config.data.pkg.version;
|
||||
var packageName = this.data.packageName || this.data.standalone;
|
||||
return (
|
||||
grunt.template.process(
|
||||
SIMPLE_TEMPLATE,
|
||||
{data: {package: packageName, version: version}}
|
||||
) +
|
||||
src
|
||||
);
|
||||
}
|
||||
|
||||
// What is happening here???
|
||||
// I'm glad you asked. It became really hard to make our bundle splitting work.
|
||||
// Everything is fine in node and when bundling with those packages, but when
|
||||
// using our pre-packaged files, the splitting didn't work. Specifically due to
|
||||
// the UMD wrappers defining their own require and creating their own encapsulated
|
||||
// "registry" scope, we couldn't require across the boundaries. Webpack tries to
|
||||
// be smart and looks for top-level requires (even when aliasing to a bundle),
|
||||
// but since we didn't have those, we couldn't require 'react' from 'react-dom'.
|
||||
// But we are already shimming in some modules that look for a global React
|
||||
// variable. So we replace the UMD wrapper that browserify creates with out own,
|
||||
// in 2 steps.
|
||||
// 1. We swap out the browserify UMD with a plain function call. This ensures
|
||||
// that the internal wrapper doesn't interact with the external state. By the
|
||||
// time we're in the internal wrapper it doesn't matter what the external wrapper
|
||||
// detected. Browserify insulates its CommonJS system inside closures so can just
|
||||
// call that function and return it.
|
||||
// 2. We put our own UMD wrapper around that fixed internal function, ensuring
|
||||
// React is in scope. This outer wrapper is essentially the same UMD wrapper
|
||||
// browserify would create, just handling the scope issue.
|
||||
// Is this insane? Yes.
|
||||
// Does it work? Yes.
|
||||
// Should it go away ASAP? Yes.
|
||||
function wrapperify(src) {
|
||||
/* eslint-disable max-len*/
|
||||
var toReplace =
|
||||
`function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.${this.data.standalone} = f()}}`;
|
||||
/* eslint-enable max-len */
|
||||
if (src.indexOf(toReplace) === -1) {
|
||||
throw new Error('wrapperify failed to find code to replace');
|
||||
}
|
||||
src = src.replace(
|
||||
toReplace,
|
||||
`function(f){return f()}`
|
||||
);
|
||||
return `
|
||||
;(function(f) {
|
||||
// CommonJS
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
module.exports = f(require('react'));
|
||||
|
||||
// RequireJS
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(['react'], f);
|
||||
|
||||
// <script>
|
||||
} else {
|
||||
var g;
|
||||
if (typeof window !== "undefined") {
|
||||
g = window;
|
||||
} else if (typeof global !== "undefined") {
|
||||
g = global;
|
||||
} else if (typeof self !== "undefined") {
|
||||
g = self;
|
||||
} else {
|
||||
// works providing we're not in "use strict";
|
||||
// needed for Java 8 Nashorn
|
||||
// see https://github.com/facebook/react/issues/3037
|
||||
g = this;
|
||||
}
|
||||
g.${this.data.standalone} = f(g.React);
|
||||
}
|
||||
})(function(React) {
|
||||
return ${src}
|
||||
});
|
||||
`;
|
||||
}
|
||||
|
||||
// Our basic config which we'll add to to make our other builds
|
||||
var basic = {
|
||||
entries: [
|
||||
'./build/node_modules/react/lib/ReactUMDEntry.js',
|
||||
],
|
||||
outfile: './build/react.js',
|
||||
debug: false,
|
||||
standalone: 'React',
|
||||
// Apply as global transform so that we also envify fbjs and any other deps
|
||||
globalTransforms: [envifyDev],
|
||||
plugins: [collapser],
|
||||
after: [derequire, simpleBannerify],
|
||||
};
|
||||
|
||||
var min = {
|
||||
entries: [
|
||||
'./build/node_modules/react/lib/ReactUMDEntry.js',
|
||||
],
|
||||
outfile: './build/react.min.js',
|
||||
debug: false,
|
||||
standalone: 'React',
|
||||
// Envify twice. The first ensures that when we uglifyify, we have the right
|
||||
// conditions to exclude requires. The global transform runs on deps.
|
||||
transforms: [envifyProd, uglifyify],
|
||||
globalTransforms: [envifyProd],
|
||||
plugins: [collapser],
|
||||
// No need to derequire because the minifier will mangle
|
||||
// the "require" calls.
|
||||
|
||||
after: [minify, bannerify],
|
||||
};
|
||||
|
||||
// The DOM Builds
|
||||
var dom = {
|
||||
entries: [
|
||||
'./build/node_modules/react-dom/lib/ReactDOMUMDEntry.js',
|
||||
],
|
||||
outfile: './build/react-dom.js',
|
||||
debug: false,
|
||||
standalone: 'ReactDOM',
|
||||
// Apply as global transform so that we also envify fbjs and any other deps
|
||||
transforms: [shimSharedModules],
|
||||
globalTransforms: [envifyDev],
|
||||
plugins: [collapser],
|
||||
after: [derequire, wrapperify, simpleBannerify],
|
||||
};
|
||||
|
||||
var domMin = {
|
||||
entries: [
|
||||
'./build/node_modules/react-dom/lib/ReactDOMUMDEntry.js',
|
||||
],
|
||||
outfile: './build/react-dom.min.js',
|
||||
debug: false,
|
||||
standalone: 'ReactDOM',
|
||||
// Envify twice. The first ensures that when we uglifyify, we have the right
|
||||
// conditions to exclude requires. The global transform runs on deps.
|
||||
transforms: [shimSharedModules, envifyProd, uglifyify],
|
||||
globalTransforms: [envifyProd],
|
||||
plugins: [collapser],
|
||||
// No need to derequire because the minifier will mangle
|
||||
// the "require" calls.
|
||||
|
||||
after: [wrapperify, minify, bannerify],
|
||||
};
|
||||
|
||||
var domServer = {
|
||||
entries: [
|
||||
'./build/node_modules/react-dom/lib/ReactDOMServerUMDEntry.js',
|
||||
],
|
||||
outfile: './build/react-dom-server.js',
|
||||
debug: false,
|
||||
standalone: 'ReactDOMServer',
|
||||
// Apply as global transform so that we also envify fbjs and any other deps
|
||||
transforms: [shimSharedModules],
|
||||
globalTransforms: [envifyDev],
|
||||
plugins: [collapser],
|
||||
after: [derequire, wrapperify, simpleBannerify],
|
||||
};
|
||||
|
||||
var domServerMin = {
|
||||
entries: [
|
||||
'./build/node_modules/react-dom/lib/ReactDOMServerUMDEntry.js',
|
||||
],
|
||||
outfile: './build/react-dom-server.min.js',
|
||||
debug: false,
|
||||
standalone: 'ReactDOMServer',
|
||||
// Envify twice. The first ensures that when we uglifyify, we have the right
|
||||
// conditions to exclude requires. The global transform runs on deps.
|
||||
transforms: [shimSharedModules, envifyProd, uglifyify],
|
||||
globalTransforms: [envifyProd],
|
||||
plugins: [collapser],
|
||||
// No need to derequire because the minifier will mangle
|
||||
// the "require" calls.
|
||||
|
||||
after: [wrapperify, minify, bannerify],
|
||||
};
|
||||
|
||||
var domFiber = {
|
||||
entries: [
|
||||
'./build/node_modules/react-dom/lib/ReactDOMFiber.js',
|
||||
],
|
||||
outfile: './build/react-dom-fiber.js',
|
||||
debug: false,
|
||||
standalone: 'ReactDOMFiber',
|
||||
// Apply as global transform so that we also envify fbjs and any other deps
|
||||
transforms: [shimSharedModules],
|
||||
globalTransforms: [envifyDev],
|
||||
plugins: [collapser],
|
||||
after: [derequire, wrapperify, simpleBannerify],
|
||||
};
|
||||
|
||||
var domFiberMin = {
|
||||
entries: [
|
||||
'./build/node_modules/react-dom/lib/ReactDOMFiber.js',
|
||||
],
|
||||
outfile: './build/react-dom-fiber.min.js',
|
||||
debug: false,
|
||||
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: [shimSharedModules, envifyProd, uglifyify],
|
||||
globalTransforms: [envifyProd],
|
||||
plugins: [collapser],
|
||||
// No need to derequire because the minifier will mangle
|
||||
// the "require" calls.
|
||||
|
||||
after: [wrapperify, minify, bannerify],
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
basic: basic,
|
||||
min: min,
|
||||
dom: dom,
|
||||
domMin: domMin,
|
||||
domServer: domServer,
|
||||
domServerMin: domServerMin,
|
||||
domFiber: domFiber,
|
||||
domFiberMin: domFiberMin,
|
||||
};
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var gzip = require('gzip-js');
|
||||
|
||||
module.exports = {
|
||||
files: [
|
||||
'build/*.js',
|
||||
],
|
||||
options: {
|
||||
compress: {
|
||||
gz: function(contents) {
|
||||
return gzip.zip(contents, {}).length;
|
||||
},
|
||||
},
|
||||
cache: '.grunt/sizecache.json',
|
||||
},
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user