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

WIP: Wip vite as suite devserver #17152

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

vojtatranta
Copy link
Contributor

@vojtatranta vojtatranta commented Feb 21, 2025

TODO

  • ✅ static routes
  • ✅ simplify vite config (remove useless nonsense)
  • ✅ remove the changes in the source code / make them compatible with webpack
  • MOVE the config to suite-build

Description

Related Issue

Resolve

Screenshots:

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch from 77c9471 to db851bd Compare February 21, 2025 09:47
@@ -0,0 +1,60 @@
<!doctype html>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be unified with the webpack's index.html file, I think thats possible just some variables willneed to be replaced coz it uses webpack's template literals.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds doable to make a script to replace or strip the webpack syntax → make it digestible by Vite.
Question is, when should this script fire?
Quick search: vite might have a hook that allows you to modify the static assets on-the-fly, which would be better than running it manually after each index.html change (although that'd be fine too, this file is not modified very often 🙂 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I know it is possible, I have it in one of the commits. Though, I have troubles moving the whole vite config to suite-buiild package for some reason. I tried many things already...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to me: don't forget to server the static/index.html file here, not this artificial one.

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch 5 times, most recently from ab227b5 to 91c45c5 Compare February 21, 2025 13:43
Copy link

github-actions bot commented Feb 21, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch 3 times, most recently from 22d9424 to 2d7ff96 Compare February 24, 2025 13:44
@@ -7,6 +7,7 @@
"type-check:watch": "yarn type-check -- --watch",
"lint:styles": "npx stylelint './src/**/*{.ts,.tsx}' --cache --config ../../.stylelintrc",
"dev": "yarn rimraf ./build && yarn workspace @trezor/suite-build run dev:web",
"dev:vite": "yarn rimraf ./build && vite",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thius should be likely in @trezor/suite-build not here

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch 8 times, most recently from 22a7790 to bc6dd74 Compare February 26, 2025 09:22
Copy link

socket-security bot commented Feb 26, 2025

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/vite-plugin-wasm@3.4.1

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch from ea4d44f to 0708451 Compare February 26, 2025 12:33
@marekrjpolak
Copy link
Contributor

Ordinary suite:dev broken for me.
image

@vojtatranta
Copy link
Contributor Author

Ordinary suite:dev broken for me. image

had that too yarn && yarn build:libs fixed it (likely not problem of thsi PR)

@vojtatranta
Copy link
Contributor Author

Ordinary suite:dev broken for me. image

had that too yarn && yarn build:libs fixed it (likely not problem of thsi PR)

damn, no longer helps, why the helll. Likely deduping?

@Lemonexe
Copy link
Contributor

Lemonexe commented Feb 27, 2025

Tested Webpack: dev Desktop, dev Desktop, linux Desktop build.
They all work correctly ✔️
But Webpack throws a very red warning at all of them, that should be solved ❌
EDIT: same as already reported

@vojtatranta
Copy link
Contributor Author

Tested Webpack: dev Desktop, dev Desktop, linux Desktop build. They all work correctly ✔️ But Webpack throws a very red warning at all of them, that should be solved ❌

Module not found: Error: Can't resolve 'vm' in 'trezor-suite/node_modules/asn1.js/lib/asn1'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

yup, see that too. Server runs, but throws errors. Looking into it.

Probably some yarn deduping caused this...

@vojtatranta
Copy link
Contributor Author

Tested Webpack: dev Desktop, dev Desktop, linux Desktop build. They all work correctly ✔️ But Webpack throws a very red warning at all of them, that should be solved ❌ EDIT: same as already reported

Added what webpack advised us to do. It is no longer with warning. I hope that's correct.

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch 5 times, most recently from f590d21 to 6a4cae9 Compare February 27, 2025 16:52

// Use require instead of import for TypeScript files
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { assetPrefix, project } = require('../suite-build/utils/env');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

damn it, I had to do this... Otherviews, the linter was screeming and with @trezor/suite-build would allow the vite config to compile, that's mess, but this wworks

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch 2 times, most recently from 23bf350 to ab567da Compare February 28, 2025 08:34
@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch from ab567da to d75d4da Compare February 28, 2025 09:30
@Lemonexe
Copy link
Contributor

@SocketSecurity ignore npm/vite-plugin-wasm@3.4.1
I have checked the vite-plugin-wasm source and verified legit usage: to generate code that fetches wasm files, using import urls by passed from vite; no external url injected in the lib ✔️

@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch 4 times, most recently from acc87c3 to c536099 Compare February 28, 2025 13:36
@vojtatranta vojtatranta force-pushed the wip-vite-as-suite-devserver branch from c536099 to 37a4d0f Compare February 28, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏃‍♀️ In progress
Development

Successfully merging this pull request may close these issues.

3 participants