Skip to content

Commit

Permalink
feat: add development build and package version to dist (#2)
Browse files Browse the repository at this point in the history
* delete tmp directory

* add documentation

* fix init function

* change API and update showcase

* add donation address

* feat: add documentation

* add development build and package version to dist
  • Loading branch information
marvinroger authored Feb 26, 2018
1 parent ad1332f commit c58ffb6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ branches:
install:
- yarn
script:
- yarn build
- yarn build:prod
- yarn test
after_success:
- yarn travis-deploy-once "yarn semantic-release"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The documentation is available in the [DOCUMENTATION.md](DOCUMENTATION.md) file.

Contributions are very welcome. To develop, make use of the following commands (using [Yarn](https://yarnpkg.com)):

* `yarn build`: build the C++ code to WebAssembly and bundle the production files into the `dist` directory
* `yarn build:dev`: build the C++ code to WebAssembly and bundle the files into the `dist` directory, without optimization so that it is fast while developing

* `yarn test`: test the code

Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@
"url": "https://github.com/marvinroger/nanocurrency-js.git"
},
"scripts": {
"build": "yarn build:native && yarn build:js",
"build:js": "rollup -c",
"build:native": "cross-os build:native__cross",
"build:native__common": "cross-var docker run --rm -v $PWD:/src trzeci/emscripten emcc -o native.tmp.js -O3 --closure 1 --llvm-lto 3 -s WASM=1 -s MODULARIZE=1 -s SINGLE_FILE=1 -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[\\\"cwrap\\\"]\" src/native/functions.cpp src/native/uint128_t/uint128_t.cpp src/native/blake2/ref/blake2b-ref.c src/native/ed25519/src/ge.c src/native/ed25519/src/fe.c src/native/ed25519/src/sc.c src/native/ed25519/src/keypair.c src/native/ed25519/src/sign.c src/native/ed25519/src/verify.c",
"build:dev": "yarn build:dev:native && yarn build:dev:js",
"build:dev:js": "cross-env NODE_ENV=development rollup -c",
"build:dev:native": "cross-env EMCC_ARGS=\"\" cross-os build:native__cross",
"build:native__common": "cross-var docker run --rm -v $PWD:/src trzeci/emscripten emcc -o native.tmp.js $EMCC_ARGS -s WASM=1 -s MODULARIZE=1 -s SINGLE_FILE=1 -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[\\\"cwrap\\\"]\" src/native/functions.cpp src/native/uint128_t/uint128_t.cpp src/native/blake2/ref/blake2b-ref.c src/native/ed25519/src/ge.c src/native/ed25519/src/fe.c src/native/ed25519/src/sc.c src/native/ed25519/src/keypair.c src/native/ed25519/src/sign.c src/native/ed25519/src/verify.c",
"build:native__cross": {
"darwin": "cross-env PWD=\"$(pwd)\" yarn build:native__common",
"linux": "cross-env PWD=\"$(pwd)\" yarn build:native__common",
"win32": "cross-env PWD=\"%cd%\" yarn build:native__common"
},
"build:prod": "yarn build:prod:native && yarn build:prod:js",
"build:prod:js": "cross-env NODE_ENV=production rollup -c",
"build:prod:native": "cross-env EMCC_ARGS=\"-O3 --closure 1 --llvm-lto 3\" cross-os build:native__cross",
"generate-docs": "jsdoc2md src/**/*.js > DOCUMENTATION.md",
"lint": "standard",
"prepublishOnly": "yarn build:prod:js",
"semantic-release": "semantic-release",
"test": "jest",
"travis-deploy-once": "travis-deploy-once"
Expand Down
21 changes: 14 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import uglify from 'rollup-plugin-uglify'
import license from 'rollup-plugin-license'
import pkg from './package.json'

const ENV = process.env.NODE_ENV

const licenseBanner = `
/*!
* nanocurrency-js: A toolkit for the Nano cryptocurrency.
* nanocurrency-js v${pkg.version}: A toolkit for the Nano cryptocurrency.
* Copyright (c) <%= moment().format('YYYY') %> Marvin ROGER <dev at marvinroger dot fr>
* Licensed under GPL-3.0 (https://git.io/vAZsK)
*/
`.trim()

const globals = { fs: 'fs', path: 'path' }

export default [
const config = [
{
input: 'src/index.js',
external: ['fs', 'path'],
Expand All @@ -25,11 +27,16 @@ export default [
],
plugins: [
resolve(),
commonjs(),
uglify(),
license({
banner: licenseBanner
})
commonjs()
]
}
]

if (ENV === 'production') {
config[0].plugins.push(uglify())
config[0].plugins.push(license({
banner: licenseBanner
}))
}

export default config

0 comments on commit c58ffb6

Please sign in to comment.