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

Feature: Initial bundling work + bundle dictionary package #1977

Merged
merged 8 commits into from
Jun 4, 2024

Conversation

madsrasmussen
Copy link
Contributor

@madsrasmussen madsrasmussen commented Jun 3, 2024

Description

This is the beginning of bundling our modules. Unfortunately, bundling all the modules before v15 might not be possible because some files are located incorrectly. These files can't be moved without a breaking change. Therefore, We will go through the modules one by one, and bundle the possible ones.

This PR sets up the basic build script for bundling. The build is made with npm workspaces which makes it possible to run a "local" build script in each package. The bundling is done by Vite.

We now have one for the npm package, which is not bundled, and one for the CMS which will be partly bundled.

The idea is to build the same way as before but swap out the "old" module files for the bundled ones when a module is ready.

How to test

  1. Run the npm run build:for:cms script in the CMS project.
  2. Check that you see the bundled javascript output in the src/packages/dictionary folder.
  3. Clear your browser cache
  4. Test the dictionary section/workspaces etc. All works as before

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

@madsrasmussen madsrasmussen changed the title V14/chore/bundling dictionary Chore: Bundling dictionary module Jun 3, 2024
@madsrasmussen madsrasmussen marked this pull request as ready for review June 3, 2024 12:08
Copy link
Collaborator

@iOvergaard iOvergaard left a comment

Choose a reason for hiding this comment

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

Tested on the dev server as well as the CMS. It definitely loads fewer files. Makes sense that is still has a number of files since much of it is lazy-loaded.

When I create a new dictionary item, I get an error in console, but I'm not sure if that is related:

image

Lastly, it seems all repository files are loaded, even before I'm clicking on the associated actions. For example, the dictionary-export.repository-CACHE123.js file always seems to load up front. When I then click on the "Export" action, even more files load such as the modal element and the icons in separate requests, which I guess is ok (and icons are probably not bundled anyway). Do we need to load repository class files up front?

@iOvergaard
Copy link
Collaborator

It also seems there is a change to "package-lock.json" but I don't dare to commit it:

image

@madsrasmussen
Copy link
Contributor Author

  1. The JS error is not caused by this PR. I think it is a problem in all workspaces when creating a new item.

  2. I have updated the package.json. The update is ok.

  3. The export repo is set to be lazy loaded in the manifest, so I guess it is loaded when we create the list of available entity actions 🤔 . As far as I can see there is not much more we can do from the bundle.

Copy link
Collaborator

@iOvergaard iOvergaard left a comment

Choose a reason for hiding this comment

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

Ok, thanks for confirming, @madsrasmussen. Having Vite bundle it up is really helpful to see what might be lazy-loaded and what isn't. With that said, this LGTM.

@iOvergaard iOvergaard merged commit 142cd09 into main Jun 4, 2024
6 checks passed
@iOvergaard iOvergaard deleted the v14/chore/bundling-dictionary branch June 4, 2024 11:14
@iOvergaard iOvergaard changed the title Chore: Bundling dictionary module Feature: Bundling dictionary module Jun 4, 2024
@madsrasmussen madsrasmussen changed the title Feature: Bundling dictionary module Feature: Initial bundling work + bundle dictionary package Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants