mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Three attempts at this have added imports to client/lib/swcHelpers.js and 10.51
still failed in Yandex Browser with the same line. The stack says where to look:
Uncaught Error: Cannot find module '@swc/helpers/_/_possible_constructor_return'
at a.s [as link] (...) at client-rspack.js (...:285:985)
at client-meteor.js (...:285:86)
Read outward: client-meteor.js links client-rspack.js, and the failing link() is
inside client-rspack.js. But the bundle rspack writes contains no @swc/helpers
specifier at all - the built _build/main-prod/client-rspack.js has the helper
bodies INLINED and the string nowhere. So the import is in the copy of that file
that METEOR compiled, and Meteor put it there:
* package.json says "meteor": { "modern": true }, which turns on Meteor 3.3+'s
SWC transpiler for every file;
* packages/babel-compiler/babel-compiler.js sets jsc.externalHelpers: true
whenever node_modules/@swc/helpers exists - and WeKan depends on it - so the
output IMPORTS its helpers instead of inlining them;
* for web.browser.legacy that transpile passes no jsc.target and an env.targets
down to ie 11, so `class` is lowered to ES5 and the output gains
import { _ } from "@swc/helpers/_/_possible_constructor_return";
* that specifier is not in the legacy bundle's module tree and the link()
throws before anything runs. The modern bundle is unaffected: nothing there is
lowered that far, and modules-runtime/modern.js resolves
mainFields ['browser','module','main'] - the esm/ file - where legacy.js
prefers `main`, which is ../../cjs/_x.cjs.
That is also why the earlier fixes could not work. client/lib/swcHelpers.js is in
the RSPACK graph; rspack resolves its imports and inlines the helper bodies, so
they never become entries in Meteor's module tree, which is the tree the failing
link() searches. No import from app code can satisfy a link that Meteor's
transpiler writes afterwards.
So .swcrc sets jsc.externalHelpers: false and SWC inlines each helper into the
file that needs it: the import is not emitted, so it cannot go missing. Both
readers of that file merge it over their defaults and neither preserves this key -
Meteor's deepMerge keeps only jsc.target, env.targets and module.type, and
@meteorjs/rspack's cleanOmittedPaths only jsc.target - so it reaches the Meteor
transpile and the rspack build alike. It costs a copy of a helper per file that
uses one, which is the right trade for a bundle that does not load at all.
.gitignore's `*.sw*` is for vim's .swp/.swo and matched .swcrc too, so adding it
was silently a no-op; `!.swcrc` follows it, and the test fails if that exception
is removed or moved above the rule that needs it.
Only browsers served the legacy bundle could hit any of this, which is why it read
as a Yandex bug. useragent-ng reports Yandex Browser as family "Yandex Browser",
webapp camel-cases that to yandexBrowser, and modern-browsers has neither a
minimum nor a chrome alias for that name - isModern() is false for a name nobody
declared - so every Yandex Browser user was served ES5. server/modernBrowsers.js
declares yandexBrowser 18: its major version is a year, and 18.x is Chromium 64,
past full ES2015 (51) and dynamic import() (63). Samsung Internet, Vivaldi, Opera
Mobile, Whale, MIUI, UC and QQ Browser are in the same position and are left
alone on purpose - their version numbers do not map onto a Chromium version - and
the file says so rather than looking like they were forgotten.
tests/modernBrowsers.test.cjs reproduces Meteor's decision (webapp's camelCase,
modern-browsers' alias table and lookup) against real user agent strings, so it
fails if the key stops matching the family name or the minimum stops covering the
versions in the reports. tests/swcLegacyHelpers.test.cjs now pins .swcrc, that
the keys the readers preserve are NOT set there, the gitignore exception, and that
swcHelpers.js still says it is a diagnostic rather than the fix.
Thanks to zubzhaaaw and xet7 !
Fixes #6557,
42 lines
2.5 KiB
JavaScript
42 lines
2.5 KiB
JavaScript
// ============================================================================
|
|
// Yandex Browser is a modern browser, and must be served the modern bundle
|
|
// (#6557).
|
|
//
|
|
// Meteor decides between `web.browser` and `web.browser.legacy` per request:
|
|
// `webapp` identifies the browser with `useragent-ng` and camel-cases the family
|
|
// it reports, then `modern-browsers` looks that name up in the minimum versions
|
|
// its packages have declared. A name nobody declared a minimum for is NOT modern -
|
|
// `isModern()` returns false for an unknown name - so it gets the ES5 bundle.
|
|
//
|
|
// Yandex Browser reports family "Yandex Browser", which camel-cases to
|
|
// `yandexBrowser`. `modern-browsers` has no minimum for it and no alias mapping it
|
|
// onto chrome (its `browserAliases` covers chromeMobile, chromium, headlesschrome,
|
|
// ie, edgeMobile, firefoxMobile, mobileSafari and appleMail - not this), so every
|
|
// Yandex Browser user was served the legacy bundle. That is why #6534 / #6535 /
|
|
// #6556 / #6557 looked like a Yandex bug: the legacy bundle was the broken one
|
|
// (see /.swcrc and client/lib/swcHelpers.js), and Yandex users were the only ones
|
|
// getting it.
|
|
//
|
|
// Yandex Browser is Chromium, and its version number is a year: 18.x (2018) is
|
|
// already Chromium 64, comfortably past everything the modern bundle assumes -
|
|
// full ES2015 (Chromium 51) and dynamic `import()` (Chromium 63). Asking for 18
|
|
// keeps a genuinely ancient build on the legacy bundle while giving the modern one
|
|
// to every version anybody is actually running (the reports are 24.x).
|
|
//
|
|
// The maximum of all declared minimums wins, so this only ever ADDS a browser
|
|
// family; it cannot lower the bar for chrome, firefox, safari or any of the
|
|
// families Meteor's own packages speak for.
|
|
//
|
|
// NOT claimed here, deliberately: Samsung Internet, Vivaldi, Opera Mobile, Whale,
|
|
// MIUI Browser, UC Browser and QQ Browser Mobile are all reported under their own
|
|
// family names too, and so are all served the legacy bundle. They are modern
|
|
// Chromium in practice, but their version numbers do not map onto a Chromium
|
|
// version in any way that can be checked from here, so declaring a minimum for
|
|
// them would be a guess. The legacy bundle works again, so they lose speed rather
|
|
// than the app; add them one at a time, with the Chromium version each one's
|
|
// minimum corresponds to.
|
|
// ============================================================================
|
|
import { setMinimumBrowserVersions } from 'meteor/modern-browsers';
|
|
|
|
setMinimumBrowserVersions({ yandexBrowser: 18 }, 'WeKan');
|