mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
WeKan 10.44 in Yandex Browser died at load with
Cannot find module '@swc/helpers/_/_possible_constructor_return'
An older browser is served `web.browser.legacy`, where SWC compiles classes down
to ES5 and emits imports of its own runtime helpers. Read out of the built
bundle: it contains `link("@swc/helpers/_/_possible_constructor_return", …)` -
the app asks for it - while the module tree beside it holds 22 helper
directories, and that is not one of them. The module system cannot resolve what
the code imports, so the bundle never finishes bootstrapping and nothing renders.
The order of the build is why. Meteor's scanner decides which files of an npm
package to include from the imports it can SEE, and these imports are written by
the SWC transform afterwards - so a helper that only the transform introduces can
be linked without being included. `_call_super` came in through another helper's
relative require and `_possible_constructor_return`, which nothing else requires,
did not. Exactly one was missing, and it was enough.
client/lib/swcHelpers.js imports the ES5 class/inheritance, iteration/spread and
async helper set from ordinary client code, which the scanner does see, and
client/main.js loads it first. Each helper is a few lines, so having the whole
set removes the class of failure rather than this one instance of it - the next
class written slightly differently would otherwise pull in the next helper
nobody imported.
tests/swcLegacyHelpers.test.cjs pins it: the helper from the report is there
along with its transform neighbours, every name resolves to a real subpath of the
installed package (a typo is a silent no-op at build time and the same crash at
runtime), and the file is imported before the styles and the app code.
The modern bundle was never affected - nothing there is transformed that far -
which is why this only showed in one browser.
Thanks to zubzhaaaw and xet7 !
Fixes #6534,
Fixes #6535.
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// ============================================================================
|
|
// WeKan Client Entry Point
|
|
//
|
|
// Side-effect imports keep bootstrap order explicit without relying on
|
|
// browser-side CommonJS require().
|
|
// ============================================================================
|
|
|
|
// 0. Browser shim that MUST run before any module pulls in bson: bson 7.x calls
|
|
// `process.getBuiltinModule('v8')` at load time, which throws in the browser
|
|
// (partial `process` polyfill) and aborts the bundle bootstrap, leaving later
|
|
// features (notifications, swimlanes, …) unregistered so boards do not render.
|
|
import '/client/lib/bsonBrowserShim';
|
|
|
|
// 0b. The SWC runtime helpers the LEGACY bundle's ES5 transform emits imports
|
|
// for. They are linked by the transformed code but only INCLUDED if the
|
|
// scanner saw an import first, and one of them was not: an older browser
|
|
// (Yandex) died at load with "Cannot find module
|
|
// '@swc/helpers/_/_possible_constructor_return'" (wekan/wekan-snap#178).
|
|
// First, so a helper is present before anything transformed runs.
|
|
import '/client/lib/swcHelpers';
|
|
|
|
// 1. Bootstrap — helpers polyfill (SimpleSchema is server-only)
|
|
import '/imports/collectionHelpers';
|
|
|
|
// 2. Eagerly load all app styles
|
|
import '/client/styles';
|
|
|
|
// 3. Load all application code
|
|
import '/client/imports';
|