mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -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.
39 lines
1.9 KiB
JavaScript
39 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
// Pure guard for the "Link to this card" feature (#5808). Linking a card to an
|
|
// existing linked card (or to one that links back) builds a chain/cycle of
|
|
// linkedId references. The card helpers resolve linkedId only ONE hop
|
|
// (getTitle/getBoardTitle/getRealId read `getCard(linkedId).<field>` directly),
|
|
// so a link whose target is itself a linked card resolves to another pointer
|
|
// instead of a real card — the card renders as an empty/broken pointer and
|
|
// becomes effectively inaccessible (the reported "both cards inaccessible /
|
|
// freeze"). Mirrors the #3328 parent/subtask cycle guard, but for linkedId.
|
|
//
|
|
// Rule: a link target must be a REAL card (not a linked card, linked board, or
|
|
// template card), must not be one of the linking board's own cards (self / same
|
|
// board), and must not already link back to one of them (direct mutual link).
|
|
|
|
const LINK_TYPES = new Set(['cardType-linkedCard', 'cardType-linkedBoard']);
|
|
|
|
// A card that is itself a link (card or board) — never a valid link target,
|
|
// because linking to it would create a chain of linkedId pointers.
|
|
function isLinkPointerCard(card) {
|
|
return !!card && LINK_TYPES.has(card.type);
|
|
}
|
|
|
|
// Whether `target` may be linked from the board whose real card ids are
|
|
// `ownRealCardIds` (Card.getRealId() of every card already on that board).
|
|
function isLinkableCardTarget(target, ownRealCardIds = []) {
|
|
if (!target || !target._id) return false;
|
|
// No chains of links, and no template cards.
|
|
if (isLinkPointerCard(target) || target.type === 'template-card') return false;
|
|
const own = ownRealCardIds instanceof Set ? ownRealCardIds : new Set(ownRealCardIds);
|
|
// Not one of our own cards (self / same-board link).
|
|
if (own.has(target._id)) return false;
|
|
// Not a card that already links back to one of our cards (direct mutual link).
|
|
if (target.linkedId && own.has(target.linkedId)) return false;
|
|
return true;
|
|
}
|
|
|
|
export { isLinkPointerCard, isLinkableCardTarget };
|