Remove najax from default set of sandbox globals.#247
Merged
rwjblue merged 1 commit intoember-fastboot:masterfrom Nov 1, 2019
Merged
Remove najax from default set of sandbox globals.#247rwjblue merged 1 commit intoember-fastboot:masterfrom
rwjblue merged 1 commit intoember-fastboot:masterfrom
Conversation
* Recent versions of ember-data (3.12+) will automatically use
`ember-fetch` (or global `fetch`) if present, and does not need
special logic around `najax`
* New applications (as of ember-cli@3.13.0) include `ember-fetch` by
default, and do **not** include jQuery by default. Considering that
`najax` is a `jQuery.ajax` emulation API, I think this library should
avoid exposing it.
* `najax` (as a dependency of this library) is difficult for the host
application to control (e.g. get their own version), and would be
better if they provided it themselves (via `buildSandboxGlobals` API)
* Providing backwards compatibility is **very** easy (add `najax:
require('najax')` via `buildSandboxGlobals`)
* It seems better to "follow a spec" (suggesting `fetch` usage)
For applications that still need `najax` (for example, if they are using
an older ember-data version), they can do (example uses new
`buildSandboxGlobals` API):
```js
const najax = require('najax');
let fastboot = new FastBoot({
distPath: 'some/path/to/dist',
buildSandboxGlobals(globals) {
return Object.assign({}, globals, {
najax,
});
}
});
```
|
fwiw you need najax even in current versions of ember-data if you don't have ember-fetch installed. This change trolled our fastboot tests in ember-data itself because when we test the jquery scenario we add @ember/jquery and remove ember-fetch, once we bump to fastboot 3 this fails (see embermap/ember-cli-fastboot-testing#471 and ember-fastboot/ember-cli-fastboot#829). It's not clear how to add najax back in from this example for ember-cli-fastboot-testing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For applications that still need
najax(for example, if they are usingan older ember-data version), they can do (example uses new
buildSandboxGlobalsAPI):See #246 for more details about this change.
Closes #246