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

Cannot build vite project using clarity core v6 #100

Closed
4 of 8 tasks
wghglory opened this issue Jun 11, 2022 · 12 comments
Closed
4 of 8 tasks

Cannot build vite project using clarity core v6 #100

wghglory opened this issue Jun 11, 2022 · 12 comments

Comments

@wghglory
Copy link
Contributor

Describe the bug

I'm using Vite Vue and React both. After installing @cds/core @cds/react v6.0.0 and importing a clarity button component for example, the vite project build always raises the below error. Only when I downgrade clarity to 5.6.4, the below issue disappear.

[vite]: Rollup failed to resolve import "@cds/core/icon/shapes/exclamation-circle.js" from "node_modules/@cds/core/forms/register.js". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.external error during build:

Versions

Clarity project:

  • Clarity Core
  • Clarity Angular/UI

Clarity version:

  • v5.x
  • v6.x

Framework:

  • Angular
  • React
  • Vue
  • Other:

Framework version:

Vite

@bbogdanov
Copy link
Contributor

Just curious - are you using micro front-end architecture?

@wghglory
Copy link
Contributor Author

Not in this bug report. Just Vite + react/vue

@ashleyryan
Copy link
Contributor

Can you create a repo with a reproduction? That would save us a lot of time

@wghglory
Copy link
Contributor Author

Yes, you can use this branch "issue/clarity" https://github.com/wghglory/vmware-vite-react-seed/tree/issue/clarity. In this branch, clarity version is 6.0.1. npm run build will see the build error. Only when downgrading to 5.6.4, the error disappears.

@ashleyryan
Copy link
Contributor

I'm not able to reproduce the issue using vite+react+core in stackblitz (using the official vite+react stackblitz starter).
https://stackblitz.com/edit/vitejs-vite-xcjfsz?file=package.json,src%2FApp.jsx,package-lock.json&terminal=dev

Your repo is also way too big and has way too many dependencies for me to debug this. I can look further if you can product a minimum-repro case, without all of the other dependencies (tailwind, etc).

@wghglory
Copy link
Contributor Author

I downloaded your stackbitz repo and npm run build, which reproduced the issue. Did you try to build?

@ashleyryan
Copy link
Contributor

ashleyryan commented Jun 22, 2022

Ah sorry, I was only running npm run dev

Ok, I figured it out. You need to add the @rollup/plugin-node-resolve package to your vite config: https://stackblitz.com/edit/vitejs-vite-xcjfsz?file=package.json,vite.config.js&terminal=build

@wghglory
Copy link
Contributor Author

wghglory commented Jun 23, 2022

Thanks, @ashleyryan! But I wonder why v.5.6.4 doesn't need this package? What changes does clarity make in v6 to make this plugin necessary?

@ashleyryan
Copy link
Contributor

There are a lot of changes in v6 and a lot of internal refactoring - most of those changes were made before my time. I can't say for sure, but as the error message indicates, that file (and similar ones) uses an import from the package instead of a relative file import. That may be new in v6

@wghglory
Copy link
Contributor Author

In v5.6.4, there's no need for @rollup/plugin-node-resolve to make a successful build. And I checked the file used an import from the package just like v6. So that's why I wonder what underneath causes the failure. I just didn't figure out the differences, and why the same format outputs the different results.

@wghglory
Copy link
Contributor Author

In v5.7.2, the build error can be reproduced.

@github-actions
Copy link

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants