Giter Site home page Giter Site logo

isomorphic-flux-boilerplate's Introduction

Circle CI Coverage Status NPM Version

A complete ES7 Isomorphic Universal ReactJS boilerplate with alt as Flux library.

A wonderfull boilerplate for Flux/ReactJS universal applications, running on koajs.

Demo: http://isomorphic.iam4x.fr

Libraries used

Setup

  • 1. Requirements

  • 2. How to / Installation

    • $ git clone -o upstream https://github.com/iam4x/isomorphic-flux-boilerplate.git app
    • $ cd app && npm install or $ cd app && yarn install

    (Don't forget to add your remote origin: $ git remote add origin [email protected]:xxx/xxx.git)

Run

  • dev

    • $ npm run dev OR
    • $ PORT=xxxx npm run dev
  • test

    • $ npm test OR
    • $ npm test -- --watch
  • build and run in separate commands

    • $ NODE_ENV=production npm run build
    • $ NODE_ENV=production node server
  • Build and run prod env short version:

    • $ npm run start

Concepts

Koa will be our server for the server side rendering, we use alt for our Flux architecture and react-router for routing in our app.

With iso as helper we can populate alt flux stores before the first rendering and have a complete async isomorphic React application.

Run this boilerplate, you will see the server is fetching some fake users and will populate the UserStore with this data. Koa will render the first markup, serve the JavaScript and then it will entirely run on the client.

Flux

We use alt instance as Flux implementation.

We need to use instances for isomorphic applications, to have a unique store/actions per requests on the server.

On the client, Flux is initialized in app/main.js and sent to our first React Component via context (this.context.flux). Every time you want to uses stores or actions in a component you need to give it access through context.

On the server, it's similar but Flux is initialized in server/router.jsx. The instance is sent to alt-resolver for rendering components with the correct props.

Learn more about alt instances in the alt documentation.

There's also alt-devtools enabled in development, it's a Chrome Extension that you can find here: https://github.com/goatslacker/alt-devtool

Internationalization (i18n)

The boilerplate provides an easy way to use internationalization, it provides through context a function called i18n that does not break when translations are missing. No more react-intl/IntlMixin to load everywhere.

import { FormattedRelative } from 'react-intl';
...
static contextTypes = { i18n: PropTypes.func.isRequired }

render() {
  const { i18n } = this.context;
  return (
    <div>
      {/* You can pass values to `i18n` fn like `<FormattedMessage />` component */}
      <h1>{ i18n('some.random.i18n.key', { now: new Date() }) }</h1>

      {/* FormattedRelative, FormattedCurrency works out the box :+1: */}
      <FormattedRelative value={ Date.now() - (1000 * 60 * 60 * 24) } />
    </div>
  );
}

We use react-intl for internationalization, it uses browser implementation of Intl. For older browser and for node, we load the polyfill.

  • Support localized strings (see data/en.js)
  • Support localized dates, times and currencies.

Lang files and Intl polyfill are compiled into webpack chunks, for lazy-loading depending the locale of the user.

If user changes locale, it is saved into a cookie _lang and used by the server to know the locale of rendering. If there's no _lang cookie, server will rely on Accept-Language request header. Server will set <html lang='x'> on rendering.

Thank's to gpbl/react-locale-hot-switch for the implementation example!

Localized routes

We have an utility to generate severals routes for the same component (see app/utils/localized-routes.js).

Use the same logic as localized string, declare the localized routes into app/routes.js and into your data/{lang} file.

Progressive web app approach

We have included a service worker set-up using sw-precache-webpack-plugin into the boilerplate so your assets generated with webpack would get proxied to your users via service worker if it is available in the browser (see service worker browser support). Meaning faster loading times, offline support and many more. This only works in production mode, you can change the behavior though. More information on service workers could be found here: here

Async data-fetching

Alt-resolver is the magic thing about the boilerplate, it will be our tool for resolving promises (data-fetching) before server side rendering.

Alt-resolver expose also an ApiClient for doing the requests to the intern API. It handle for you the cookies on server and URI matching between server and browser.

Wrap data-fetching requests from actions into promises and send them to altResolver like:

show(id) {
  // You need to return a fn in actions
  // to get alt instance as second parameter to access
  // `alt-resolver` and the ApiClient
  return (dispatch, { resolve, request  }) =>
  // We use `alt-resolver` from the boilerplate
  // to indicate the server we need to resolve
  // this data before server side rendering
    resolve(async () => {
      try {
        const response = await request({ url: '/users' });
        this.actions.indexSuccess(response);
      } catch (error) {
        this.actions.indexFail({ error });
      }
    });
}

Call the fetch action from component in the componentWillMount method:

import React, { Component, PropTypes } from 'react';
import connect from 'connect-alt';

// connect-alt is an util to connect store state to component props
// you can read more about it here: http://github.com/iam4x/connect-alt
// it handle store changes for you :)
//
// users -> store name
// collection -> `this.collection` into users store
//
@connect(({ users: { collection } }) => ({ users: collection }))
class Users extends Component {

  static contextTypes: { flux: PropTypes.object.isRequired }
  static propTypes: { users: PropTypes.array.isRequired }

  componentWillMount() {
    const { flux } = this.context
    return flux.getActions('users').fetch();
  }

  render() {
    const { users } = this.props;
    return (<pre>{ JSON.stringify(users, null, 4) }</pre>)
  }
}

On browser side, the rendering won't be stopped and will resolve the promise instantly.

On server side, altResolver.render will fire a first render to collect all the promises needed for a complete rendering. It will then resolve them, and try to re-render the application for a complete markup.

Open app/actions/users.js, app/utils/alt-resolver.js, app/stores/users.js for more information about data-fetching.

How to require() images on server side

On client with webpack, you can directly require() images for your images DOM element like:

<img src={require('images/logo.png')} />

Webpack will load them through the url-loader and if it's too big it will sent through file-loader for minification/compilation. The results is an image with a new filename for cache busting.

But on node, require() an image will just throw an exception. There's an util for loading image on server side to achieve this:

import imageResolver from 'utils/image-resolver'

let image;
// On browser just require() the image as usual
if (process.env.BROWSER) {
  image = require('images/logo.png');
}
else {
  image = imageResolver('images/logo.png');
}

...
render () {
  return (
    <img src={image} />
  );
}
...

The utils/image-resolver with match the original image name with the compiled one.

Voilà! You can require() images on server side too.

Run the project in development:

  • $ npm run dev

Open your browser to http://localhost:3002 and you will see the magic happens! Try to disable JavaScript in your browser, you will still be able to navigate between pages of the application. Enjoy the power of isomorphic applications!

(Note: ports 3000-3002 are needed, you can change this with $ PORT=3050 npm run dev it will run on 3050-3052)

Update the boilerplate

You can fetch the upstream branch and merge it into your master:

  • $ git checkout master
  • $ git fetch upstream
  • $ git merge upstream/master
  • $ npm install

Run in production

Build the project first:

  • $ npm run build

Then start the koa server:

  • $ NODE_ENV=production node server/index.js

You can also use processes.json to run the application with PM2 Monitor on your production server (customize it for your use):

  • $ pm2 start processes.json

(OSX) Run into docker for development

You can build and dev with the boilerplate through docker container, it runs with dinghy.

  • Install dinghy (it has support for NFS sharing which is required for changes detection and it's fast!)
  • $ dinghy up
  • $ docker-compose build (don't kill your terminal it take time to install node_modules for dev)
  • $ docker-compose up

Then open http://webapp.docker into your browser. (You can change this URL into docker-compose.yml)

Learn more

isomorphic-flux-boilerplate's People

Contributors

adamjv90 avatar aegyed91 avatar allenfang avatar bitdeli-chef avatar doodledood avatar drosen0 avatar eugenehlushko avatar greenkeeperio-bot avatar heidar avatar iam4x avatar iquabius avatar jaredkotoff avatar jasonlfunk avatar jbroadice avatar jeremymarc avatar joeframbach avatar kennyt avatar lancetw avatar maxsvargal avatar mayashaddad avatar nuragic avatar quicksnap avatar sogko avatar tabakd avatar tee-yankov avatar tizmagik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

isomorphic-flux-boilerplate's Issues

core-js error

Hello, trying to "npm run dev" on latest master with node 0.12.2. But getting a error.

node --harmony ./webpack/dev-server.js

module.js:338
throw err;
^
Error: Cannot find module 'core-js/shim'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/Users/subpublic/Documents/jobb/rnd/rnd_node/react/isomorphic-flux-boilerplate/node_modules/babel-core/lib/babel/polyfill.js:3:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)

node-sass makes Webpack hang when importing SASS files several times

I'm posting this issue as a warning for other people that come across this problem (and it doesn't take long).

This issue is being discussed on the following URLs:

Basically, node-sass has a bug which makes SASS compilation hang when you're importing the same SASS file (common mixins, colors etc.) more than a few times. Now, Webpack needs those imports to compile assets properly, but you can't use the imports and the circle is complete.

What makes this a hard bug to catch comes down to several factors:

  • It works fine the first couple of imports
  • The application continues working with hot replacement, it's only when you exit and restart the server the problem appears
  • There is no feedback whatsoever, the building process simply hangs forever

Even though I really like SASS (I've been using it since its early Ruby days), it might be better to replace it with a different preprocessor (postcss using cssnext springs to mind).

react-intl:FormattedRelative always returns English

Like this:

// Import FormattedRelative
import {IntlMixin, FormattedRelative} from 'react-intl';

// In render() 
<FormattedRelative value={Date.now() - (1000 * 60 * 60 * 24)} />

No matter what the current language is, it is always return 'yesterday'.

2015-06-02 3 54 02

Passing router context to services

I'm struggling with a way to pass context from the router (e.g., current params) to services with the new promise interface. Or is there some... fluxier way?

Any ideas? Thanks for all the great work on this, especially the recent updates. Is there a place of open issues we could help with?

Can't run on windows 8.1

When I try to run 'npm run dev' I get the following error:
'DEBUG' is not recognized as an internal or external command

Memory consumption

Unfortunately the gulpfile takes a lot of memory and thus breaks in cloud9. Any chance to modify the settings to reduce this?

Reloading Weirdness

I'm working on bringing an app up to date with the latest webpack changes and noticed some weird behavior with regards to reloading.

Since webpack is now loading images, I was replacing some <img /> tags in JSX so webpack could find them (e.g., <img src={require('../images/foo.jpg')} />). What's odd is hot reloading worked fine, but when hard-refreshing the page from the server I experienced an error.

Here is a little video I made while making the changes: http://assets.kevinmarsh.com.s3.amazonaws.com/20150414-Reloading-Weirdness.mp4

You can see hot reloading working well, then hard refreshing a the page with an error (not having the previous change), then reloading the server which results in a 500 error.

I tried this with the latest version of isomorphic-flux-boilerplate and it exhibits the same behavior. Hot reloading works fine, but refreshing the browser shows the previous version without the change.

Error: `libsass` bindings not found. Try reinstalling `node-sass`?

Hi,
I tried to run npm run dev and got errors:

Error: `libsass` bindings not found. Try reinstalling `node-sass`?
    at getBinding (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:22:11)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:188:23)
    at Module._compile (module.js:410:26)
    at Module._extensions..js (module.js:428:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/octopitus/projects/app/node_modules/babel/lib/babel/api/register/node.js:130:7)
    at Module.load (module.js:335:32)
    at Function.Module._load (module.js:290:12)
    at Module.require (module.js:345:17)
    at require (module.js:364:17)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/sass-loader/index.js:4:12)
Error: `libsass` bindings not found. Try reinstalling `node-sass`?
    at getBinding (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:22:11)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:188:23)
    at Module._compile (module.js:410:26)
    at Module._extensions..js (module.js:428:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/octopitus/projects/app/node_modules/babel/lib/babel/api/register/node.js:130:7)
    at Module.load (module.js:335:32)
    at Function.Module._load (module.js:290:12)
    at Module.require (module.js:345:17)
    at require (module.js:364:17)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/sass-loader/index.js:4:12)
Error: `libsass` bindings not found. Try reinstalling `node-sass`?
    at getBinding (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:22:11)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:188:23)
    at Module._compile (module.js:410:26)
    at Module._extensions..js (module.js:428:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/octopitus/projects/app/node_modules/babel/lib/babel/api/register/node.js:130:7)
    at Module.load (module.js:335:32)
    at Function.Module._load (module.js:290:12)
    at Module.require (module.js:345:17)
    at require (module.js:364:17)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/sass-loader/index.js:4:12)
Error: `libsass` bindings not found. Try reinstalling `node-sass`?
    at getBinding (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:22:11)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:188:23)
    at Module._compile (module.js:410:26)
    at Module._extensions..js (module.js:428:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/octopitus/projects/app/node_modules/babel/lib/babel/api/register/node.js:130:7)
    at Module.load (module.js:335:32)
    at Function.Module._load (module.js:290:12)
    at Module.require (module.js:345:17)
    at require (module.js:364:17)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/sass-loader/index.js:4:12)
Error: `libsass` bindings not found. Try reinstalling `node-sass`?
    at getBinding (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:22:11)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/node-sass/lib/index.js:188:23)
    at Module._compile (module.js:410:26)
    at Module._extensions..js (module.js:428:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/octopitus/projects/app/node_modules/babel/lib/babel/api/register/node.js:130:7)
    at Module.load (module.js:335:32)
    at Function.Module._load (module.js:290:12)
    at Module.require (module.js:345:17)
    at require (module.js:364:17)
    at Object.<anonymous> (/home/octopitus/projects/app/node_modules/sass-loader/index.js:4:12)

Any ideas?

browsersync polling is spamming my terminal output

When I run the dev server, my terminal is spammed with this:

<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193331-7236
dev first render +23ms
dev second render +8ms
dev return html content +3ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193331-7236 200 33ms -
<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193366-7237
dev first render +14ms
dev second render +4ms
dev return html content +9ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193366-7237 200 26ms -
<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193392-7238
dev first render +25ms
dev second render +5ms
dev return html content +3ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193392-7238 200 34ms -
<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193267-7234
dev first render +18ms
dev second render +4ms
dev return html content +3ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193267-7234 200 25ms -
koa blocked for 42ms +1ms
<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193447-7240
dev first render +16ms
dev second render +3ms
dev return html content +4ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193447-7240 200 25ms -
<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193471-7241
dev first render +30ms
dev second render +5ms
dev return html content +4ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193471-7241 200 37ms -
<-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193492-7242
dev first render +15ms
dev second render +4ms
dev return html content +3ms
--> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1429553193492-7242 200 22ms -

