-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: refactored to support node/browser targets using babel #1423
Conversation
@kornelski I also suggest that we use |
There's an issue right now with |
As an aside, if you use |
Tests should pass now, I think. |
I doubt that we can use this package, but I made it anyways https://github.com/niftylettuce/spdy-or-http2. Not sure of the differences or if there'd be a conflict. The only reason why tests fail is because |
Codecov Report
@@ Coverage Diff @@
## master #1423 +/- ##
=========================================
Coverage ? 94.64%
=========================================
Files ? 10
Lines ? 766
Branches ? 0
=========================================
Hits ? 725
Misses ? 41
Partials ? 0
Continue to review full report at Codecov.
|
✅ all tests are now passing btw |
I also had updated the docs too, you can view a preview at https://github.com/niftylettuce/superagent. |
That's a huge PR with many unrelated changes. It'll take me a while to review it. |
Thanks @kornelski, if I can answer any questions please let me know. This is blocking for me right now and I published I didn't change any core code other than running it through the linter / xo / prettier with Currently there are a ton of code quality issues with the existing codebase, such as using The reason the PR is so huge is because I used https://lass.js.org, and therefore moved everything from |
@niftylettuce Thanks for this, I was also blocked on the same issue with having ES6 slip into a final build. Your package |
Hi! Sorry, there are too many unrelated changes. I can't accept this PR. I don't have time to review 20000 lines of changes. It doesn't matter that the changes are just from a code formatter, I can't accept code changes I haven't reviewed, and basically everything everywhere has changed. I'm still keen to improve compilation for browsers, but just that. Please leave out changes of quoting style or moving commas and semicolons around. |
This will also fix #1437 I will release this soon, thank you folks for adding me as a contributor! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this, especially making a browser compatible version.
Instead of switching to Yarn, please just start committing the package-lock.json
from npm
["@babel/env", { | ||
"targets": { | ||
"node": "8.8.1", | ||
"browsers": [ "> 1%", "last 2 versions", "ie >= 9" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: is there a way to use the .browserlistrc
file here so we don't have duplicated config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not
package-lock.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: while not a change you made, package-lock.json
should absolutely be being committed to the codebase.
@@ -5,3 +5,5 @@ examples | |||
lib-cov | |||
coverage.html | |||
bower.json | |||
.nyc_output | |||
coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't think this file isn't being used because we already specify the files
directive in package.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a scenario which happened multiple times (and I reported to NPM) where despite files
and being in .gitignore
, NPM tarball contained these folders, so it was just a safe guard.
@@ -0,0 +1,3 @@ | |||
CONTRIBUTING.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this repo use Remark?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now using it (via my PR), I have to update the contributors block still, it's pretty cool - gets read from contributors
in package.json
and automatically added to README.md
in the # Contributors
section.
@@ -58,9 +58,9 @@ exports.unzip = (req, res) => { | |||
// override `on` to capture data listeners | |||
const _on = res.on; | |||
res.on = function(type, fn) { | |||
if ('data' == type || 'end' == type) { | |||
if (type == 'data' || type == 'end') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use ===
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left most of the core logic as-is, this was from prior code. If you see I turned a TON of ESLint rules off so the tests would pass... there were so many existing issues with the old codebase.
this.serverError = type == 5; | ||
this.error = type == 4 || type == 5 ? this.toError() : false; | ||
|
||
// sugar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use ===
. use Number.parseInt(status, 10)
if status
is a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as #1423 (comment), what we have to do is fix this everywhere by turning off the rules one by one and fixing lint errors. I didn't want to do a daunting commit with tons of changes everywhere, my first step was getting browser support done.
"type": "git", | ||
"url": "https://github.com/visionmedia/superagent" | ||
}, | ||
"scripts": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: these should be near the top of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use fixpack
which organizes them differently, I think there might be a way to configure the order somehow with fixpack
. Is there a better alternative than using fixpack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like what I'm looking for should be the default behavior: From the fixpack
docs:
It will re-write your package.json file as follows:
- name first
- description second
- version third
- author fourth
- all other keys in alphabetical order
- dependencies and devDependencies sorted alphabetically
- newline at the end of the file
It seems you could create a .fixpackrc
file to manage the configuration.
Personally I just manage package.json
files manually (save for npm install
runs)
"test-coverage": "npm run build && npm run lint && npm run nyc" | ||
}, | ||
"unpkg": "dist/superagent.min.js", | ||
"xo": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an ESLint config. Can we use a .eslintrc
file instead please? This really clutters this file
return new exports.Request('GET', method).end(url); | ||
} | ||
|
||
// url first | ||
if (1 == arguments.length) { | ||
if (arguments.length == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use ===
try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {} | ||
if ( | ||
root.XMLHttpRequest && | ||
(!root.location || root.location.protocol != 'file:' || !root.ActiveXObject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use !==
Ill double check this before I publish. Thank you for your review. Super super helpful to have extra set of eyes.
…On January 11, 2019 12:47:21 AM UTC, Matthew Herbst ***@***.***> wrote:
MatthewHerbst commented on this pull request.
> + },
+ "prettier": {
+ "singleQuote": true,
+ "bracketSpacing": true,
+ "trailingComma": "none"
+ },
+ "remarkConfig": {
+ "plugins": [
+ "preset-github"
+ ]
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/visionmedia/superagent"
+ },
+ "scripts": {
It seems like what I'm looking for should be the default behavior: From
[the `fixpack` docs](https://www.npmjs.com/package/fixpack):
> It will re-write your package.json file as follows:
>
> - name first
> - description second
> - version third
> - author fourth
> - all other keys in alphabetical order
> - dependencies and devDependencies sorted alphabetically
> - newline at the end of the file
It seems you could create a `.fixpackrc` file to manage the
configuration.
Personally I just manage `package.json` files manually (save for `npm
install` runs)
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#1423 (comment)
|
@niftylettuce what's the status of this? will 5.0 be released soon? |
Will try to get this released today. |
v5.0.0 was just released to NPM and an updated README is now available here on GitHub (see https://github.com/visionmedia/superagent#superagent). What's new
How to installnpm install superagent@latest
yarn add superagent@latest PolyfillsPlease see the Required Browser Features section in the README if you plan to support IE 9 and/or IE 10 and use |
btw @MatthewHerbst I fixed all those weird syntax and equality issues from the old version, e.g. |
@niftylettuce thanks so much for your hard work on this! Excited to upgrade at my company today 🚀 |
this should resolve tons of issues, but namely these ones:
#1418, #1365, #1421, #1390, #1340, #1276, #1269