diff --git a/.babelrc b/.babelrc index 99885738c..c401493c0 100644 --- a/.babelrc +++ b/.babelrc @@ -1,14 +1,30 @@ { - "comments": true, + "comments": false, "presets": [ "@babel/preset-env", "@babel/typescript" ], + "targets": { + "node": 14, + "browsers": [ "> 2%" ] + }, "env": { "development": { - "plugins": [ - "istanbul" - ] + "comments": true, // for debugging + "plugins": [ "istanbul" ] // for code coverage + }, + "docs": { + "comments": true // for jsdocs + }, + "production": { + // stricter target for final browser bundle + "targets": { + "browsers": [ + "> 2%", + "ie 11", + "not op_mini all" + ] + } } } } \ No newline at end of file diff --git a/config/webpack.config.browser.js b/config/webpack.config.browser.js index a4a4be74b..6cd2d3a46 100644 --- a/config/webpack.config.browser.js +++ b/config/webpack.config.browser.js @@ -63,7 +63,7 @@ const config = { // Ignore native modules (sodium-native) new webpack.IgnorePlugin({ resourceRegExp: /sodium-native/ }), new NodePolyfillPlugin({ - includeAliases: ["http", "https"] // others aren't needed + includeAliases: ['http', 'https'] // others aren't needed }), new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] diff --git a/package.json b/package.json index 6aa736455..138962e26 100644 --- a/package.json +++ b/package.json @@ -26,19 +26,21 @@ "scripts": { "build": "cross-env NODE_ENV=development yarn _build", "build:prod": "cross-env NODE_ENV=production yarn _build", - "build:node": "babel --extensions '.ts' --out-dir lib/ src/ && tsc -p ./config/tsconfig.json", + "build:node": "yarn _babel && yarn build:ts", + "build:ts": "tsc -p ./config/tsconfig.json", "build:browser": "webpack --stats-modules-space 999 -c config/webpack.config.browser.js", - "clean": "rm -rf lib/ dist/ coverage/ .nyc_output/", - "docs": "jsdoc -c ./config/.jsdoc.json --verbose", + "build:docs": "cross-env NODE_ENV=docs yarn _babel", + "clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/", + "docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose", "test": "yarn test:node && yarn test:integration && yarn test:browser", "test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'", "test:integration": "yarn _nyc mocha --recursive 'test/integration/**/*.js'", "test:browser": "karma start config/karma.conf.js", - "lint": "eslint -c .eslintrc.js src/", - "fmt": "yarn lint --fix && yarn _prettier", - "preversion": "yarn clean && yarn fmt && yarn lint && yarn build:prod && yarn test", + "fmt": "yarn eslint -c .eslintrc.js src/ --fix && yarn _prettier", + "preversion": "yarn clean && yarn fmt && yarn build:prod && yarn test", "prepare": "yarn build:prod", "_build": "yarn build:node && yarn build:browser", + "_babel": "babel --extensions '.ts' --out-dir lib/ src/", "_nyc": "nyc --nycrc-path config/.nycrc", "_prettier": "prettier --ignore-path config/.prettierignore --write './**/*.js'" },