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 8b92079
Show file tree
Hide file tree
Showing 6 changed files with 5,628 additions and 75,705 deletions.
4 changes: 4 additions & 0 deletions lib/abort-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var AbortController = require('abort-controller');

// istanbul ignore next
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
4 changes: 4 additions & 0 deletions lib/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var fetch = require('node-fetch');

// istanbul ignore next
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
1 change: 0 additions & 1 deletion test/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ describe('Base', function() {
})
.then(function() {
const {query} = testExpressApp.get('most recent request');
console.log(query);
expect(query.getAll('foo')).toEqual(['bar']);
expect(query.getAll('arr[]')).toEqual(['one', 'two']);
expect(query.getAll('obj[baz]')).toEqual(['qux']);
Expand Down
Loading

0 comments on commit 8b92079

Please sign in to comment.