Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1 from wincent/no-implicit
Browse files Browse the repository at this point in the history
Don't rely on transparent global access to React, Relay, ReactDOM
  • Loading branch information
wincent committed Sep 30, 2015
2 parents d9dd225 + 72d23a9 commit a85dfcd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
5 changes: 5 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'babel/polyfill';

import App from './components/App';
import AppHomeRoute from './routes/AppHomeRoute';
import React from 'react';
import ReactDOM from 'react-dom';
import Relay from 'react-relay';

ReactDOM.render(
<Relay.RootContainer
Expand Down
3 changes: 2 additions & 1 deletion js/components/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'babel/polyfill';
import React from 'react';
import Relay from 'react-relay';

class App extends React.Component {
render() {
Expand Down
2 changes: 2 additions & 0 deletions js/routes/AppHomeRoute.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Relay from 'react-relay';

export default class extends Relay.Route {
static queries = {
viewer: () => Relay.QL`
Expand Down
12 changes: 0 additions & 12 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@
// Force `fetch` polyfill to workaround Chrome not displaying request body
// in developer tools for the native `fetch`.
self.fetch = null;
function warnRelayMissing() {
document.body.innerHTML = (
'<h2>Could not find relay.js</h2>' +
'<p>' +
'Be sure to run <code>npm run build</code> ' +
'in the <code>relay/</code> directory.' +
'</p>'
);
}
</script>
<script src="http://localhost:3000/webpack-dev-server.js"></script>
<script src="react/react.min.js"></script>
<script src="react/react-dom.min.js"></script>
<script src="relay/relay.js" onerror="warnRelayMissing()"></script>
<script src="js/app.js"></script>
</body>
</html>
13 changes: 3 additions & 10 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ var compiler = webpack({
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {stage: 0, plugins: ['./build/babelRelayPlugin']}
query: {stage: 0, plugins: ['./build/babelRelayPlugin']},
test: /\.js$/,
}
]
},
Expand All @@ -37,14 +38,6 @@ var app = new WebpackDevServer(compiler, {
});
// Serve static resources
app.use('/', express.static(path.resolve(__dirname, 'public')));
app.use(
'/react',
express.static(path.resolve(__dirname, 'node_modules/react/dist'))
);
app.use(
'/relay',
express.static(path.resolve(__dirname, 'node_modules/react-relay/dist'))
);
app.listen(APP_PORT, () => {
console.log(`App is now running on http://localhost:${APP_PORT}`);
});

0 comments on commit a85dfcd

Please sign in to comment.