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.
33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
// #3185 "Template with subtasks and checklists". When a card is copied (e.g.
|
|
// generating a card from a template), each subtask was inserted as a BARE card
|
|
// document — its checklists (and their items) were never copied, so the new
|
|
// card's subtasks came out empty. The parent card's own checklists were copied,
|
|
// but the per-subtask copy skipped them.
|
|
//
|
|
// buildCopiedSubtaskFields() builds the card document for a copied subtask
|
|
// (re-homed under the new parent and onto the destination board), and
|
|
// subtaskCopyChildKinds() declares the child records a subtask copy must also
|
|
// reproduce — 'checklists' being the one that was missing in #3185. Meteor-free
|
|
// so the re-homing and the copy contract are unit tested; the caller then runs
|
|
// Checklist.copy() for each kind.
|
|
function buildCopiedSubtaskFields(subtask, { newParentId, boardId, swimlaneId, listId } = {}) {
|
|
const fields = Object.assign({}, subtask);
|
|
delete fields._id;
|
|
fields.parentId = newParentId;
|
|
fields.boardId = boardId;
|
|
fields.swimlaneId = swimlaneId;
|
|
fields.listId = listId;
|
|
return fields;
|
|
}
|
|
|
|
// The child-record kinds a full subtask copy must reproduce. Guards #3185: a
|
|
// subtask copy that reproduces only the card (this list empty / missing
|
|
// 'checklists') is the regression.
|
|
function subtaskCopyChildKinds() {
|
|
return ['checklists'];
|
|
}
|
|
|
|
export { buildCopiedSubtaskFields, subtaskCopyChildKinds };
|