Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install and npm usage documentation missing #221

Open
quantuminformation opened this issue Dec 1, 2017 · 6 comments
Open

npm install and npm usage documentation missing #221

quantuminformation opened this issue Dec 1, 2017 · 6 comments

Comments

@quantuminformation
Copy link

No description provided.

@jherdman
Copy link

This would be really nice. I'm a bit confused as is. Installing into a project gives me this error when running my tests:

FakeFetch is undefined, can't access property "fetch" of it

Looking at ecli-pretender's package.json:

https://github.com/rwjblue/ember-cli-pretender/blob/ea7dc7abe1c3ce26011f9beacc4f5c41e7ff699a/package.json#L62-L72

it looks like they're installing quite a few of the dependencies in this project:

pretender/package.json

Lines 41 to 45 in 6cdf4e5

"dependencies": {
"@xg-wang/whatwg-fetch": "^3.0.0",
"fake-xml-http-request": "^2.0.0",
"route-recognizer": "^0.3.3"
},

It kind of suggests to me that these are indeed peerDependencies instead. Is that correct?

@jherdman
Copy link

Alternatively, whatwg-fetch is missing as an import here:

pretender/index.d.ts

Lines 1 to 2 in 6cdf4e5

import FakeXMLHttpRequest from "fake-xml-http-request";
import { Params, QueryParams } from "route-recognizer";

@xg-wang
Copy link
Member

xg-wang commented Oct 1, 2018

@jherdman , if you are on browser environment the assumption is that route-recognizer, fake-xml-http-request and whatwg-fetch/dist/fetch.umd.js are installed together with pretender, so they are dependencies. You can take a look at ember-cli-pretender's implementation.

For index.d.ts, can you explain more on what should be imported here?

@jherdman
Copy link

jherdman commented Oct 1, 2018

Thank you, that definitely helps. I think we can use this information to beef up the README with installation instructions — things currently are a bit murky.

I'm a bit of a TypeScript neophyte, so I don't fully understand the significance of the index.d.ts file. But it seems strange to me that

var FakeFetch = appearsBrowserified ? getModuleDefault(require('@xg-wang/whatwg-fetch')) : self.WHATWGFetch;

references code that isn't necessarily loaded. And that

pretender/pretender.js

Lines 13 to 15 in 6cdf4e5

var RouteRecognizer = appearsBrowserified ? getModuleDefault(require('route-recognizer')) : self.RouteRecognizer;
var FakeXMLHttpRequest = appearsBrowserified ? getModuleDefault(require('fake-xml-http-request')) :
self.FakeXMLHttpRequest;

references code that looks to be loaded in the index.d.ts file. This line of thinking comes from my above noted FakeFetch error, but I don't see a RouteRecognizer error (maybe it's loaded as a side dependency already???).

@xg-wang
Copy link
Member

xg-wang commented Oct 3, 2018

@jherdman you don't need to worry about index.d.ts file since mirage is not using typescript. If you're curious about how typescript def loading works, you can checkout their documentation.

@jherdman
Copy link

jherdman commented Oct 3, 2018

Thank you again for the reply, @xg-wang . I really appreciate your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants