Skip to content

Commit

Permalink
FIO 7733: move polyfill to conditional lazy import (#5506)
Browse files Browse the repository at this point in the history
* move polyfill to conditional import

* minor change to eslint config
  • Loading branch information
brendanbond authored Apr 23, 2024
1 parent f96bf94 commit 1ad7247
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"parser": "@typescript-eslint/parser",
"extends": "formio",
"parserOptions": {
"ecmaVersion": 2015,
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"env": {
"browser": true,
"es6": true,
"es2020": true,
"node": true,
"mocha": true
},
Expand Down
8 changes: 7 additions & 1 deletion src/providers/storage/s3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import XHR from './xhr';
import { withRetries } from './util';

const AbortController = window.AbortController || require('abortcontroller-polyfill/dist/cjs-ponyfill');
const loadAbortControllerPolyfill = async() => {
if (typeof AbortController === 'undefined') {
await import('abortcontroller-polyfill/dist/polyfill-patch-fetch');
}
};

function s3(formio) {
return {
async uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions) {
Expand All @@ -11,6 +16,7 @@ function s3(formio) {
if (response.signed) {
if (multipartOptions && Array.isArray(response.signed)) {
// patch abort callback
await loadAbortControllerPolyfill();
const abortController = new AbortController();
const abortSignal = abortController.signal;
if (typeof abortCallback === 'function') {
Expand Down

0 comments on commit 1ad7247

Please sign in to comment.