mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -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.
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
// #4494 "Creating a board from a template breaks subtasks". Boards are created
|
|
// from a template by copying the template board. The copy inherited the
|
|
// template's subtasksDefaultBoardId / dateSettingsDefaultBoardId verbatim. When
|
|
// those pointed at the template board ITSELF (the common case — "subtasks live
|
|
// on this board"), subtasks created on the NEW board were dropped onto the
|
|
// TEMPLATE board, and the subtask card linked back across boards to the parent.
|
|
//
|
|
// remapCopiedBoardDefaults returns the $set patch that repoints any default
|
|
// board pointer referencing the source board to the copy instead. When a board
|
|
// pointer moves, its paired list pointer is cleared (null) because that list id
|
|
// belongs to the source board's lists; it self-heals to a list on the new
|
|
// board via Board.getDefaultSubtasksListId()/getDefaultDateSettingsListId().
|
|
// Meteor-free so it can be unit tested.
|
|
function remapCopiedBoardDefaults(board, oldId, newId) {
|
|
const patch = {};
|
|
if (board && board.subtasksDefaultBoardId === oldId) {
|
|
patch.subtasksDefaultBoardId = newId;
|
|
patch.subtasksDefaultListId = null;
|
|
}
|
|
if (board && board.dateSettingsDefaultBoardId === oldId) {
|
|
patch.dateSettingsDefaultBoardId = newId;
|
|
patch.dateSettingsDefaultListId = null;
|
|
}
|
|
return patch;
|
|
}
|
|
|
|
export { remapCopiedBoardDefaults };
|