Skip to content

Conversation

BenjaminCharmes
Copy link
Contributor

@BenjaminCharmes BenjaminCharmes commented Dec 2, 2024

Closes #1005

First attempt to switch from vue-cli to vite and a few things to discuss:

  • I had to use cryptojs instead of crypto (MD5(value).toString(); instead of crypto.createHash("md5").update(value).digest("hex");)

  • I had to use import.meta.env.BASE_URL instead of process.env.BASE_URL

  • I remove .browserslistrc and babel.config.js, not useful with vite ?

  • vite 6.x.x not supported by cypress ? (warning message)

  • In vite.config.js, I use extensions: [".vue", ".js", ".json"] to not rename all the imports in all the files, but it could be better to take the time to do it ? (e.g. import Navbar from "@/components/Navbar"; to import Navbar from "@/components/Navbar.vue";

  • Had to rename env variables from VUE_ to VITE_ to make it work without having to import all of them. Should we keep it that way (and also rename them where ever it's needed, e.g. github?) or just import them in the vite.config.js ?

To do:

  • Rewrite the scripts in package.json ?
  • Need to fix Bokeh.
    Just need to downgrade to Bokeh 2.4.0
  • import "tinymce/plugins/hr"; not working
    Downgrade tinymce to v5
  • Fix docker -> Fix cypress e2e test in github workflow

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.84%. Comparing base (18ee71c) to head (2aff549).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1026   +/-   ##
=======================================
  Coverage   74.84%   74.84%           
=======================================
  Files          67       67           
  Lines        4631     4631           
=======================================
  Hits         3466     3466           
  Misses       1165     1165           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BenjaminCharmes BenjaminCharmes added enhancement New feature or request webapp For issues/PRs pertaining to the web interface labels Dec 2, 2024
@BenjaminCharmes BenjaminCharmes added the build For issues/PRs pertaining to the build or deployment of the package label Dec 10, 2024
@BenjaminCharmes BenjaminCharmes force-pushed the bc/switch-to-vite branch 2 times, most recently from da60bee to 5a7a0d7 Compare December 16, 2024 10:44
First attempt to switch from vue-cli to vite

Remove a 'process' that I missed

Fix a few thing to make vite work

Fix a few thing to make vite work

Fix a few thing to make vite work

Downgrade Bokeh to 2.4.0

Downgrade tinymce to v5

Temp commit

Update yarn build with vite

Update yarn build with vite

Update yarn build with vite

Update yarn build with vite

Update docker build for vite

Add serve into package.json

Update env variable fron VUE_ to VITE_
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments for myself:

  • check docker build version info with vite
  • think about migrating env vars too

Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @BenjaminCharmes, great to remove 4000 lines from our lockfile, though we might need to review some of the deps upgrades carefully to make sure they still work. Some initial comments below

@@ -1,10 +1,10 @@
import { createStore } from "vuex";
import UserBubbleLogin from "@/components/UserBubbleLogin.vue";
import NotificationDot from "@/components/NotificationDot.vue";
import crypto from "crypto";
import MD5 from "crypto-js/md5";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we need to be careful here too, I had a lot of fun getting the crypto-browserify stuff to work recently. The crypto-js library itself is deprecated (see README here: https://www.npmjs.com/package/crypto-js) -- we may need another solution

"serve": "^14.2.1",
"qrcode-vue3": "^1.7.1",
"redis": "^4.7.0",
"serve": "^14.2.4",
"stream-browserify": "^3.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may not need stream-browserify anymore

Comment on lines 37 to 38
args[0].meta = {
x_datalab_api_url: process.env.VUE_APP_API_URL,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by the client code quite a lot, we should make sure that the equivalent is done with vite too (I couldn't see it above), should be doable in the same way as the website title

Copy link

cypress bot commented Jan 11, 2025

datalab    Run #2933

Run Properties:  status check failed Failed #2933  •  git commit f199b2f4ea ℹ️: Merge be60e56b4efe87979c4caa5ee60caaab797918a3 into 17ab3575328038e4dc200814c5a3...
Project datalab
Branch Review bc/switch-to-vite
Run status status check failed Failed #2933
Run duration 08m 48s
Commit git commit f199b2f4ea ℹ️: Merge be60e56b4efe87979c4caa5ee60caaab797918a3 into 17ab3575328038e4dc200814c5a3...
Committer Ben Charmes
View all properties for this run ↗︎

Test results
Tests that failed  Failures 15
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 408
View all changes introduced in this branch ↗︎

Tests for review

Failed  ChemicalFormulaTest.cy.jsx • 1 failed test • Component tests (chrome)

View Output

Test Artifacts
ChemFormulaInput > renders single element formula correctly Test Replay Screenshots
Failed  CollectionTableTest.cy.jsx • 1 failed test • Component tests (chrome)

View Output

Test Artifacts
An uncaught error was detected outside of a test Test Replay Screenshots
Failed  EquipmentTableTest.cy.jsx • 1 failed test • Component tests (chrome)

View Output

Test Artifacts
An uncaught error was detected outside of a test Test Replay Screenshots
Failed  SampleTableTest.cy.jsx • 1 failed test • Component tests (chrome)

View Output

Test Artifacts
An uncaught error was detected outside of a test Test Replay Screenshots
Failed  StartingMaterialTableTest.cy.jsx • 1 failed test • Component tests (chrome)

View Output

Test Artifacts
An uncaught error was detected outside of a test Test Replay Screenshots

The first 5 failed specs are shown, see all 15 specs in Cypress Cloud.

Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things left:

  • fix whatever is going on with cypress/support/e2e.js (maybe just try removing it)
  • at some point, update our package.json so that it launches the dev server for you before running tests, as vue-cli did

@ml-evs ml-evs force-pushed the bc/switch-to-vite branch from 60265fe to 42c34e9 Compare February 7, 2025 11:29
@ml-evs
Copy link
Member

ml-evs commented Feb 25, 2025

I've pushed a bit further on this in the last few commits, though its really unsatisfactory still. The component tests rae failing with Cannot access [Component] before initialization. With the help of Claude, I've tried to address this with two changes:

  • Added more node.js polyfills for Vite
    • Configured vite-plugin-node-polyfills in both Vite and Cypress configs to support the crypto module in browser environments, since the UserBubble test was failing at least partially for this reason
  • Resolved a potential circular dependency in resources.js:
    • Moved/refactored GRAVATAR_STYLE (which has never been changed) from resources.js to prevent initialization order issues
    • The bottom line is that Vite's ESM-based module system is stricter about circular dependencies than vue-cli was, and component tests are particularly sensitive to these initialization order issues

Of the remaining failures, the FormattedItemName test fails for the same reason here, that resources.js is imported. Then all of the dynamic table tests fail, presumably for the same reason... We might need to think about refactoring resources.js generally.

@ml-evs
Copy link
Member

ml-evs commented Feb 25, 2025

See e.g. 337b718 for the fix required to FormattedItemName to allow this component test to pass. I don't think we necessarily want to do this change...

@ml-evs ml-evs self-assigned this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked build For issues/PRs pertaining to the build or deployment of the package enhancement New feature or request webapp For issues/PRs pertaining to the web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch our webapp build tool from vue-cli to vite
2 participants