In this file
import React from 'react'
import { Route, IndexRoute } from 'react-router/es'
import Root from './modules/Root'
import Page from './modules/Page'
function errorLoading(err) {
console.error('Dynamic page loading failed', err)
}
function loadRoute(cb) {
return module => cb(null, module.default)
}
/*
* @param {Redux Store}
*/
export default () =>
<Route component={Page}>
<Route path="/" component={Root}>
<Route
path="/info(/:category)"
getComponent={(location, cb) => {
import(
/* webpackChunkName : "info" */
'./modules/info/containers/Layout')
.then(loadRoute(cb))
.catch(errorLoading)
}}
/>
</Route>
</Route>
Problem is in comment /* webpackChunkName : "info" */. From console.it works.
Thank you for submitting this issue. Will start looking into this asap.
Hi @alex-shamshurin,
This issue is caused by the prettier flow parser itself. I have created a issue on it so that you can further track it (https://github.com/prettier/prettier/issues/2588).
In the meantime you can work around this by using 'babylon' parser. In order to do that you can add this line to your .vimrc
g:prettier#config#parser = 'babylon'
Since this is not a bug in vim-prettier itself I will be closing this issue, but please feel free to add more comments in here.
Looks like this is a known issue on prettier and they closed the issue I have created as duplicate, they are handling that case now in here https://github.com/prettier/prettier/issues/2555
I just ran into this. The issue actually seems to be that vim-prettier is defaulting to the flow parser while according to this comment babylon is the default, and more capable parser. It might be better if the default parser for vim-prettier matches the default parser for prettier.
Hi @sleepycat,
To give a bit more context around the default choices for vim-prettier.
We are following the settings for FB and that uses the flow parser.
However since prettier now supports custom configuration (prettier 1.7+) you can now overwrite this behavior by creating ~/.prettierrc or the already supported .vimrc configuration.
vim-prettier will give higher precedence to .prettierrc configurations, then if none is found it will try .vimrc configurationyours and only then if none is found will default to the custom default settings (FB options)
Hi @mitermayer,
I am getting this error message. I have tried setting the parser to babylon from my vimrc. I am still observing the same error. Any idea what else could be wrong?
Hi @ferdinandsalis,
Could you please provide me a bit more information about your environment ?
:PrettierVersion):PrettierCliVersion)@ferdinandsalis Updating to the newest version of vim-prettier fixed it for me.
@Mike-Now I am using the latest version
@mitermayer sorry for providing insufficient information
Accoring to ./node_modules/.bin/prettier its version 1.7.4
The following is code that I am trying to parse and that returns the error. Though this is true for any piece of code.
import styled from 'react-emotion';
import { space, fontSize, width, color, propTypes } from 'styled-system';
const base = props => ({
fontFamily: props.theme.fonts[1]
});
const Text = styled('div')(base, space, fontSize, width, color);
Text.propTypes = Object.assign(
{},
propTypes.fontSize,
propTypes.space,
propTypes.width,
propTypes.color
);
Text.defaultProps = {};
Text.displayName = 'Text';
Text.p = Text.withComponent('p');
Text.span = Text.withComponent('span');
export default Text;
This the relevant config in my vimrc.
let g:prettier#autoformat = 0
let g:prettier#exec_cmd_async = 1
let g:prettier#config#parser = 'babylon'
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql PrettierAsync
Thank you for helping out.
Hi @ferdinandsalis,
Sorry that you are experiencing this issues, we will help you figure out why and unblock you. I have tried to reproduce this issue locally unsuccessfully, so I may need to ask you some more questions.
vim by checking on :version ?:PrettierCliVersionThanks for your patience, and hopefully we can unblock you soon
My nvim :version output
NVIM v0.2.0
Build type: Release
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNDEBUG -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fs
tack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20170916-87078-1f9fi5o/neovim-0.2.0/build/config -I/tmp/neovim-20170916-87078-1f9fi5o/neovim-0.2.0/src -I/usr/local/include -I/usr/local/include -I/usr/local/inc
lude -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20170916-87078-1f9fi5o/neovim-0.2.0/build/src/nvim/auto -I/tmp/neovim-20170916-87078-1f9fi5o/neovim-0.2.0/build/include
Compiled by [email protected]
Optional features included (+) or not (-): +acl +iconv +jemalloc +tui
For differences from Vim, see :help vim-differences
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.2.0_1/share/nvim"
:PrettierCliVersion does not provide any visible output
There is also no prettier configuration besides the one in my .vimrc (see above). I can also confirm that vim-prettier works for me with system installed vim and the latest installed via homebrew.
Thanks again for your help. For now I will just use vim and not neovim, since prettier is essential to my dev workflow 鈽猴笍.
a :PlugUpdate followed by a restart did the trick for me
Found a weird way to reproduce this error. If the path of the file has a $ in it, then the failed to parse buffer message appears.
For instance, if the file currently opened is in a directory $foo the error will happen. :]
I ran into this today. You can also get this error if there is a syntax error in your package.json, probably because Prettier looks for a prettier config there and is unable to parse the file.
It might help if instead of saying "failed to parse buffer" in this case to say exactly which buffer failed to parse.
@mjackson
That鈥檚 a good idea, will do that!
Most helpful comment
I ran into this today. You can also get this error if there is a syntax error in your
package.json, probably because Prettier looks for aprettierconfig there and is unable to parse the file.It might help if instead of saying "failed to parse buffer" in this case to say exactly which buffer failed to parse.