It just keeps coming. If something actually important happens, I wouldn't know.

How can I at least tame this polling to, say, once every 2000ms rather than repeatedly?

Use localized routes

Now that the boilerplate use react-intl for internationalization we should be able to have different routes for the same handler.

It's a must have for SEO.

Better docs - specifically views / actions / stores

I'm slowing working through this, but we could really use a little more documentation on how to wire up new actions, views and stores.

The approach in the boilerplate diverges enough from the basic alt docs that it's really difficult to figure out what's going on.

I've successfully wired up a new set, but I don't understand it well enough to 1) feel secure that i've done it right and 2) do the documentation myself

For example, I know I need to add this to my view to access this.setState

_handleStoreChange = this._handleStoreChange.bind(this);

but I have no idea why :)

The docs on async data fetching is great, so more of that type of thing would be great.

A step by step guide to adding a new action, store and view would be good. Items like "make sure you add them both to utils/flux.js"

Additionally, I have no idea what the request store is supposed to be doing :)

Anyway, this is the best boilerplate I've found, so keep up the good work!

a bunch of errors after install

i followed the instruction @ readme, but stumbled upon this errors, right after npm run dev

ERROR in ./app/utils/flux.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/utils/flux.js
  6:6  error  Flux is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/utils/alt-resolver.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/utils/alt-resolver.js
  9:21  error  AltResolver is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/actions/users.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/actions/users.js
  7:6  error  UsersActions is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/actions/locale.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/actions/locale.js
  5:6  error  LocaleActions is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/actions/page-title.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/actions/page-title.js
  3:6  error  PageTitleActions is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/actions/requests.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/actions/requests.js
  3:6  error  RequestsActions is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/stores/requests.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/stores/requests.js
  3:6  error  RequestsStore is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/stores/locale.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/stores/locale.js
  5:6  error  LocaleStore is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/stores/users.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/stores/users.js
  5:6  error  UsersStore is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)
ERROR in ./app/stores/page-title.js
/Users/oleg/code/isomorphic-flux-boilerplate/app/stores/page-title.js
  5:6  error  PageTitleStore is already declared in the upper scope  no-shadow
✖ 1 problem (1 error, 0 warnings)

browser-sync flood and memory leaks

I don't know whose this problem, but wrote here.
Browser-sync sockets hightly flood to stdout even then page is closed.
And i see memory leaks in browser.
Anybody met this problem?

Application started on port 3000
  koa blocked for 728ms +0ms
  <-- GET /
[BS] Proxying: http://localhost:3000
[BS] Access URLs:
 ------------------------------------
       Local: http://localhost:8080
    External: http://192.168.1.2:8080
 ------------------------------------
          UI: http://localhost:3002
 UI External: http://192.168.1.2:3002
 ------------------------------------
  dev locale of request: en +836ms
  dev first render +3ms
  dev update page title to 'ISO-ReactJS | Users' +21ms
  koa blocked for 565ms +13ms
  <-- GET /
  dev locale of request: en +10ms
  dev first render +2ms
  dev update page title to 'ISO-ReactJS | Users' +13ms
  dev second render +279ms
  dev update page title to 'ISO-ReactJS | Users' +7ms
  dev return html content +20ms
  koa blocked for 28ms +2ms
  dev second render +0ms
  dev update page title to 'ISO-ReactJS | Users' +7ms
  dev return html content +17ms
  --> GET / 200 1,016ms -
  --> GET / 200 384ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470589-15169
  dev locale of request: en +1s
  dev first render +2ms
  dev second render +8ms
  dev return html content +7ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470589-15169 200 24ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470624-15170
  dev locale of request: en +13ms
  dev first render +0ms
  dev second render +8ms
  dev return html content +7ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470624-15170 200 22ms -
  koa blocked for 22ms +1ms
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470651-15171
  dev locale of request: en +11ms
  dev first render +0ms
  dev second render +10ms
  dev return html content +8ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470651-15171 200 25ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470682-15172
  dev locale of request: en +13ms
  dev first render +1ms
  dev second render +7ms
  dev return html content +17ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470682-15172 200 31ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470719-15173
  dev locale of request: en +10ms
  dev first render +0ms
  dev second render +8ms
  dev return html content +7ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470719-15173 200 20ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470744-15174
  dev locale of request: en +11ms
  dev first render +1ms
  dev second render +7ms
  dev return html content +8ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470744-15174 200 22ms -
  koa blocked for 20ms +1ms
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470771-15175
  dev locale of request: en +10ms
  dev first render +1ms
  dev second render +7ms
  dev return html content +9ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470771-15175 200 22ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470799-15176
  dev locale of request: en +11ms
  dev first render +0ms
  dev second render +8ms
  dev return html content +10ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470799-15176 200 24ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470829-15177
  dev locale of request: en +11ms
  dev first render +1ms
  dev second render +7ms
  dev return html content +7ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470829-15177 200 20ms -
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470854-15178
  dev locale of request: en +10ms
  dev first render +0ms
  dev second render +10ms
  dev return html content +9ms
  --> GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470854-15178 200 24ms -
  koa blocked for 12ms +1ms
  <-- GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1431977470884-15179
  dev locale of request: en +14ms
  dev first render +0ms
  dev second render +8ms
  dev return html content +7ms


