mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
refactor globalThis polyfill to improve legacy support
This commit is contained in:
@@ -443,13 +443,18 @@ class RequireExternalsPlugin {
|
||||
|
||||
_ensureGlobalThisModule() {
|
||||
const block = [
|
||||
`/* Polyfill globalThis.module & exports */`,
|
||||
`if (typeof globalThis.module === 'undefined') {`,
|
||||
` globalThis.module = { exports: {} };`,
|
||||
`/* Polyfill globalThis.module, exports & module for legacy */`,
|
||||
`if (typeof globalThis !== 'undefined') {`,
|
||||
` if (typeof globalThis.module === 'undefined') {`,
|
||||
` globalThis.module = { exports: {} };`,
|
||||
` }`,
|
||||
` if (typeof globalThis.exports === 'undefined') {`,
|
||||
` globalThis.exports = globalThis.module.exports;`,
|
||||
` }`,
|
||||
`}`,
|
||||
`if (typeof window.module === 'undefined') {`,
|
||||
` window.module = { exports: {} };`,
|
||||
`}`,
|
||||
`if (typeof globalThis.exports === 'undefined') {`,
|
||||
` globalThis.exports = globalThis.module.exports;`,
|
||||
`}`
|
||||
].join('\n') + '\n';
|
||||
|
||||
let content = '';
|
||||
|
||||
Reference in New Issue
Block a user