Skip to content

Commit

Permalink
Distributing standalone modules
Browse files Browse the repository at this point in the history
This commit is obviously too big but also hard to split.
The main goal is to build standalone modules instead of using a
complicated async loading workflow, as to ease development,
optimization, and usage.
This also include a huge rewrite of the docs to accommodate for the
change and make them more readable.
  • Loading branch information
felixgirault committed Feb 7, 2025
1 parent ac44636 commit 816dd62
Show file tree
Hide file tree
Showing 37 changed files with 302 additions and 510 deletions.
364 changes: 195 additions & 169 deletions README.md

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions adr/002-standalone-bundles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
date:
status:
---

# Standalone bundles

## Context

As of now, Orejime is split into many chunks to isolate the core from the language and UI.
However, it is often used on websites using a single language, and always a single theme.

## Considerations

* Async loading relies on bundler magic to locate chunks.
* A bundle containing the core, lang and UI is more optimized than when split and loaded asynchronously, because resources are mutualized and compression acts on the whole bundle at once. Also, this save the time needed to import the chunks.
* Loading different versions of a bundle requires no more work than setting options in the config. In most cases, this will actually be easier.
* The split was meant to reduce network and preocessing usage by loading the bare minimum code. However, Orejime would pop anytime a user visits a website for the first time, and the UI would thus be loaded and cached. We might as well load and cache the whole bundle at once.
* Generating a bundle for each combination of themes and languages could lead to bloat, but we shouldn't add lots of themes. Anyways, even a large list of bundles wouldn't really be a problem, as long as each one is optimized.

## Decision

Orejime will now be distributed as many standalone packages, each providing a single theme and language.
For example, `orejime-dsfr-en` would provide orejime with the DSFR theme and the english translations.
4 changes: 2 additions & 2 deletions e2e/OrejimePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ export class OrejimePage {
<html>
<head>
<title>Orejime</title>
<link rel="stylesheet" href="orejime.css" />
<link rel="stylesheet" href="orejime-standard.css" />
</head>
<body>
<script>
window.orejimeConfig = ${JSON.stringify(config)}
</script>
<script src="orejime.js"></script>
<script src="orejime-standard-en.js"></script>
</body>
</html>
`
Expand Down
239 changes: 2 additions & 237 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
"preact": "^10.23.2",
"prettier": "^2.2.1",
"prettier-loader": "^3.3.0",
"sass": "^1.51.0",
"sass-loader": "^12.6.0",
"sharp": "^0.33.5",
"shiki": "^2.2.0",
"shx": "^0.3.4",
Expand Down
Loading

0 comments on commit 816dd62

Please sign in to comment.