... to infinity

Koa to Express

Is it possible to make a concurrent branch where the source is based on express?

Use Alt instance with <AltContainer />

Change alt to instances, it will solve problems on server side rendering when two requests arrives at the same time and they're doing async operations!

With new Alt version, the <AltContainer /> is more documented, the switch maybe interesting!

  • alt.js.org/docs/altInstances
  • alt.js.org/docs/components/altContainer/

Declared errors on start

On first start server i have many variabels declared errors in bundle compile:

> node --harmony ./webpack/dev-server.js

Time: 9689ms
                      Asset     Size  Chunks       Chunk Names
                1h0uCyf.eot  21.4 kB
                YXLsN8c.svg  71.8 kB
                2J_BsMc.ttf  45.3 kB
               3sk6Jfr.woff    25 kB
                V2d-uc_.png    49 kB
app-9697fd3a3232a7f92bd3.js  4.84 MB       0       app
  1-12170997047ad81dc91b.js   381 kB    1, 3
  2-fe4f7caecfff8bd789ea.js   376 kB    2, 4
  3-834397ac1efd83c78972.js  3.37 kB       3
  4-d0cf4a9def770669b2ed.js  3.31 kB       4

ERROR in ./app/utils/flux.js

/isomorphic-flux-boilerplate/app/utils/flux.js
  6:6  error  Flux is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/utils/alt-resolver.js

/isomorphic-flux-boilerplate/app/utils/alt-resolver.js
  9:21  error  AltResolver is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/actions/users.js

/isomorphic-flux-boilerplate/app/actions/users.js
  7:6  error  UsersActions is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/actions/requests.js

/isomorphic-flux-boilerplate/app/actions/requests.js
  3:6  error  RequestsActions is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/actions/page-title.js

/isomorphic-flux-boilerplate/app/actions/page-title.js
  3:6  error  PageTitleActions is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/actions/locale.js

/isomorphic-flux-boilerplate/app/actions/locale.js
  5:6  error  LocaleActions is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/stores/requests.js

/isomorphic-flux-boilerplate/app/stores/requests.js
  3:6  error  RequestsStore is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/stores/locale.js

/isomorphic-flux-boilerplate/app/stores/locale.js
  5:6  error  LocaleStore is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/stores/users.js

/isomorphic-flux-boilerplate/app/stores/users.js
  5:6  error  UsersStore is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/stores/page-title.js

/isomorphic-flux-boilerplate/app/stores/page-title.js
  5:6  error  PageTitleStore is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)

webpack: bundle is now VALID.

I suppose this modules recursively (?) required, but i now idea where is. Or it's webpack problem. I update it but change nothing.

Server redirect not working

If i define a redirect route

<Route name='another' handler={} />
<Redirect from='/from' to='another' />

and the initial request is set to /from then page load just seems to hang.

I did notice that there was a TODO note inside server/router.js

// TODO: Try to render the good page with re-creating a Router,
// and with modifying req with `redirect.to`

Inside that onAbort function you seem to be setting the status and redirecting with koa functions but this would reference the instance of the router.

I don't really care about rendering the initial page. Just wondering if you had any input on this or have already thought of a solution.

transform undefined

came across this error when trying to boot up the boilerplate.

ERROR in ./app/index.js

/Users/adam/Code/smp/vault/app/index.js
  0:0  error  transform is not defined

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/main.js

/Users/adam/Code/smp/vault/app/main.js
  0:0  error  transform is not defined

this error occurs for almost every js file. any ideas?

reset

Hello

Install ok on local Win : great !
I have a reset bug :

When i delete all profiles
and add random profile
and show this new profile
and click "users list"
Then i must show one profile
But i show ten new profiles !

