Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .chachalog/B5LNULyZ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Allowed version bumps: patch, minor, major
javascript-modules: patch
---

We have migrated our build pipelines and test suites to Vite 8 and Rolldown to ensure JS Modules work with the latest versions of this stack. (#668)

This is not a breaking change, we support all Vite versions from 6 to 8.
6 changes: 6 additions & 0 deletions .chachalog/KYA_2pVz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# Allowed version bumps: patch, minor, major
javascript-modules: patch
---

Exposed React's new `<Activity>` component and `useEffectEvent` hook, added in React 19.2.0. (#668)
7 changes: 7 additions & 0 deletions .yarn/patches/fast-text-encoding-npm-1.0.6-b474f65fe2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/text.min.js b/text.min.js
index 0ec6e725303aa4d05bceff3ae482edee025afe14..92e466e0482c305e7cc541b2db4e7579e6510616 100644
--- a/text.min.js
+++ b/text.min.js
@@ -3,1 +3,1 @@
-}(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));
+}(globalThis));
2 changes: 1 addition & 1 deletion jahia-test-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"i18next": "^25.7.3",
"react-i18next": "^16.5.0",
"typescript": "^5.9.3",
"vite": "^7.3.0"
"vite": "^8.0.14"
},
"engines": {
"node": ">=18.0.0",
Comment thread
GauBen marked this conversation as resolved.
Expand Down
13 changes: 4 additions & 9 deletions javascript-modules-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@
"repository": "git@github.com:Jahia/javascript-modules-engine.git",
"license": "MIT",
"scripts": {
"build": "rollup -c --environment BUILD:production",
"build:development": "rollup -c --environment BUILD:development",
"build": "rolldown -c rolldown.config.mjs --environment BUILD:production",
"build:development": "rolldown -c rolldown.config.mjs --environment BUILD:development",
"clean": "run clean-server && run clean-client",
"clean-client": "rm -rf src/main/resources/javascript/",
"clean-server": "rm -rf src/main/resources/META-INF/js/"
},
"dependencies": {
"@jahia/javascript-modules-library": "workspace:*",
"devalue": "5.8.1",
"fast-text-encoding": "1.0.6",
"fast-text-encoding": "patch:fast-text-encoding@npm%3A1.0.6#~/.yarn/patches/fast-text-encoding-npm-1.0.6-b474f65fe2.patch",
"i18next": "25.7.3",
"react": "19.2.4",
"react-dom": "19.2.4",
"react-i18next": "16.5.4"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-replace": "^6.0.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.3.0",
"@types/node": "^22.19.3",
"@types/react-dom": "^19.2.3",
"rollup": "^4.53.5",
"rolldown": "^1.0.2",
"rollup-plugin-sbom": "^3.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// @ts-check
import commonJs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { fileURLToPath } from "node:url";
import { defineConfig } from "rollup";
import { defineConfig } from "rolldown";
import { esmExternalRequirePlugin } from "rolldown/plugins";
import sbom from "rollup-plugin-sbom";
import { clientLibs, serverLibs } from "./shared-libs.mjs";

Expand All @@ -25,40 +21,37 @@ const buildEnv = process.env.BUILD || "development";
* The goal of all this is to flatten the network dependency graph of the hydrated code, by using
* `<link rel="modulepreload" />` hints.
*
* @type {string[]}
* @type {string[] | undefined}
*/
let sharedLibFiles;

/**
* Rollup plugins common to all builds.
* Options common to all builds.
*
* @type {import("rollup").InputPluginOption[]}
* @satisfies {import("rolldown").InputOptions}
*/
const plugins = [
commonJs(),
nodeResolve(),
replace({
values: {
const commonOptions = {
transform: {
define: {
"process.env.NODE_ENV": JSON.stringify(buildEnv),
},
preventAssignment: true,
}),
typescript(),
sbom({ specVersion: "1.4" }),
];
},
plugins: [sbom({ specVersion: "1.4" })],
};

export default defineConfig([
//#region Client build
// Bundle the shared libraries for browser use (exposed by an importmap)
// They are used by both the main client script and client-side module scripts
{
...commonOptions,
input: clientLibs,
output: {
dir: "./src/main/resources/javascript/shared-libs/",
minify: buildEnv === "production",
},
plugins: [
...plugins,
buildEnv === "production" && terser(),
...commonOptions.plugins,
{
name: "extract-shared-lib-files",
generateBundle(_, bundle) {
Expand All @@ -72,22 +65,23 @@ export default defineConfig([
},
// Build the main client script: the script that hydrates server-rendered components
{
...commonOptions,
input: "./src/client/index.ts",
output: {
file: "src/main/resources/javascript/index.js",
minify: buildEnv === "production",
},
external: Object.keys(clientLibs),
plugins: [
...plugins,
// Minify client files in production
buildEnv === "production" && terser(),
esmExternalRequirePlugin({ external: Object.keys(clientLibs) }),
...commonOptions.plugins,
],
},
//#endregion

//#region Server build
// Bundle the shared libraries for server use
{
...commonOptions,
input: serverLibs,
output: {
dir: "./src/main/resources/META-INF/js/libs/",
Expand Down Expand Up @@ -120,22 +114,26 @@ export default defineConfig([
if (id === "virtual:shared-lib-files") return `\0shared-lib-files`;
},
load(id) {
if (!sharedLibFiles) throw new Error("sharedLibFiles not collected yet");
if (id === "\0shared-lib-files")
return `export default ${JSON.stringify(sharedLibFiles)};`;
},
},
...plugins,
...commonOptions.plugins,
],
},
// Build the server-side script
// It takes care of rendering JSX components on the server
{
...commonOptions,
input: "./src/server/index.ts",
output: {
file: "./src/main/resources/META-INF/js/main.js",
},
external: Object.keys(serverLibs),
plugins,
plugins: [
esmExternalRequirePlugin({ external: Object.keys(serverLibs) }),
...commonOptions.plugins,
],
},
//#endregion
]);
3 changes: 3 additions & 0 deletions javascript-modules-engine/src/shared/react-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export {
unstable_batchedUpdates,
useFormState,
useFormStatus,
version,
// Default export too
default,
// @ts-expect-error Expose react-dom internals for react-dom/client
__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
} from "react-dom";
4 changes: 4 additions & 0 deletions javascript-modules-engine/src/shared/react.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Until https://github.com/facebook/react/issues/10021 is fixed,
// we have to list every single export
export {
Activity,
Children,
Component,
Fragment,
Expand All @@ -26,6 +27,7 @@ export {
useDebugValue,
useDeferredValue,
useEffect,
useEffectEvent,
useId,
useImperativeHandle,
useInsertionEffect,
Expand All @@ -40,4 +42,6 @@ export {
version,
// Default export too
default,
// @ts-expect-error Expose react internals for react-dom
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
} from "react";
2 changes: 1 addition & 1 deletion samples/hydrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"typescript": "^5.9.3",
"typescript-eslint": "^8.50.0",
"typescript-plugin-css-modules": "^5.2.0",
"vite": "^7.3.0"
"vite": "^8.0.14"
},
"packageManager": "yarn@4.10.3",
"engines": {
Expand Down
4 changes: 3 additions & 1 deletion vite-plugin/fixtures/expected/assets/style.css

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

2 changes: 1 addition & 1 deletion vite-plugin/fixtures/expected/client/foo.client.tsx.js

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

84 changes: 43 additions & 41 deletions vite-plugin/fixtures/expected/server/index.js

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

Loading
Loading