Skip to content

Commit

Permalink
Merge pull request #447 from ember-cli/simplify
Browse files Browse the repository at this point in the history
Remove ember-fetch/mixins/adapter-fetch ember-fetch/ajax, drop node 8
  • Loading branch information
xg-wang authored Mar 28, 2020
2 parents 0a2d176 + ebf025e commit 36c3a2b
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 753 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "8"
- "10"

addons:
chrome: stable
Expand Down
61 changes: 1 addition & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,9 @@ To use `ember-fetch` with TypeScript or enable editor's type support, You can ad

### Use with Ember Data

> [email protected] was released with built-in fetch support, this mixin is no longer needed and will be removed in next major bump.
To have Ember Data utilize `fetch` instead of jQuery.ajax to make calls to your backend, extend your project's `application` adapter with the `adapter-fetch` mixin.

```js
// app/adapters/application.js
import DS from 'ember-data';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';

export default DS.RESTAdapter.extend(AdapterFetch, {
...
});
```
[email protected] was released with built-in fetch support, if your ember-data is below 3.9.2, please checkout [ember-fetch v7.x](https://github.com/ember-cli/ember-fetch/tree/v7.x).

### Use with Fastboot
#### ajax-service
Currently, Fastboot supplies its own server-side ajax functionality, and including `ember-fetch` and the `adapter-fetch` mixin in a Fastboot app will not work without some modifications. To allow the `node-fetch` polyfill that is included with this addon to make your API calls, you must add an initializer to the consuming app's `fastboot` directory that overrides the one Fastboot utilizes to inject its own ajax.

Example:
```js
// fastboot/initializers/ajax.js

export default {
name: 'ajax-service',
initialize() {
// noop
// This is to override Fastboot's initializer which prevents ember-fetch from working
// https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/fastboot/initializers/ajax.js
}
}
```

#### relative url
`ember-fetch` uses `node-fetch` in Fastboot, which [doesn't allow relative URL](https://github.com/bitinn/node-fetch/tree/v2.3.0#fetchurl-options).

Expand Down Expand Up @@ -199,33 +170,3 @@ export default Route.extend({
* we actually don't bundle github/fetch rather we merely wrap/transform what
comes from `node_modules`, so we should be resilient to changes assuming
semver from the fetch module

## Deprecations

### deprecate-fetch-ember-data-support

Starting with [`ember-data`](https://www.npmjs.com/package/ember-data) v3.9.2, the library comes with built-in fetch support.
To address this deprecation, find imports and uses of the `ember-fetch/mixins/adapter-fetch` module:

Before:

```js
// app/adapters/application.js
import DS from 'ember-data';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';

export default DS.RESTAdapter.extend(AdapterFetch, {
//
});
```

After:

```js
// app/adapters/application.js
import DS from 'ember-data';

export default DS.RESTAdapter.extend({
//
});
```
14 changes: 0 additions & 14 deletions addon/ajax.ts

This file was deleted.

232 changes: 0 additions & 232 deletions addon/mixins/adapter-fetch.ts

This file was deleted.

1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ init:
environment:
MOCHA_REPORTER: "mocha-appveyor-reporter"
matrix:
- nodejs_version: "8"
- nodejs_version: "10"

# Install scripts. (runs after repo cloning)
Expand Down
4 changes: 0 additions & 4 deletions assets/browser-fetch.js.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,4 @@
delete self[prop];
});
});

define('fetch/ajax', ['exports'], function() {
throw new Error('You included `fetch/ajax` but it was renamed to `ember-fetch/ajax`');
});
}(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"**/engine.io": "~3.3.0"
},
"engines": {
"node": "8.* || >= 10"
"node": ">= 10"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
6 changes: 0 additions & 6 deletions public/fetch-fastboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,3 @@ define('fetch', ['exports'], function(exports) {
exports.Response = nodeFetch.Response;
exports.AbortController = AbortControllerPolyfill.AbortController;
});

define('fetch/ajax', ['exports'], function() {
throw new Error(
'You included `fetch/ajax` but it was renamed to `ember-fetch/ajax`'
);
});
Loading

0 comments on commit 36c3a2b

Please sign in to comment.