How disable reset of profiles when i back to 'home' page

how to resolve promises only once?

we have first render and second render, this leads 3 requests to server side when rendering:

  1. first render: collect promises
  2. second render: componentWillMount will be called again
  3. browser render: componentWillMount will be called in browser.

how can i deal with this?

React checksum warning when using `style` prop on components

When I use a style prop on a component, React throws a warning:

Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) sten Wiig Movie HD" style="width:50vw;he
 (server) sten Wiig Movie HD" data-reactid=".18afr

It looks like the style prop is only rendered on the client side. Any idea how I can fix this? I want to be able to style a component directly, instead of having to add CSS rules in another file.

Problem with CSS in dev mode

When I start npm run dev and disable JS in the browser I loose styles for all elements on the page:
screen shot 2015-06-03 at 23 17 19

However demo at your web-site works good with disabled JS.

I've copied part from your prod.config.js file regarding
loader: ExtractTextPlugin.extract('style', 'css!autoprefixer?browsers=last 2 version!sass')
and everything starts to work properly, but I'm not familiar with webpack neither with JS and not sure it is right way to fix the problem.

How to access router or route progmatically?

What's the best way to access the router from the client? Specifically I want to transition users on log in or log out. Should I add the router as a property on the alt container?

Alt-resolver should clean up promises earlier

Currently, alt-resolver cleans up toResolve after all promises are resolved.

https://github.com/iam4x/isomorphic-flux-boilerplate/blob/master/app/utils/alt-resolver.js#L57

However, if there is another request coming in when the previous request's promises are not fully resolved yet, the second request would have to wait for the previous request's promises as well, since the previous request's promises are still inside toResolve. Although it does not affect the data integrity (since data in different requests are still kept inside different contexts), it may hurt the throughput of the server-side app.

Help understanding set up

I'm sorry, this isn't an issue exactly.

I've been trying for a few hours to wrap my head around how this boilerplate is set up and I am just completely confused.

I wanted to add auth and an API. It seemed like I'd need to set up some new routes so I tried using Koa router and the mount middleware the same way the assets are being loaded. But I kept 404ing on the URL.

So I played around with it, commented things out, added dev logs, and it seemed like none of my logs were reaching the console. I copied/pasted one of the existing dev calls a few times and only one went through. Changed text etc. Stopped and restarted the dev server.

Putting a console.log outside of a function, at the root of the file would send it to the console but if I put it inside of any existing or new function it would just disappear.

I commented out nearly everything in the koa.js file and somehow the default app was still being served. I assume this is either caching, or proxying from WebPack.

How would I go about adding new routes API routes, not component routes?

It doesn't seem like the webpack config is really doing anything crazy so I just feel silly asking this.

If I figure it out on my own I'll close the issue and either comment with a little how-to or put a pull-request with a new doc section if you'd like.

Use Inline CSS

Following the advice from React CSS In JS,
advice from the official documentation of react it self, and my own experiments, I think it would be a nice replacement to sass in the boilerplate.

What do you think?

Libraries such as react-inline-css or radium can be helpful if it is decided to adopt this idea.

Error in alt-resolver

On a fresh clone of the repository I get the following error on npm run build:

ERROR in ./app/utils/alt-resolver.js

/home/blittle/dev/app/app/utils/alt-resolver.js
  24:24  error  "object" is not defined  no-undef
  24:38  error  "object" is not defined  no-undef

✖ 2 problems (2 errors, 0 warnings)

Webpack assets use localhost:{port} on remote devices

This issue seems to be explained at https://gist.github.com/MrOrz/4f3da17fd73dbb4c7668
I quickly tried out the solution, but it didn't solve the problem right away. I'll probably look into this myself one of the coming days and send you a PR, or at least try to.

It's quite easy to reproduce:

  1. Start the dev server
  2. Use a remote device to go to the external ip mentioned in the BrowserSync output
  3. See 404s on the webpack assets, and the base URL being localhost:{port}

on windows, localhost:3002 hangs

Running Windows 8.1 x64 and node v0.12.4, the startup process seems to go smoothly, it opens a browser window pointed at

http://localhost:3002/

... and nothing happens

console content:

C:\Learning\isomorphic-flux-boilerplate>npm run dev

> [email protected] dev C:\Learning\isomorphic-flux-boilerplate
> node --harmony ./webpack/dev-server.js

Time: 4122ms
                      Asset     Size  Chunks             Chunk Names
                1h0uCyf.eot  21.4 kB          [emitted]
                1b8EiXF.svg  72.4 kB          [emitted]
                2J_BsMc.ttf  45.3 kB          [emitted]
               3sk6Jfr.woff    25 kB          [emitted]
                V2d-uc_.png    49 kB          [emitted]
app-078e987500c0d7438ea8.js  4.89 MB       0  [emitted]  app
  1-dcbd4e3dd800a21f01e8.js   381 kB    1, 3  [emitted]
  2-cb52fcb3d7da8bb6b01e.js   376 kB    2, 4  [emitted]
  3-c65670473acb8e580e95.js  3.77 kB       3  [emitted]
  4-0170e24063f2c2cfaebb.js  3.81 kB       4  [emitted]
webpack: bundle is now VALID.
  koa blocked for 543ms +0ms
[BS] [info] Reloading Browsers...
  koa blocked for 421ms +0ms
[BS] Proxying: http://0.0.0.0:3000
[BS] Access URLs:
 --------------------------------------
       Local: http://localhost:3002
    External: http://192.168.2.157:3002
 --------------------------------------
          UI: http://localhost:3003
 UI External: http://192.168.2.157:3003
 --------------------------------------

Latest code starts and runs fine in an ubuntu vm for me.

If I hit localhost:3000, the app actually comes up and works - so I'm not entirely sure what the point in 3002 is :)

Any thoughts?

parse error in spinner.scss

"npm run dev" throws the following error running io.js v1.7.1 on OSX

> [email protected] dev /Users/rdg/repos/isomorphic-flux-boilerplate
> DEBUG=dev,koa node ./webpack/dev-server.js

  dev `webpack-dev-server` listen on port 3001 +0ms
  dev `webpack-stats.json` updated +7s
Time: 6570ms
                      Asset     Size  Chunks             Chunk Names
                1h0uCyf.eot  21.4 kB          [emitted]  
                YXLsN8c.svg  71.8 kB          [emitted]  
                2J_BsMc.ttf  45.3 kB          [emitted]  
               3sk6Jfr.woff    25 kB          [emitted]  
                V2d-uc_.png    49 kB          [emitted]  
app-7d6827f12e2cc4f9a70a.js  4.33 MB       0  [emitted]  app
webpack: bundle is now VALID.
/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/babel/helpers/parse.js:70
    throw err;
          ^
SyntaxError: /Users/rdg/repos/isomorphic-flux-boilerplate/app/styles/spinner.scss: Unexpected token (1:0)
> 1 | .app--spinner {
    | ^
  2 |   background-image: url('../images/spinner.svg');
  3 |   background-repeat: no-repeat;
  4 |   display: none;
    at Parser.pp.raise (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/location.js:68:13)
    at Parser.pp.unexpected (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/parseutil.js:87:8)
    at Parser.pp.parseExprAtom (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:373:12)
    at Parser.parseExprAtom (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/plugins/jsx.js:593:162)
    at Parser.pp.parseExprSubscripts (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:217:19)
    at Parser.pp.parseMaybeUnary (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:199:19)
    at Parser.pp.parseExprOps (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:155:19)
    at Parser.pp.parseMaybeConditional (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:138:19)
    at Parser.pp.parseMaybeAssign (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:106:19)
    at Parser.pp.parseExpression (/Users/rdg/repos/isomorphic-flux-boilerplate/node_modules/babel-core/lib/acorn/src/expression.js:81:19)

Use with node

Is there any modification I can make to this setup to be able to run with node instead of iojs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.