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

Build fails when using local custom theme. #405

Closed
Kurogoma4D opened this issue Nov 13, 2021 · 4 comments
Closed

Build fails when using local custom theme. #405

Kurogoma4D opened this issue Nov 13, 2021 · 4 comments

Comments

@Kurogoma4D
Copy link

Kurogoma4D commented Nov 13, 2021

Describe the bug
When deploy some project using custom theme (in monorepo) to Netlify, I found an error like this:

3:34:18 PM: Error: Cannot find module '@slidev/types'
3:34:18 PM: Require stack:
3:34:18 PM: - /opt/build/repo/example_theme/setup/shiki.ts
3:34:18 PM:     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
3:34:18 PM:     at Function.resolve (node:internal/modules/cjs/helpers:98:19)
3:34:18 PM:     at p (/opt/build/repo/slidev_example/node_modules/jiti/dist/jiti.js:1:52925)
3:34:18 PM:     at g (/opt/build/repo/slidev_example/node_modules/jiti/dist/jiti.js:1:54200)
3:34:18 PM:     at /opt/build/repo/example_theme/setup/shiki.ts:1:176
3:34:18 PM:     at g (/opt/build/repo/slidev_example/node_modules/jiti/dist/jiti.js:1:55111)
3:34:18 PM:     at loadSetups (/opt/build/repo/slidev_example/node_modules/@slidev/cli/dist/chunk-MJ3BO472.js:124:73)
3:34:18 PM:     at createMarkdownPlugin (/opt/build/repo/slidev_example/node_modules/@slidev/cli/dist/chunk-MJ3BO472.js:1135:32)
3:34:18 PM:     at async ViteSlidevPlugin (/opt/build/repo/slidev_example/node_modules/@slidev/cli/dist/chunk-MJ3BO472.js:1349:26)
3:34:18 PM:     at async build (/opt/build/repo/slidev_example/node_modules/@slidev/cli/dist/build-63UO2WKL.js:332:9) {
3:34:18 PM:   code: 'MODULE_NOT_FOUND',
3:34:18 PM:   requireStack: [ '/opt/build/repo/example_theme/setup/shiki.ts' ]
3:34:18 PM: }

Changing to not use shiki did not change the error that @slidev/types was not found.

And local build is works fine at all time.

To Reproduce
An reproducable repository is here: https://github.com/Kurogoma4D/slidev_custom_theme_test,
and here is build log that attempting to deploy it: https://app.netlify.com/sites/adoring-shaw-a7e05b/deploys/618f5c505f1fa67294f98703

  1. Create a project and custom theme project to be a monorepo.
  2. Make it dependent on that project to use a custom theme.
  3. Setup Netlify build to deploy that project.

Desktop (please complete the following information):

  • OS: macOS 11.5.2
  • Browser: Chrome 95.0.4638.69
  • Slidev version: 0.27.13
@Kurogoma4D
Copy link
Author

Okay, I temporary resolved this...
A local custom theme doesn't make node_modules when build automatically, then the main project cannot find module.

So I changed build command to sh -c 'cd ../custom_theme && npm install'; slidev build and works it.
However, I think it would be better if slidev had a built-in way to build even a local custom theme (because slidev supports local theme).

@Kurogoma4D Kurogoma4D changed the title Netlify build fails when using custom theme. Build fails when using local custom theme. Nov 13, 2021
@Kurogoma4D
Copy link
Author

And sadly, the above solution caused a new problem by creating multiple node_modules ( vuejs/core#4344 ).

In the end, I decided to separate the custom theme for each repository in my project and npm install it on the user side.

@yjl9903
Copy link
Contributor

yjl9903 commented Nov 13, 2021

Maybe you can use something like pnpm workspace to manage your monorepo at the root level?

@antfu
Copy link
Member

antfu commented Nov 13, 2021

I think you might want to either

  • Put the theme under Slidev root
  • Have a package.json under your theme and install the necessary packages
  • Use monorepo workspace setup

I believe this is more like a Node.js dependency management question rather than a bug of Slidev.

@antfu antfu closed this as completed Nov 13, 2021
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

3 participants