Webpacker: Compilation error with react-boilerplate

Created on 31 Mar 2017  路  8Comments  路  Source: rails/webpacker

I'm trying to integrate react-boilerplate and am getting compilation errors:

```ERROR in ./app/javascript/packs/app.js
Module build failed: SyntaxError: (106:12)

104 | if (!window.Intl) {
105 | (new Promise((resolve) => {

106 | resolve(import('intl'));
| ^
107 | }))
108 | .then(() => Promise.all([
109 | import('intl/locale-data/jsonp/en.js'),

ERROR in ./app/javascript/packs/reducers.js
Module build failed: SyntaxError: Unexpected token (47:4)

45 | route: routeReducer,
46 | language: languageProviderReducer,

47 | ...asyncReducers,
| ^
48 | });
49 | }
50 |

ERROR in ./app/javascript/packs/routes.js
Module build failed: SyntaxError: Unexpected token (24:10)

22 | getComponent(nextState, cb) {
23 | const importModules = Promise.all([

24 | import('containers/HomePage'),
| ^
25 | ]);
26 |
27 | const renderRoute = loadModule(cb);

ERROR in ./app/javascript/packs/store.js
Module build failed: SyntaxError: 'import' and 'export' may only appear at the top level (49:6)

47 | if (module.hot) {
48 | module.hot.accept('./reducers', () => {

49 | import('./reducers').then((reducerModule) => {
| ^
50 | const createReducers = reducerModule.default;
51 | const nextReducers = createReducers(store.asyncReducers);
52 |
```

All I did was drop react-boilerplate/app into app/javascript/packs and pointed manifest.json at app.js.

I also asked a question on Stack Overflow. Configuration for boilerplate and webpacker is complex and I'm not sure how to proceed.

Most helpful comment

Great 馃憤 There is another similar issue. Will make a PR to move all this config to .babelrc instead of inline presets. Thank you

All 8 comments

@reedlaw You would need appropriate babel loader or please upgrade the node version - http://node.green/ and the babel presets can be found here - https://github.com/react-boilerplate/react-boilerplate/blob/master/package.json#L51

@gauravtiwari I'm on node v7.7.3. I tried copying that section of package.json but I get the same errors.

@reedlaw I think it's because inline presets are overriding it. Could you remove options section from config/webpack/loaders/babel.js and config/webpack/loaders/react.js

@gauravtiwari sorry that doesn't work either. Feel free to look at the source.

@reedlaw Delete .babelrc please :)

@gauravtiwari that works! I'm getting different error messages which are more helpful. I'll continue on my own from here. Hopefully this can be useful to others.

Great 馃憤 There is another similar issue. Will make a PR to move all this config to .babelrc instead of inline presets. Thank you

Sorry to bump this but I can't seem to be able to get React Boilerplate working with this either. Were you able to solve it @reedlaw ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iChip picture iChip  路  3Comments

christianrojas picture christianrojas  路  3Comments

suhomlineugene picture suhomlineugene  路  3Comments

johan-smits picture johan-smits  路  3Comments

pioz picture pioz  路  3Comments