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

Migrate to vite / vitest / vitepress for building #3529

Closed
wants to merge 11 commits into from
Closed

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Nov 30, 2022

Created because of this comment: #2959 (comment)


Based on this comment I migrated the project to use vite for bundling / building (without noticing this is already done in #2959).

  • Migrate to vite for building (so dependency on webpack anymore)
  • Migrate to vitest for unit tests (instead of jest)
  • Migrate to vue-docgen + vitepress for documentation
  • Migrate cypress to use vite (and updated cypress)

One problem with this migration is the missing live preview of the Nc components, as vitepress is using vue3 but we are still using vue2. This leads dependency issues.
(I got it working locally but it requires experimental node features (import maps) to mount vue2 components within vitepress vue3).

@susnux susnux added dependencies Pull requests that update a dependency file breaking PR that requires a new major version labels Nov 30, 2022
@susnux susnux mentioned this pull request Nov 30, 2022
3 tasks
@skjnldsv
Copy link
Contributor

skjnldsv commented Dec 1, 2022

https://app.netlify.com/sites/nextcloud-vue-components/deploys/63874efdd546a70009f9b500

1:41:10 PM: failed to load config from /opt/build/repo/styleguide/.vitepress/config.mjs
1:41:10 PM: build error:
1:41:10 PM:  Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vitepress' imported from
/opt/build/repo/styleguide/.vitepress/config.mjs.timestamp-1669812070118.mjs

@susnux
Copy link
Contributor Author

susnux commented Dec 1, 2022

Oh yes, I only tested the live preview. Looks like the build is broken because vue-docgen does not escape < and vitepress interprets <...> as vue components.

@skjnldsv skjnldsv added the 2. developing Work in progress label Dec 1, 2022
@susnux
Copy link
Contributor Author

susnux commented Dec 4, 2022

@skjnldsv fixed the issue. So now everything works, even styleguide build.

@raimund-schluessler
Copy link
Contributor

The styleguide preview somehow doesn't work yet.

@susnux
Copy link
Contributor Author

susnux commented Dec 5, 2022

The styleguide preview somehow doesn't work yet.

Do you get any error message? As for me it works

voko.mp4

@raimund-schluessler
Copy link
Contributor

I didnt' try the local build, I just checked the browser preview here https://deploy-preview-3529--nextcloud-vue-components.netlify.app/

@susnux
Copy link
Contributor Author

susnux commented Dec 5, 2022

I do not know how netlify is configured, where does it try to load the index.html from?
As all files are saved into styleguide/build, meaning it looks like this

styleguide/
    build/
        assets/
        index.html

@raimund-schluessler
Copy link
Contributor

I don

I do not know how netlify is configured, where does it try to load the index.html from? As all files are saved into styleguide/build, meaning it looks like this

styleguide/
    build/
        assets/
        index.html

I don't know either. But the deploy log here https://app.netlify.com/sites/nextcloud-vue-components/deploys/638e134d9ffb950008585e30 says this:

...
4:51:40 PM: vitepress v1.0.0-alpha.29
4:51:40 PM: - building client + server bundles...
4:51:45 PM:  building client + server bundles...
4:51:45 PM: build error:
4:51:45 PM:  file:///opt/build/repo/styleguide/.vitepress/.temp/plugin-vue_export-helper.1460a1c7.js:1
4:51:45 PM: import { initDirectivesForSSR, ssrContextKey, warn as warn$1, Fragment, Static, Comment, Text, mergeProps, createVNode, ssrUtils, createApp } from "vue";
4:51:45 PM:                                                                                          ^^^^
4:51:45 PM: SyntaxError: The requested module 'vue' does not provide an export named 'Text'
4:51:45 PM:     at ModuleJob._instantiate (internal/modules/esm/module_job.js:124:21)
4:51:45 PM:     at async ModuleJob.run (internal/modules/esm/module_job.js:179:5)
4:51:45 PM:     at async Loader.import (internal/modules/esm/loader.js:178:24)
4:51:45 PM:     at async build (file:///opt/build/repo/styleguide/node_modules/vitepress/dist/node/serve-fcdc8868.js:42002:24)
4:51:45 PM: ​
4:51:45 PM: ────────────────────────────────────────────────────────────────
4:51:45 PM:   "build.command" failed                                        
4:51:45 PM: ────────────────────────────────────────────────────────────────
4:51:45 PM: ​
4:51:45 PM:   Error message
4:51:45 PM: Creating deploy upload records
4:51:45 PM:   Command failed with exit code 1: npm ci && npm run styleguide:build (https://ntl.fyi/exit-code-1)
4:51:45 PM: ​
4:51:45 PM:   Error location
4:51:45 PM:   In Build command from Netlify app:
4:51:45 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:51:45 PM:   npm ci && npm run styleguide:build
4:51:45 PM: ​
4:51:45 PM:   Resolved config
4:51:45 PM:   build:
4:51:45 PM:     command: npm ci && npm run styleguide:build
4:51:45 PM:     commandOrigin: ui
4:51:45 PM:     environment:
4:51:45 PM:       - NODE_VERSION
4:51:45 PM:       - NPM_VERSION
4:51:45 PM:       - REVIEW_ID
4:51:45 PM:     publish: /opt/build/repo/styleguide
4:51:45 PM:     publishOrigin: ui
4:51:45 PM: Caching artifacts
...

@susnux
Copy link
Contributor Author

susnux commented Dec 5, 2022

@raimund-schluessler "Fixed" that, it was indeed the netlify config which seems to be set up to take the whole styleguide directory.
I added a temporary workaround for this
https://deploy-preview-3529--nextcloud-vue-components.netlify.app/build/

@raimund-schluessler
Copy link
Contributor

@raimund-schluessler "Fixed" that, it was indeed the netlify config which seems to be set up to take the whole styleguide directory. I added a temporary workaround for this https://deploy-preview-3529--nextcloud-vue-components.netlify.app/build/

Nice, I can see the styleguide now. But somehow the components have no live preview, as it is in the current docs. Can this be enabled?

@susnux
Copy link
Contributor Author

susnux commented Dec 5, 2022

But somehow the components have no live preview, as it is in the current docs. Can this be enabled?

As stated above the problem is vitepress uses Vue 3, but we are still using Vue 2.
So we would have to mount Vue2 components within Vue 3, which is possible (I already wrote a wrapper for this),
but the main problem is we have to compile the vue 2 components within the browser which leads to versions clashes of @vue/sfc-compiler because vitepress already loads the vue 3 version of it.

I was able to fix this but that required Node import maps which are experimental, so I will have to look for an other solution until we can port all components to vue 3 :)

susnux added 10 commits December 5, 2022 17:53
Signed-off-by: Ferdinand Thiessen <[email protected]>
This entry point provides all components, mixins etc as named
exports.
Added vue plugin export `NextcloudVue` so users can register
all components using the vue plugin functionality:
`Vue.use(NextcloudVue)`

Signed-off-by: Ferdinand Thiessen <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
@raimund-schluessler
Copy link
Contributor

@susnux Thanks for the explanation. I guess this has to wait until we migrated to vue3 then. Would be interesting to see how #2637 works on top of it.

@raimund-schluessler
Copy link
Contributor

Vite4 was just released: https://vitejs.dev/blog/announcing-vite4.html
I guess we should directly use this release, once we are able to upgrade.

@susnux
Copy link
Contributor Author

susnux commented Dec 12, 2022

I think I will close this PR as the migration does not make much sense while using vue 2.
But as said above it might be interesting to see this on top of the vue3 branch so I merged it for demonstation purpose.

@susnux
Copy link
Contributor Author

susnux commented Dec 12, 2022

#3565

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress breaking PR that requires a new major version dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants