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

✨ Standalone Vite #2530

Merged
merged 17 commits into from
Dec 21, 2023
Merged

✨ Standalone Vite #2530

merged 17 commits into from
Dec 21, 2023

Conversation

AntoLC
Copy link
Contributor

@AntoLC AntoLC commented Dec 7, 2023

Purpose

Migrate from CRA to Vite.
CRA is not maintained anymore, better to switch to Vite.

Proposal

  • Standalone turning with Vite
  • Hot Reloading with all packages
  • Load correctly translations
  • Adapt tests
  • Adapt CI to to test standalone with sharding

Nice stuff

  • Faster to build / start
  • CI with sharding
  • Full hand on the building part

Review

Extra attention on:

@AntoLC AntoLC self-assigned this Dec 7, 2023
@AntoLC AntoLC force-pushed the feature/anthony/standalone-vite branch 2 times, most recently from 254d009 to 50e1dbf Compare December 11, 2023 16:42
@AntoLC AntoLC changed the base branch from master to feature/anthony/optimize-bundle December 11, 2023 16:46
Base automatically changed from feature/anthony/optimize-bundle to master December 12, 2023 09:27
@AntoLC AntoLC force-pushed the feature/anthony/standalone-vite branch 11 times, most recently from c87edb5 to 842b217 Compare December 15, 2023 16:30
@AntoLC AntoLC marked this pull request as ready for review December 15, 2023 16:35
@AntoLC AntoLC force-pushed the feature/anthony/standalone-vite branch from 842b217 to 7825562 Compare December 18, 2023 09:13
Copy link
Member

@kernicPanel kernicPanel left a comment

Choose a reason for hiding this comment

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

Everything seems fine, with a small except for a warning when we run yarn start-site from src/frontend:

  Plugin: vite:dynamic-import-vars
  File: /home/nc/projets/fun/marsha/src/frontend/packages/lib_video/src/utils/conversejs/entry.js:1:0
  1  |  // This file comes from converse.js github repository
     |  ^
  2  |  // This is the entrypoint to load converse headless
  3  |  // and then use it from window.converse

@AntoLC
Copy link
Contributor Author

AntoLC commented Dec 18, 2023

Everything seems fine, with a small except for a warning when we run yarn start-site from src/frontend:

  Plugin: vite:dynamic-import-vars
  File: /home/nc/projets/fun/marsha/src/frontend/packages/lib_video/src/utils/conversejs/entry.js:1:0
  1  |  // This file comes from converse.js github repository
     |  ^
  2  |  // This is the entrypoint to load converse headless
  3  |  // and then use it from window.converse

97f658a: seems to remove the warning

@AntoLC AntoLC force-pushed the feature/anthony/standalone-vite branch 3 times, most recently from b1d7923 to dd13fdc Compare December 20, 2023 14:03
AntoLC and others added 17 commits December 21, 2023 16:44
CRA is not maintained anymore, we replace it by vite.
This commit replace CRA with the basic setting, we still need to
fine tune it to have the same behavior as before.
All our tests are already written in jest, so we
will use Jest with Vite.
CRA was managing the jest config for us, but now we have to do
it ourselves, to do so we need to add a jest config file, and the
babel config file. We added some babel plugins to the babel config
to make it work with jest and vite.
This commit proxy the url /api to the local backend.
We want the same behavior as with CRA, so we need to adapt the
svg loader to return a ReactComponent.
CRA with Jest has a special treatment for SVG files. It uses a Jest
transformer to convert SVG files into a svg with some basic
information. It is quite usefull to test wich svg is loaded in
our tests. In order to have the same behavior in our Vite standalone,
we need to add the same transformer.
We had to fix another problem, the svg in our app are loaded with
a query string. The transformer was not able to handle it. We had to
add a babel plugin (babel-plugin-import-remove-resource-query)
to remove the query string before the transformer
is called.
Absolutes urls are not working with dynamic import,
we have to import the translation files with relative paths.
p2p-media-loader-hlsjs uses the "util" module, which is a
Node.js module.
Vite does not automatically polyfill Node.js modules,
so we need to add a polyfill for the "util" module in order
to use p2p-media-loader-hlsjs correctly.
ThemeContext is flagged as a "sideEffects" module, Vite seems to
have a problem with that, the module is not exported.
We change the import of ThemeContext, this way is correctly bundled by
Vite.
Vite doesn't support require, so we need to use import instead.
We update eslint to allow import.
Add equivalent of __webpack_public_path__ in vite, to allow loading of
assets from a CDN on runtime.
In the generics.ts module, importing the module with await import was
creating a chunk of the module imported, but Vite was pinpointing
that the module was already bundled in the main chunk via index.
This commit fixes the warning by importing the module with a
standard import, it doesn't have to be a promise anymore.
vtt.js expect VTTRegion to be already defined, but it is not the case,
it seems that the Window object didn't have the time to load
VTTRegion before vtt.js try to use it. By importing vtt.js in the
component, we make sure that Window had the time to load VTTRegion.
Vite was complaining about a circular dependency in lib_components,
this commit fixes it.
The vite framework is escaping the variable used in a django template.
Instead of using django template, we are doing a replace using a regex
on a specfic keyword
Some dependencies were not being installed correctly in lib_markdown,
plus these dependencies have some source maps missing that
cause warnings during the build.
This commit fixes the issue by installing the dependencies correctly,
and remove the warnings on missing source maps.
In order to build correctly the stansalone site with vite, we have to
set the environment variable VITE_DIR_PROD and VITE_CDN_REPLACE_KEYWORD
When we load a component from a toast.custom, we can't access the
intl object, the ancestor tree is lost. We need to pass it down
explicitly.
@AntoLC AntoLC force-pushed the feature/anthony/standalone-vite branch from dd13fdc to 97f6149 Compare December 21, 2023 15:44
@AntoLC AntoLC enabled auto-merge (rebase) December 21, 2023 15:46
@AntoLC AntoLC merged commit 9104631 into master Dec 21, 2023
32 of 33 checks passed
@AntoLC AntoLC deleted the feature/anthony/standalone-vite branch December 21, 2023 15:57
lunika added a commit that referenced this pull request Jun 24, 2024
Added

- Add scaleway storage configuration
- Add Peertube pipeline to VOD
- Celery task queue
- Refactor video S3 deletion
- Add thumbnail celery task
- Add shared live media celery task
- Add timed text track celery task
- Add form submission with enter key when entering a classroom
- Persist username used on classroom join

Changed

- Replace CRA by Vite (#2530)
- Replace grommet Image and Grid component (#2518)
- Optimized apps bundle (#2528)
- Launch transcoding through a celery task

Fixed

- Correctly set startime with filtering medialive logs
- Remove non existing fields in PortabilityRequestAdmin
- Correctly send xapi statement to a configured LRS
- Correctly send xapi video download statements
lunika added a commit that referenced this pull request Jun 26, 2024
Added

- Add scaleway storage configuration
- Add Peertube pipeline to VOD
- Celery task queue
- Refactor video S3 deletion
- Add thumbnail celery task
- Add shared live media celery task
- Add timed text track celery task
- Add form submission with enter key when entering a classroom
- Persist username used on classroom join

Changed

- Replace CRA by Vite (#2530)
- Replace grommet Image and Grid component (#2518)
- Optimized apps bundle (#2528)
- Launch transcoding through a celery task

Fixed

- Correctly set startime with filtering medialive logs
- Remove non existing fields in PortabilityRequestAdmin
- Correctly send xapi statement to a configured LRS
- Correctly send xapi video download statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants