Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function in plugin options is filtered #1643

Open
2 of 3 tasks
dongyuanxin opened this issue Jun 8, 2019 · 0 comments
Open
2 of 3 tasks

Function in plugin options is filtered #1643

dongyuanxin opened this issue Jun 8, 2019 · 0 comments

Comments

@dongyuanxin
Copy link

dongyuanxin commented Jun 8, 2019

  • I confirm that this is an issue rather than a question.

Bug report

I'm writing a comment plugin for vuepress. It should listen router change and refresh automaticly.

However, when the user sets the option to a function, the option seems to be filtered and disappear.

Steps to reproduce

① Register local plugin

module.exports = {
  // ...
  plugins: [
    [
      require('./plugins/comment-plugin'),
      {
        name: 'comment',
        options: (frontmatter) => {
          return {...frontmatter}
        }
      }
    ],
  ]
}

② Define global variables

./plugins/comment-plugin/index.js:

const path = require('path')
module.exports = (options, context) => {
  return {
    /***** set global variable options *****/
    define () {
      return {
        options
      }
    },
    /***** end *****/
    enhanceAppFiles: path.resolve(__dirname, 'enhanceAppFile.js'),
    globalUIComponents: 'Comment' 
  }
}

③ Read variable

Comment.vue:

<script>
export default {
  mounted () {
    console.log(options)
  }
}
</script>

What is expected?

The output of Chrome console should be an Object with attributes name[string] and options[function].

What is actually happening?

Only name[string] is output, options[function] disappears.

As shown below:
image

Other relevant information

  • My VuePress version is lower and euqal than 1.0.0-alpha.47:

    • VuePress version:
    • OS:
    • Node.js version:
    • Browser version:
    • Is this a global or local install?
    • Which package manager did you use for the install?
    • Does this issue occur when all plugins are disabled?
  • My VuePress version is higher than 1.0.0-alpha.47, the following is the output of npx vuepress info in my VuePress project:

Environment Info:

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-4210H CPU @ 2.90GHz
  Binaries:
    Node: 10.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.13.0 - C:\Users\godbmw\AppData\Roaming\npm\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Not Found
  npmPackages:
    @vuepress/core: Not Found
    @vuepress/theme-default: Not Found
    vuepress: Not Found
  npmGlobalPackages:
    vuepress: Not Found
@ulivz ulivz mentioned this issue Jun 22, 2019
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant