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

index.js is not optional, if the theme is to be loaded from a package #928

Closed
sebiniemann opened this issue Oct 13, 2018 · 1 comment
Closed

Comments

@sebiniemann
Copy link

sebiniemann commented Oct 13, 2018

Bug report

Version

1.0.0-alpha.9

Steps to reproduce

  • Configure the site's config.js to use a theme from a dependency package (such that resolveModule is called within @vuepress/shared-utils/lib/shortcutPackageResolver.js)
  • Do not add an index.js to the theme

What is expected?

No problems

What is actually happening?

An exception is thrown, as index.js is required for require.resolve to find the package. While this is not stated by the error shown below itself, we get to this point since require.resolve will simple return null in this case and shortcutPackageResolver will return whatever require.resolve returned, causing therefore later lines of code to fail.

TypeError: Cannot read property 'endsWith' of null
    at loadTheme (xyz\node_modules\@vuepress\core\lib\prepare\loadTheme.js:51:20)
    at AppContext.resolveTheme (xyz\node_modules\@vuepress\core\lib\prepare\AppContext.js:265:32)
    at AppContext.process (xyz\node_modules\@vuepress\core\lib\prepare\AppContext.js:72:16)
    at prepare (xyz\node_modules\@vuepress\core\lib\prepare\index.js:15:20)
    at dev (xyz\node_modules\@vuepress\core\lib\dev.js:23:25)
    at args (xyz\node_modules\@vuepress\cli\index.js:120:14)
    at Command.program.command.description.option.option.option.option.option.option.action (xyz\node_modules\@vuepress\cli\index.js:50:23)
    at Command.listener (xyz\node_modules\@vuepress\cli\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:182:13)
    at Command.parseArgs (xyz\node_modules\@vuepress\cli\node_modules\commander\index.js:654:12)

Other relevant information

This is mostly a bug with the documentation, as it currently states that index.js is optional (aka not needed, see https://vuepress.vuejs.org/theme/#directory-structure). However, if the theme is to be loaded from a package, at least an empty index.js is needed.

@ulivz
Copy link
Member

ulivz commented Oct 17, 2018

Thanks for reporting that, I just updated the docs: 7759d54

@ulivz ulivz closed this as completed Oct 17, 2018
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

2 participants