fix(pkg): restore trailing-slash ep_etherpad-lite/node/eejs/ resolution

Previous commit dropped the './node/eejs/' entry to silence DEP0155.
That warning applies only to folder mappings (string target ending in
/), not to exact-match keys with conditional object values. Real
plugins use the trailing-slash form (see PR #7605 CI logs).

Implementation notes:
- Re-adds './node/eejs/' exports key with object-condition value.
  Node 24/26 still fires DEP0155 for the trailing-slash specifier
  (the warning is tied to the caller's import path, not just the
  exports key format), but resolution succeeds.
- tsdown build:done hooks emit dist-cjs/node/eejs/.cjs and
  dist/node/eejs/.mjs stubs that Node's folder-pattern expansion
  resolves to when the import suffix is empty ('eejs/' + '').
- Adds explicit './node/eejs/index.js' and './node/eejs/index'
  entries so the ESM import('ep_etherpad-lite/node/eejs/index.js')
  is not hijacked by the trailing-slash folder-prefix match.
- Adds 'ep_etherpad-lite/node/eejs/' to cjsResolvableSubpaths in
  the exports_map spec.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
SamTV12345 2026-05-25 12:40:47 +02:00
parent b874ff5e55
commit f762cf5cd9
3 changed files with 29 additions and 0 deletions

View file

@ -20,6 +20,18 @@
"import": "./dist/node/eejs/index.mjs",
"require": "./dist-cjs/node/eejs/index.cjs"
},
"./node/eejs/index.js": {
"import": "./dist/node/eejs/index.mjs",
"require": "./dist-cjs/node/eejs/index.cjs"
},
"./node/eejs/index": {
"import": "./dist/node/eejs/index.mjs",
"require": "./dist-cjs/node/eejs/index.cjs"
},
"./node/eejs/": {
"import": "./dist/node/eejs/index.mjs",
"require": "./dist-cjs/node/eejs/index.cjs"
},
"./node/*": {
"import": "./dist/node/*.mjs",
"require": "./dist-cjs/node/*.cjs"

View file

@ -6,6 +6,7 @@ const require = createRequire(import.meta.url);
// All CJS subpaths must resolve to a .cjs file.
const cjsResolvableSubpaths = [
'ep_etherpad-lite/node/eejs',
'ep_etherpad-lite/node/eejs/',
'ep_etherpad-lite/node/db/PadManager',
'ep_etherpad-lite/node/db/API.js',
'ep_etherpad-lite/node/db/AuthorManager',

View file

@ -1,3 +1,4 @@
import { writeFileSync } from 'node:fs';
import { defineConfig } from 'tsdown';
// Globs covering every subpath plugins consume from ep_etherpad-lite.
@ -33,11 +34,26 @@ export default defineConfig([
entry: commonEntries,
format: 'esm',
outDir: 'dist',
hooks: {
// Node's legacy trailing-slash exports mapping for "./node/eejs/" resolves
// the empty suffix to dist/node/eejs/.mjs (key + "" → value-prefix + "").
// We emit this stub so require('ep_etherpad-lite/node/eejs/') works even
// though DEP0155 will still fire for callers using the trailing-slash form.
'build:done': () => {
writeFileSync('dist/node/eejs/.mjs', "export * from './index.mjs';\n");
},
},
},
{
...common,
entry: cjsEntries,
format: 'cjs',
outDir: 'dist-cjs',
hooks: {
// Counterpart CJS stub for the "./node/eejs/" trailing-slash exports entry.
'build:done': () => {
writeFileSync('dist-cjs/node/eejs/.cjs', "module.exports = require('./index.cjs');\n");
},
},
},
]);