Skip to content

Commit bab91cf

Browse files
author
Robert Jackson
committed
Remove najax from default set of sandbox globals.
* 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 [email protected]) 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, }); } }); ```
1 parent ed9b9d1 commit bab91cf

File tree

5 files changed

+0
-32
lines changed

5 files changed

+0
-32
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"chalk": "^2.4.2",
2929
"cookie": "^0.4.0",
3030
"debug": "^4.1.1",
31-
"najax": "^1.0.4",
3231
"resolve": "^1.12.0",
3332
"simple-dom": "^1.4.0",
3433
"source-map-support": "^0.5.13"

src/ember-app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const vm = require('vm');
55
const path = require('path');
66
const chalk = require('chalk');
77

8-
const najax = require('najax');
98
const SimpleDOM = require('simple-dom');
109
const resolve = require('resolve');
1110
const debug = require('debug')('fastboot:ember-app');
@@ -92,7 +91,6 @@ class EmberApp {
9291
}
9392

9493
let defaultGlobals = {
95-
najax,
9694
FastBoot: {
9795
require: sandboxRequire,
9896
config: fastbootConfig,

test/fastboot-test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ describe('FastBoot', function() {
175175
buildSandboxGlobals(globals) {
176176
return Object.assign({}, globals, {
177177
foo: 5,
178-
najax: 'undefined',
179178
myVar: 'undefined',
180179
});
181180
},
@@ -186,7 +185,6 @@ describe('FastBoot', function() {
186185
.then(r => r.html())
187186
.then(html => {
188187
expect(html).to.match(/foo from sandbox: 5/);
189-
expect(html).to.match(/najax in sandbox: undefined/);
190188
});
191189
});
192190

@@ -264,7 +262,6 @@ describe('FastBoot', function() {
264262
buildSandboxGlobals(globals) {
265263
return Object.assign({}, globals, {
266264
foo: 5,
267-
najax: 'undefined',
268265
myVar: 'undefined',
269266
});
270267
},
@@ -279,7 +276,6 @@ describe('FastBoot', function() {
279276
.then(r => r.html())
280277
.then(html => {
281278
expect(html).to.match(/foo from sandbox: 5/);
282-
expect(html).to.match(/najax in sandbox: undefined/);
283279
});
284280

285281
function hotReloadApp() {

test/fixtures/custom-sandbox/assets/fastboot-trial.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

yarn.lock

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,11 +1971,6 @@ isobject@^4.0.0:
19711971
resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0"
19721972
integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==
19731973

1974-
jquery-deferred@^0.3.0:
1975-
version "0.3.1"
1976-
resolved "https://registry.yarnpkg.com/jquery-deferred/-/jquery-deferred-0.3.1.tgz#596eca1caaff54f61b110962b23cafea74c35355"
1977-
integrity sha1-WW7KHKr/VPYbEQlisjyv6nTDU1U=
1978-
19791974
js-tokens@^4.0.0:
19801975
version "4.0.0"
19811976
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -2095,11 +2090,6 @@ locate-path@^5.0.0:
20952090
dependencies:
20962091
p-locate "^4.1.0"
20972092

2098-
lodash.defaultsdeep@^4.6.0:
2099-
version "4.6.1"
2100-
resolved "https://registry.yarnpkg.com/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz#512e9bd721d272d94e3d3a63653fa17516741ca6"
2101-
integrity sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==
2102-
21032093
lodash.find@^4.6.0:
21042094
version "4.6.0"
21052095
resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1"
@@ -2391,15 +2381,6 @@ mz@^2.4.0:
23912381
object-assign "^4.0.1"
23922382
thenify-all "^1.0.0"
23932383

2394-
najax@^1.0.4:
2395-
version "1.0.4"
2396-
resolved "https://registry.yarnpkg.com/najax/-/najax-1.0.4.tgz#63fd8dbf15d18f24dc895b3a16fec66c136b8084"
2397-
integrity sha512-wsSacA+RkgY1wxRxXCT3tdqzmamEv9PLeoV/ub9SlLf2RngbPMSqc3A7H35XJDfURC0twMmZsnPdsYPkuuFSVg==
2398-
dependencies:
2399-
jquery-deferred "^0.3.0"
2400-
lodash.defaultsdeep "^4.6.0"
2401-
qs "^6.2.0"
2402-
24032384
natural-compare@^1.4.0:
24042385
version "1.4.0"
24052386
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@@ -2878,11 +2859,6 @@ [email protected]:
28782859
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
28792860
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
28802861

2881-
qs@^6.2.0:
2882-
version "6.9.0"
2883-
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.0.tgz#d1297e2a049c53119cb49cca366adbbacc80b409"
2884-
integrity sha512-27RP4UotQORTpmNQDX8BHPukOnBP3p1uUJY5UnDhaJB+rMt9iMsok724XL+UHU23bEFOHRMQ2ZhI99qOWUMGFA==
2885-
28862862
ramda@^0.26.1:
28872863
version "0.26.1"
28882864
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.26.1.tgz#8d41351eb8111c55353617fc3bbffad8e4d35d06"

0 commit comments

Comments
 (0)