Skip to content

Commit ef58b53

Browse files
author
deepshekhardas
committed
feat: Backend esm vitest
Port of upstream ether#7605 Converts backend tests from mocha to vitest and migrates to ESM.
1 parent 40eeb21 commit ef58b53

329 files changed

Lines changed: 3555 additions & 4563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/backend-tests.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ jobs:
8484
path: node-report/
8585
if-no-files-found: ignore
8686
retention-days: 7
87-
- name: Run the new vitest tests
88-
working-directory: src
89-
run: pnpm run test:vitest
9087

9188
withpluginsLinux:
9289
env:
@@ -166,9 +163,6 @@ jobs:
166163
path: node-report/
167164
if-no-files-found: ignore
168165
retention-days: 7
169-
- name: Run the new vitest tests
170-
working-directory: src
171-
run: pnpm run test:vitest
172166

173167
# Windows tests only run on push to develop/master, not on PRs
174168
withoutpluginsWindows:
@@ -222,11 +216,7 @@ jobs:
222216
NODE_OPTIONS: "--report-on-fatalerror --report-uncaught-exception --report-on-signal --report-compact --report-directory=${{ github.workspace }}/node-report"
223217
run: |
224218
mkdir -p "${{ github.workspace }}/node-report"
225-
# --exit forces process.exit(failures) after the suite completes,
226-
# closing the post-suite event-loop drain window where Windows +
227-
# Node 24 hard-kills the process. Scoped to Windows so Linux/local
228-
# runs still surface real handle leaks via natural drain.
229-
pnpm test -- --exit
219+
pnpm test
230220
- name: Upload Node diagnostic reports on failure
231221
if: ${{ failure() }}
232222
uses: actions/upload-artifact@v7
@@ -235,9 +225,6 @@ jobs:
235225
path: node-report/
236226
if-no-files-found: ignore
237227
retention-days: 7
238-
- name: Run the new vitest tests
239-
working-directory: src
240-
run: pnpm run test:vitest
241228

242229
withpluginsWindows:
243230
env:
@@ -319,11 +306,7 @@ jobs:
319306
NODE_OPTIONS: "--report-on-fatalerror --report-uncaught-exception --report-on-signal --report-compact --report-directory=${{ github.workspace }}/node-report"
320307
run: |
321308
mkdir -p "${{ github.workspace }}/node-report"
322-
# --exit forces process.exit(failures) after the suite completes,
323-
# closing the post-suite event-loop drain window where Windows +
324-
# Node 24 hard-kills the process. Scoped to Windows so Linux/local
325-
# runs still surface real handle leaks via natural drain.
326-
pnpm test -- --exit
309+
pnpm test
327310
- name: Upload Node diagnostic reports on failure
328311
if: ${{ failure() }}
329312
uses: actions/upload-artifact@v7
@@ -332,6 +315,3 @@ jobs:
332315
path: node-report/
333316
if-no-files-found: ignore
334317
retention-days: 7
335-
- name: Run the new vitest tests
336-
working-directory: src
337-
run: pnpm run test:vitest

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ A bundle of defence-in-depth tightening picked up during an internal audit pass
4141

4242
# 3.0.0
4343

44-
3.0 is a feature-heavy release that closes out the self-update programme (Tiers 2 and 3 land alongside Tier 1 from 2.7.3), removes the last identified upstream telemetry vector, and ships a parsed JSONC settings editor, native DOCX export, in-place pad history scrubbing, and an admin UI for GDPR author erasure. It also marks the start of the broader Etherpad app ecosystem (see *Companion apps* below).
44+
3.0 is a feature-heavy release that closes out the self-update programme (Tiers 2 and 3 land alongside Tier 1 from 2.7.3), removes the last identified upstream telemetry vector, and ships a parsed JSONC settings editor, native DOCX export, in-place pad history scrubbing, and an admin UI for GDPR author erasure. It also completes the backend ESM migration and replaces mocha with vitest as the backend test runner, and marks the start of the broader Etherpad app ecosystem (see *Companion apps* below).
4545

4646
### Breaking changes
4747

@@ -50,6 +50,11 @@ A bundle of defence-in-depth tightening picked up during an internal audit pass
5050
- **`swagger-ui-express` removed.** `/api-docs` now serves a vendored, telemetry-free copy of [Scalar](https://github.com/scalar/scalar) (see the privacy item below). The route, the OpenAPI document, and the rendered output are unchanged for downstream consumers, but anything that introspected `swagger-ui-express` internals will need updating.
5151
- **Debian package depends on `nodejs (>= 24)`.** The signed apt repository at `etherpad.org/apt` is rebuilt against this floor; older Node packages are no longer acceptable as a dependency (#7754).
5252

53+
### Breaking changes for plugin authors
54+
55+
- Migrated the Etherpad backend (everything under `src/node/` and the server-side parts of `src/static/js/pluginfw/`) from CommonJS to ECMAScript modules. **Existing CommonJS plugins continue to load unchanged** — the plugin loader now uses Node's `createRequire` to keep `require()` working synchronously against CJS plugin entry files. ESM plugins are also supported (use `"type": "module"` or `.mjs`, export hooks with `export const`). One contract change: the accessor-property shim that exposed `Settings` top-level fields directly on the `require()` result has been removed (it was dead code under ESM). Plugins reading core settings via `require('ep_etherpad-lite/node/utils/Settings').toolbar` must now use `import settings from '...'` (ESM) or `require('...').default.toolbar` (CJS via the bridge). See `doc/plugins.md` for the full updated contract.
56+
- Replaced mocha with vitest as the backend test runner. `pnpm test` now runs vitest. Plugin authors with backend test suites that ran under the core mocha runner via `../node_modules/ep_*/static/tests/backend/specs/**` should expect to migrate their tests to vitest.
57+
5358
### Companion apps
5459

5560
This release coincides with the launch of two ecosystem projects, both maintained under the [`ether` org](https://github.com/ether) and able to talk to any 3.x Etherpad server over its existing HTTP / WebSocket API:

doc/plugins.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ name of a function exported by the named module. See
9090
[`module.exports`](https://nodejs.org/docs/latest/api/modules.html#modules_module_exports)
9191
for how to export a function.
9292

93+
> **Note (Etherpad ≥ 2.7.x):** the core was migrated to ECMAScript modules,
94+
> but the plugin loader uses Node's `createRequire` so existing CommonJS
95+
> plugins (the documented format above) continue to load unchanged. ESM
96+
> plugins are also supported — name your hook entry file with a `.mjs`
97+
> extension or set `"type": "module"` in your plugin's `package.json`, and
98+
> export hook functions with `export const`. One contract change: plugins
99+
> that previously read core settings via `require('ep_etherpad-lite/node/utils/Settings').toolbar`
100+
> must now use either `import settings from 'ep_etherpad-lite/node/utils/Settings'`
101+
> (ESM) or `require('ep_etherpad-lite/node/utils/Settings').default.toolbar`
102+
> (CJS via the bridge). The accessor-property shim that exposed top-level
103+
> fields directly on the require() result is gone.
104+
93105
For the module name you can omit the `.js` suffix, and if the file is `index.js`
94106
you can use just the directory name. You can also omit the module name entirely,
95107
in which case it defaults to the plugin name (e.g., `ep_example`).

0 commit comments

Comments
 (0)