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

Browser support #13

Closed
devinrhode2 opened this issue Jun 30, 2016 · 2 comments · Fixed by #14
Closed

Browser support #13

devinrhode2 opened this issue Jun 30, 2016 · 2 comments · Fixed by #14

Comments

@devinrhode2
Copy link
Contributor

devinrhode2 commented Jun 30, 2016

I'm using babel as a part of ember-cli, had to use ember-browserify to be able to import better-assert, but now I get fs.readFileSync is not a function because this is a browser, of course.

This code:

import assert from 'npm:better-assert'

try {
    console.log('before calling assert')
    assert('true')
    console.log('called assert')
    assert(false)
    console.log('called with false')
} catch (e) {
    console.log('caught err'+e.stack)
}

Prints this:

before calling assert
cat.js:7 called assert
cat.js:11 caught errTypeError: fs.readFileSync is not a function
    at assert (http://localhost:4200/assets/vendor.js:65236:16)
    at Module.callback (http://localhost:4200/assets/dynamic-segments.js:385:35)
    at Module.exports (http://localhost:4200/assets/vendor.js:131:32)
    at requireModule (http://localhost:4200/assets/vendor.js:30:18)
    at Class._extractDefaultExport (http://localhost:4200/assets/vendor.js:144697:20)
    at Class.resolveOther (http://localhost:4200/assets/vendor.js:144432:32)
    at Class.superWrapper (http://localhost:4200/assets/vendor.js:35482:22)
    at Class.resolve (http://localhost:4200/assets/vendor.js:16205:43)
    at resolve (http://localhost:4200/assets/vendor.js:12565:36)
    at Object.resolve (http://localhost:4200/assets/vendor.js:12025:21)

Ember goliath generates horrible stack trace! 💯 :)

Going to fork and see what I can do..!

@devinrhode2
Copy link
Contributor Author

This issue: #12 COULD ALSO affect the ember/babel/browser use case, but I'm NOT SURE.

devinrhode2 added a commit to devinrhode2/better-assert-browser that referenced this issue Jul 1, 2016
@devinrhode2
Copy link
Contributor Author

I replaced the fs.readFile call with a window.fetch call for the browser, and am going to leave this as a separate fork here: https://github.com/devinrhode2/better-assert-browser

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

Successfully merging a pull request may close this issue.

1 participant