-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
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.
Several issues:
-
Some reference to the
api
are in the other packages (eg. inetherscan/accounts
). This should not occur, orparity.js
should be a dependency and used as one. -
The index files of
src
anddist
reference the3rd party
folder. This doesn't exist in thenpm
folder context
Why not having one script for the dryrun
and not dryrun
version of the npm scripts, one with one extra-line for publishing ? Right now one of them has some issues, so it would prevent that and having to maintain two scripts
js/scripts/dryrun-npm.sh
Outdated
|
||
cd $DIRECTORY | ||
pushd .; cd npm/jsonrpc |
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.
etherscan
js/scripts/dryrun-npm.sh
Outdated
|
||
done | ||
cd .. | ||
pushd .; cd npm/jsonrpc |
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.
shapeshift
js/scripts/dryrun-npm.sh
Outdated
cp -r src/api npm/parity/src/api | ||
env LIBRARY=parity npm run ci:build:npm | ||
|
||
pushd .; cd npm/jsonrpc |
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.
cd npm/parity
Changing from `~` to `../..` is a step backwards in terms of dev UX. Nevertheless, it seems worth it, because we can get rid of additional plugins/bundlers when publishing the libraries to npm. See #4479.
Note: We need to properly test |
Even though this commit introduces duplicated code, it seems worth it, because we can get rid of additional plugins/bundlers when publishing the libraries to npm. See #4479 for more details.
I updated a bit the PR. Everything seems to work fine, but we might want to test every possibility before merging. Might also want to update as a Major release, since we got rid of the babel + promise polyfills |
Don't do this -
We cannot maintain stuff (untested) in 2 places. |
|
||
if (typeof JsonRpc !== 'object') { | ||
throw new Error('JsonRpc'); | ||
} | ||
|
||
console.log(JsonRpc); | ||
console.log('JSON RPC Endpoints:', Object.keys(JsonRpc)); |
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.
Think the original was actually a debug that slipped through, however this makes (slightly) more sense.
js/webpack/libraries.js
Outdated
@@ -30,7 +30,7 @@ module.exports = { | |||
// library | |||
'inject': ['./inject.js'], | |||
'web3': ['./web3.js'], | |||
'parity': ['./parity.js'] | |||
'parity': ['./library.parity.js'] |
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.
We have things mixed up here. This version of parity is supposed to be the version served via /parity-utils/{inject,parity}.js
- library refers to the npm version.
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.
Fully agree that it's not a for the library. @ngotchac and I discussed renaming it to dev.parity.js
. What do you think?
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 not dev.parity either :)
It is actually the version of parity.js that gets used by all dapps running inside Parity. e.g. https://github.com/gavofyork/gavcoin/blob/master/index.html#L11
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.
If I don't confuse things, we can move src/parity.js
to npm/parity/src/index.js
and rename src/library.parity.js
to src/parity.js
.
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.
Yes, the changes here
and here
Are the ones where you went wrong. You tried to convert the one into the other, instead of understanding the purpose. (Changes basically copies the one to the other - more or less) Should have kept it, moved library.parity.js
to index.js
(like done elsewhere) and have been done, but rather these changes got them mixed.
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.
5da69d7 renames parity.js
to parity.npm.js
and reverts library.parity.js
to parity.js
.
@@ -0,0 +1 @@ | |||
../../abi/util/address.js |
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.
Why not moving the file in api
?
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.
@ngotchac Maybe i missed something, but then abi
would depend on api
, which we try to prevent.
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.
Not sure I fully followed the discussion about what goes in ABI vs. API. However it just looks weird to have a symlink to symlink.
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.
~/abi/util
is not part of the exposed interfaces (i.e. stuff on Abi.*), so don't use it. :)
-
Has anybody tested the symlink stuff on Windows? (Anything needs to work across Mac, Linux & Windows - although we may get away here since publishing is only done from Linux)
-
And I do agree, symlink to symlink is (very) weird, but (slightly) better than the alternative at least.
Moving from grumle to got issues. First the grumble part -
Secondly the has-issues part -
|
Ok.
The idea behind this PR is to get clean, decoupled libraries published to NPM. What you suggest would move us in the opposite direction. Maybe that sounds too harsh, but arguing that only because people use our Ethererum node we can force them to use our other stuff seems to be awfully close to embrace extend extinguish. Arguing that the lib doesn't need to have a good quality (in a PR that tries to improve it) because it's never going to be often-used also seems weird.
Will do that as a trade-off.
Polyfills are basically shared globals, Regarding
Strongly disagree. It is neither very hard nor uncommon to have users to
As stated, the Webpack version doesn't work in codebases that |
Not sure what Babel does (EDIT: babel-runtime), And sorry, but I'm not going to support anything that is going to create yet more overhead in "this doesn't work". We need to find an elegant polyfill solution if the current is not it. (And I'm probably leaning towards ignoring It is always very easy to throw out the baby with the bathwater, but you need to understand why the baby got dirty in the first place. Dependent libraries are one thing, having to deal with other stuff lands us in the category of "this is too much effort". Steps should be -
And no, we are not at #2. |
js/npm/etherscan/package.json
Outdated
"peerDependencies": { | ||
"es6-promise": "^4.0.5", | ||
"isomorphic-fetch": "^2.2.1", | ||
"babel-polyfill": "^6.22.0" |
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.
Wondering out loud... Could https://github.com/es-shims not (maybe, just maybe) be a more elegant (can include it without issues) solution. Worth a go, e.g.
require('es6-shim');
require('es7-shim');
...stuff goes here (without issues)...
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.
Scratch that.
Babel actually has the solution - the transform runtime plugin. Basically means only babel-runtime
is added as a package dep, and the runtime includes the polyfill without polluting the global namespace. No Promise, polyfill and other include-at-head crainess. (Well, according to them - this is their library mode)
@@ -0,0 +1 @@ | |||
../../../api/util/address.js |
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 should probably be removed now?
printf "\n***** Building jsonrpc for NPM ********" | ||
printf "\n***************************************\n\n" | ||
npm run ci:build:jsonrpc | ||
cp LICENSE npm/jsonrpc/LICENSE |
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.
+1
js/.gitignore
Outdated
|
||
npm/*/src | ||
npm/*/dist | ||
npm/jsonrpc/index.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.
Shouldn't the LICENSE files be here now as well since it is copied into tracked paths after the fact?
js/npm/etherscan/README.md
Outdated
```js | ||
require('babel-polyfill'); | ||
require('es6-promise').polyfill(); | ||
require('isomorphic-fetch'); |
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.
Really ridiculously complicated just to get started. Not an option. Been there, done that, got the scars.
(As indicated, we may get away with fetch, we could by indicating that you need to include it for it in a Node environment and what to do for browsers - Edge, FF, Chrome has it, others lag.)
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.
For fetch - could... maybe... use the package.json browser field (all modern bundler support this), and for the node entry include isometric-fetch
for the browser one whatwg-fetch
.
(Together with babel-runtime
it could get us to a "just works" point.)
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.
For fetch - could... maybe... use the package.json browser field (all modern bundler support this), and for the node entry include
isometric-fetch
for the browser onewhatwg-fetch
.
That is what isomorphic-fetch
does.. But people consuming the library want to be able to bundle it themselves. That's why it's in the readme.
@jacogr can we do something with this? |
Closing. Re-open PR when actually being worked on. |
When trying to use
@parity/parity.js
, I noticed a lot of significant shortcomings of our npm-published libraries as well as some minor problems. This PR intends to create a starting point to improve the shape of these libraries.I tried to make the build & publish process more transparent. Instead of copying files using the Webpack copy plugin into a temp directory, I now does a plain
cp -r src/something npm/library-name/src
and then transpiles these files using plain Babel (seenpm run scripts/dryrun-npm.sh
).This means that we publish ES5 source code as individual files instead of a bundle including all dependencies & polyfills. There's a few advantages involved:
@parity/parity.js
, you can now see what's going on in a call to the library, e.g. if you passed invalid parameters and the error messages are not 100% helpfulBecause this PR deprecates the
.npmjs
temp directory, it would make sense if we handlenpm/library-name
as the canonical root directory of our npm-published libraries.package.json
, especially as we'll (probably) remove more polyfills & tooling from the published library (see https://github.com/ethcore/parity/pull/4448#issuecomment-277748842)package.json
, put it into the librarypackage.json
and commit these changes. this makes it transparent which library will be published and gives us a better chance to move to a server-friendly versioning scheme in the future.I also changed the smoke tests inside
npm/library-name/test
to work with the coreassert
module. This has the advantage that the tests can live where the library gets copied to and we don't need to install additional dependencies in a subfolder.Moving on from this PR, I see the following improvements to be made (but this is IMO):
npm/library-name
. this has several advantages:src
.Things still to be done:
~
fromsrc/api
andsrc/abi
. it's only a few occurrences that don't seem to be worth the build setup.scripts/release.sh
andnpm run clean
more. i'm sure i missed thingstest/e2e
. there's alsotest/npm*.js
that seem partially obsolete. – 0465034parity.js
twice (it is impossible right now) – de56706npm/etherscan
depends onapi/util
Tradeoffs made in this PR:
abi/util/address
into3rdparty/etherscan/util
in order to make@parity/etherscan
completely independent from@parity/parity.js
. A more elegant solution would be to dynamically include the required file, but this seems hard to do without a Webpack-like setup. (We dropped the Webpack setup because it lacks transparency and is very complicated).