From d8ca36a5aeabcb405ff163ee27b92291de7295d0 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Thu, 30 Sep 2021 14:54:45 +0200 Subject: [PATCH] fix: allow to disable load of polyfills --- packages/core/global-types.d.ts | 2 +- packages/core/globals/index.ts | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/core/global-types.d.ts b/packages/core/global-types.d.ts index 2987a1e6d..ded68b829 100644 --- a/packages/core/global-types.d.ts +++ b/packages/core/global-types.d.ts @@ -122,7 +122,7 @@ declare namespace NodeJS { TNS_WEBPACK?: boolean; isIOS?: boolean; isAndroid?: boolean; - autoRegisterUIModules?: boolean; + autoLoadPolyfills?: boolean; __requireOverride?: (name: string, dir: string) => any; // used to get the rootlayout instance to add/remove childviews diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index 5b5ee54d5..27ec52fc5 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -301,26 +301,28 @@ export function initGlobal() { }; // DOM api polyfills - // global.registerModule('timer', () => require('../timer')); - // installPolyfills('timer', ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval']); + if (global.autoLoadPolyfills !== false) { + global.registerModule('timer', () => require('../timer')); + installPolyfills('timer', ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval']); - // global.registerModule('animation', () => require('../animation-frame')); - // installPolyfills('animation', ['requestAnimationFrame', 'cancelAnimationFrame']); + global.registerModule('animation', () => require('../animation-frame')); + installPolyfills('animation', ['requestAnimationFrame', 'cancelAnimationFrame']); - // global.registerModule('ui-dialogs', () => require('../ui/dialogs')); - // installPolyfills('ui-dialogs', ['alert', 'confirm', 'prompt', 'login', 'action']); + global.registerModule('ui-dialogs', () => require('../ui/dialogs')); + installPolyfills('ui-dialogs', ['alert', 'confirm', 'prompt', 'login', 'action']); - // global.registerModule('text', () => require('../text')); - // installPolyfills('text', ['TextDecoder', 'TextEncoder']); + global.registerModule('text', () => require('../text')); + installPolyfills('text', ['TextDecoder', 'TextEncoder']); - // global.registerModule('xhr', () => require('../xhr')); - // installPolyfills('xhr', ['XMLHttpRequest', 'Blob', 'File', 'FileReader']); + global.registerModule('xhr', () => require('../xhr')); + installPolyfills('xhr', ['XMLHttpRequest', 'Blob', 'File', 'FileReader']); - // global.registerModule('formdata', () => require('../polyfills/formdata')); - // installPolyfills('formdata', ['FormData']); + global.registerModule('formdata', () => require('../polyfills/formdata')); + installPolyfills('formdata', ['FormData']); - // global.registerModule('fetch', () => require('../fetch')); - // installPolyfills('fetch', ['fetch', 'Headers', 'Request', 'Response']); + global.registerModule('fetch', () => require('../fetch')); + installPolyfills('fetch', ['fetch', 'Headers', 'Request', 'Response']); + } // global.registerModule('abortcontroller', () => require('../abortcontroller')); // installPolyfills('abortcontroller', ['AbortController', 'AbortSignal']);