-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
- I confirm that this is a issue rather than a question.
Bug report
Version
vuepress/1.0.0-alpha.39
Steps to reproduce
The shortest reproduction is to run these two commands in your developer console:
eval('function f(a) { return a }')
// undefined
eval('(a) => a')
// (a) => aTo see this in the context of vuepress, create a blank project that uses @vuepress/pagination, and then pass a normal function (not an arrow function) to either postsSorter or postsFilter. Since that plugin uses eval to recover those functions:
https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/plugin-pagination/enhanceAppFile.js#L8
undefined will be returned, and the build will fail, saying that undefined isn't a function.
Similarly, if someone defines their postsSorter or postsFilter as an anonymous normal function, eval will throw a SyntaxError:
eval('function () {}')
// Uncaught SyntaxError: Unexpected token ( at <anonymous>:1:1What is expected?
The plugin should successfully recover either kind of function.
What is actually happening?
The plugin throws an error, saying that undefined is not a function.
Other relevant information
- Your OS:
Ubuntu 18.04 - Node.js version:
node-v11.8.0 - Browser version:
Chrome 72 on Linux - Is this a global or local install?
global - Which package manager did you use for the install?
npm