Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Added babel-cli to distribute ES5 version on npm #114

Merged
merged 3 commits into from Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .babelrc
@@ -0,0 +1,7 @@
{
"presets": [
[
"env"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If publisher will build with latest node this will produce not ES5 output, is not it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you be a bit more specific, who is the "publisher", the one who publishes this on npm? And what "latest" node do you mean, which version? What changed in that version, do you have some link on that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one missed word destroyed my message, I wanted write: If publisher will build with latest node version...

I checked https://www.npmjs.com/package/babel-preset-env

Without any configuration options, babel-preset-env behaves exactly the same as babel-preset-latest (or babel-preset-es2015, babel-preset-es2016, and babel-preset-es2017 together).

Did not knew about this. Sorry for false alarm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I am not totally the transpilation/babel expert, so better to double check than one check to few. Sorry also for being a bit unconsistent in what Node version we actually support. I think we still have to fine-tune this a bit. I also didn't know how many people still need some ES5 compatible distribution and for what reasons.

So I think it probably makes sense for the various libraries to -yes- drop Node 4 support for the source version to be able to implement with newer and more elegant techniques, but also provide a transpiled distribution version with lower requirements.

Probably also has to be decided/evolved on a case-by-case (library-by-library) basis, depending on the needs of the users, the scope of the library and the compromises which have to be done in respect to security, speed and build/library size.

Actually this topic gets more and more complex for me the more I read on it. Will try to keep pace! 😄

]
]
}
68 changes: 67 additions & 1 deletion .gitignore
@@ -1,3 +1,69 @@
### App ###

.cachedb


# Created by https://www.gitignore.io/api/osx,node

### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules
package-lock.json

# Build folder
dist

npm-debug.log
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,5 +1,6 @@
language: node_js
node_js:
- "4"
- "6"
- "8"
env:
Expand Down
18 changes: 13 additions & 5 deletions package.json
Expand Up @@ -2,15 +2,19 @@
"name": "ethereumjs-util",
"version": "5.1.3",
"description": "a collection of utility functions for Ethereum",
"main": "index.js",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"coverage": "istanbul cover _mocha",
"coverage": "npm run build:dist && istanbul cover _mocha",
"coveralls": "npm run coverage && coveralls <coverage/lcov.info",
"lint": "standard",
"prepublish": "npm run lint && npm run test",
"prepublishOnly": "npm run lint && npm run build:dist && npm run test",
"test": "npm run test:node && npm run test:browser",
"test:browser": "karma start karma.conf.js",
"test:node": "istanbul test mocha -- --reporter spec",
"test:browser": "npm run build:dist && karma start karma.conf.js",
"test:node": "npm run build:dist && istanbul test mocha -- --reporter spec",
"build:dist": "babel index.js --source-root ./ -d ./dist",
"build:docs": "documentation build ./index.js --github --sort-order='alpha' -f md > ./docs/index.md"
},
"browserify": {
Expand Down Expand Up @@ -120,6 +124,7 @@
"secp256k1": "^3.0.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babelify": "^8.0.0",
"browserify": "^14.0.0",
Expand All @@ -141,6 +146,9 @@
"globals": [
"describe",
"it"
],
"ignore": [
"dist/**"
]
}
}
2 changes: 1 addition & 1 deletion test/defineFields.js
@@ -1,5 +1,5 @@
var assert = require('assert')
var ethUtil = require('../index.js')
var ethUtil = require('../dist/index.js')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe tests can be part of the babel space too for some may write these in ES6?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, we can think about that, but let's leave this for now.


describe('define', function () {
const fields = [{
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
@@ -1,5 +1,5 @@
var assert = require('assert')
var ethUtils = require('../index.js')
var ethUtils = require('../dist/index.js')
var BN = require('bn.js')

describe('zeros function', function () {
Expand Down