Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AMD and Brunch issues #8686

Merged
merged 5 commits into from
Jan 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions fixtures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Manual Testing Fixtures

This folder exists for **React contributors** only.
If you use React you don't need to worry about it.

These fixtures verify that the built React distributions are usable in different environments.
**They are not running automatically.** (At least not yet, feel free to contribute to automate them.)

Run them when you make changes to how we package React, ReactDOM, and addons.

## How to Run

First, build React and the fixtures:

```
cd react
npm run build
cd fixtures
node build-all.js
```

Then run a local server at the root of the repo, e.g.

```
npm i -g pushstate-server
cd ..
pushstate-server .
```

(Too complicated? Send a PR to simplify this :-).

Then open the corresponding URLs, for example:

```
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
```

You should see two things:

* "Hello World" fading in with an animation.
* No errors in the console.
1 change: 1 addition & 0 deletions fixtures/browserify/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
16 changes: 16 additions & 0 deletions fixtures/browserify/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="output.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions fixtures/browserify/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var React = require('react');
var CSSTransitionGroup = require('react-addons-css-transition-group');
var ReactDOM = require('react-dom');

ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
10 changes: 10 additions & 0 deletions fixtures/browserify/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "webpack-test",
"private": true,
"dependencies": {
"browserify": "^13.3.0"
},
"scripts": {
"build": "rm -f output.js && NODE_PATH=../../build/packages browserify ./input.js -o output.js"
}
}
2 changes: 2 additions & 0 deletions fixtures/brunch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
output.js
output.js.map
16 changes: 16 additions & 0 deletions fixtures/brunch/app/initialize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var React = require('react');
var CSSTransitionGroup = require('react-addons-css-transition-group');
var ReactDOM = require('react-dom');

ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
10 changes: 10 additions & 0 deletions fixtures/brunch/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.config = {
paths: {
public: '.',
},
files: {
javascripts: {
joinTo: 'output.js',
},
},
};
17 changes: 17 additions & 0 deletions fixtures/brunch/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="output.js"></script>
<script>require('initialize');</script>
</body>
</html>
16 changes: 16 additions & 0 deletions fixtures/brunch/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var React = require('react');
var CSSTransitionGroup = require('react-addons-css-transition-group');
var ReactDOM = require('react-dom');

ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
10 changes: 10 additions & 0 deletions fixtures/brunch/package.json
Original file line number Diff line number Diff line change
@@ -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 && ln -fs ../../../build/packages/react-addons-css-transition-group node_modules/react-addons-css-transition-group && brunch build"
}
}
30 changes: 30 additions & 0 deletions fixtures/build-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var fs = require('fs');
var path = require('path');
var { spawnSync } = require('child_process');

var fixtureDirs = fs.readdirSync(__dirname).filter((file) => {
return fs.statSync(path.join(__dirname, file)).isDirectory();
});

var cmdArgs = [
{cmd: 'npm', args: ['install']},
{cmd: 'npm', args: ['run', 'build']},
];

for (const dir of fixtureDirs) {
for (const cmdArg of cmdArgs) {
const opts = {
cwd: path.join(__dirname, dir),
stdio: 'inherit',
};
let result = spawnSync(cmdArg.cmd, cmdArg.args, opts);
if (result.status !== 0) {
throw new Error('Failed to build fixtures.');
}
}
}

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('-------------------------');
32 changes: 32 additions & 0 deletions fixtures/globals.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<html>
<body>
<script src="../build/react-with-addons.js"></script>
<script src="../build/react-dom.js"></script>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script>
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
</script>
</body>
</html>
40 changes: 40 additions & 0 deletions fixtures/requirejs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<html>
<body>
<script src="https://unpkg.com/requirejs@2.3.2/require.js"></script>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script>
requirejs.config({
paths: {
react: '../build/react-with-addons',
'react-dom': '../build/react-dom'
}
});

require(['react', 'react-dom'], function(React, ReactDOM) {
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions fixtures/rjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
10 changes: 10 additions & 0 deletions fixtures/rjs/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
baseUrl: '.',
name: 'input',
out: 'output.js',
optimize: 'none',
paths: {
react: '../../build/react-with-addons',
'react-dom': '../../build/react-dom',
},
};
17 changes: 17 additions & 0 deletions fixtures/rjs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="https://unpkg.com/requirejs@2.3.2/require.js"></script>
<script src="output.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions fixtures/rjs/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require(['react', 'react-dom'], function(React, ReactDOM) {
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
});
10 changes: 10 additions & 0 deletions fixtures/rjs/package.json
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions fixtures/systemjs-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
12 changes: 12 additions & 0 deletions fixtures/systemjs-builder/build.js
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions fixtures/systemjs-builder/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
System.config({
paths: {
react: '../../build/react-with-addons.js',
'react-dom': '../../build/react-dom.js',
},
});
16 changes: 16 additions & 0 deletions fixtures/systemjs-builder/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="output.js"></script>
</body>
</html>
Loading