Skip to content

Conversation

@scottinet
Copy link
Contributor

Description

While scanning this SDK code to fix an unrelated documentation issue, I came across a process.nextTick call, which is a pure-NodeJS method.
So, I fixed that. Which led to a failed unit test, also relying on process.nextTick.

It came to me that having a browser-compatible code tested with ES6 and/or NodeJS specific code was not a good idea, so I modified ESLint to make sure our code and tests are using the same standards, and reverted unit tests from ES6 to ES5.

@scottinet scottinet self-assigned this Feb 16, 2017
@scottinet scottinet added the bug label Feb 16, 2017
@codecov-io
Copy link

codecov-io commented Feb 16, 2017

Codecov Report

Merging #184 into 4.x will not change coverage.
The diff coverage is 100%.

@@           Coverage Diff           @@
##              4.x     #184   +/-   ##
=======================================
  Coverage   99.39%   99.39%           
=======================================
  Files          16       16           
  Lines        1665     1665           
  Branches      441      441           
=======================================
  Hits         1655     1655           
  Misses         10       10
Impacted Files Coverage Δ
src/Kuzzle.js 99.45% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e60778e...8199d21. Read the comment docs.

@xbill82
Copy link
Contributor

xbill82 commented Feb 16, 2017

I don't understand the point of this PR, since the code is transiped by Webpack and in the README we tell developers to use the transipled version in dist for the browser so... All the nextTick are automatically transpiled to setTimeout(..., 0) by Webpack, making the transpiled code ES5 compliant.

@scottinet
Copy link
Contributor Author

scottinet commented Feb 16, 2017

We certainly use webpack, but there is no transpilation, everything is in pure ES5, and webpack uses the code as is to create the minified SDK version.

This was a choice made a long time ago, but now this is a choice I regret. One day I'll rewrite everything in ES6 (or even ES7 if I make my mind late enough) and use a transpiler.

Moreover (to be checked), I'm not certain that transpilers can transpile NodeJS-only methods, and process.nextTick is one of them.

@xbill82
Copy link
Contributor

xbill82 commented Feb 16, 2017

Ok, I understand.
As an aside, I can reasonably say that Webpack can translate node-specific methods to browser-specific ones. This was the aim of Browserify, which Webpack reproduces.

@scottinet scottinet changed the base branch from 3.x to 4.x February 23, 2017 09:22
@scottinet scottinet merged commit b5de17a into 4.x Feb 23, 2017
@scottinet scottinet deleted the browser-compatibility-fix branch February 23, 2017 09:37
This was referenced Apr 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants