mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
The rspack client build treats a `module.exports` file imported into the
client bundle as an ES module and throws
"ES Modules may not assign module.exports" at evaluation time, aborting
the whole client module chain (No such template: swimlane / notifications
/ boardButtons, blank board, missing top bar). This is not an rspack
version regression (the lockfile has pinned ~1.7.x since v8.40); it is
that WeKan added CommonJS helpers to the client bundle.
Convert the 42 client-reachable pure-logic models/lib helpers from
`module.exports = { ... }` to `export { ... }`, and calendarFilter's
internal require('./swimlaneFilter') to an import with a .js extension
(node ESM needs it; rspack/reify tolerate it). Server-only helpers that
use node built-ins (fs/path/child_process) stay CommonJS. The plain-Node
.cjs unit tests for these helpers now use `await import(...js)` (wrapped
in an async IIFE); a source-guard in importVirtualMembers was updated
from module.exports to export. Verified: the full tests/*.test.cjs suite
has the SAME 7 pre-existing failures as before this change and no new
ones.
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
// Pure decision for how an original member of an imported board becomes a member of the
|
|
// newly created board (see models/wekanCreator.js). Split out so it is unit-testable.
|
|
//
|
|
// Returns the member entry to add, or null when there is no id or the member is the
|
|
// importer (who is already the board's active admin). Without an explicit deliberate
|
|
// mapping (wekanMember.wekanId), the ORIGINAL member is kept — reusing their original id
|
|
// — but added INACTIVE and non-admin, so they are visible in the member list yet hold no
|
|
// board permission until reconciled later. A real mapping preserves the mapped role.
|
|
function planImportedBoardMember(wekanMember, importerId) {
|
|
if (!wekanMember) return null;
|
|
const memberId = wekanMember.wekanId || wekanMember.userId || wekanMember.id;
|
|
if (!memberId || memberId === importerId) return null;
|
|
const mapped = !!wekanMember.wekanId;
|
|
return {
|
|
...wekanMember,
|
|
userId: memberId,
|
|
wekanId: memberId,
|
|
isActive: mapped ? wekanMember.isActive !== false : false,
|
|
isAdmin: mapped ? !!wekanMember.isAdmin : false,
|
|
};
|
|
}
|
|
|
|
export { planImportedBoardMember };
|