Skip to content

Commit

Permalink
Ensure airtable.js browser build works
Browse files Browse the repository at this point in the history
- Regenerate the the airtable.browser.js via grunt and ensure that it
works via the python server
- Replace `node-fetch` and `abort-controller` packages with the build in
versions on the window for the browser build
- Maybe they should instead be replace by polyfills. There is a lack of
clarity of what browsers needs to be supported.
- Both fetch and abortController are widely supported by many browsers
so I think the polyfills can be skipped.

https://developer.mozilla.org/en-US/docs/Web/API/AbortController#Browser_compatibility
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility
  • Loading branch information
rmeritz committed Jun 24, 2020
1 parent 2bca72d commit 406e00f
Show file tree
Hide file tree
Showing 5 changed files with 5,626 additions and 75,704 deletions.
3 changes: 3 additions & 0 deletions lib/abort-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var AbortController = require('abort-controller');

module.exports = typeof window === 'undefined' ? AbortController : window.AbortController;
4 changes: 2 additions & 2 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ var forEach = require('lodash/forEach');
var get = require('lodash/get');
var assign = require('lodash/assign');
var isPlainObject = require('lodash/isPlainObject');
var fetch = require('node-fetch');
var AbortController = require('abort-controller');
var fetch = require('./fetch');
var AbortController = require('./abort-controller');

var objectToQueryParamString = require('./object_to_query_param_string');
var AirtableError = require('./airtable_error');
Expand Down
3 changes: 3 additions & 0 deletions lib/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var fetch = require('node-fetch');

module.exports = typeof window === 'undefined' ? fetch : window.fetch;
5 changes: 2 additions & 3 deletions lib/run_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
var exponentialBackoffWithJitter = require('./exponential_backoff_with_jitter');
var objectToQueryParamString = require('./object_to_query_param_string');
var packageVersion = require('./package_version');

var fetch = require('node-fetch');
var AbortController = require('abort-controller');
var fetch = require('./fetch');
var AbortController = require('./abort-controller');

var userAgent = 'Airtable.js/' + packageVersion;

Expand Down
Loading

0 comments on commit 406e00f

Please sign in to comment.