-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Building Webpack 5 support is here! - the node package is built using Babel via `yarn build:node` - the browser bundle is built using Webpack via `yarn build:browser` * this is configured in `cfg/webpack.config.browser.js` * its accessible after including the script via the `StellarBase` variable * it adds a handful of important polyfills * it does linting via ESLint # Linting ESLint, Prettier, and DTSLint are all updated: - ESLint works with Babel via the `@babel/eslint-parser` in each `.eslintrc.js` file and is implicitly part of building via Webpack (see above) - DTSLint is part of the `@definitelytyped` project and has additional configuration implicitly as part of the `types/.eslintrc.js` file which uses `@typescript-eslint/parser`, instead - Prettier is configured in `cfg/prettier.config.js` (and `cfg/.prettierignore`) and runs on all files now. It's also (still) a pre-commit hook. Just run `yarn pretty && yarn lint` to format your files and check that everything is up to par. # Testing **Istanbul**: Istanbul is [unmaintained](https://www.npmjs.com/package/istanbul) and superceded by the `nyc` package. - the `istanbul` plugin in `.babelrc` tells Babel about it - `cfg/.nycrc` extends a Babel-compatible configuration file ([docs](https://github.com/istanbuljs/nyc#babel-projects)) - the `nyc` key in `package.json` configures instrumentation behavior - the coverage is *actually* provided by `babel-plugin-istanbul` ([docs](https://github.com/istanbuljs/babel-plugin-istanbul)), which is why `"instrument": false` in the above **Node Testing**: Mocha (and its helper friends Sinon and Chai) has been updated. - the `mocha` key in `package.json` configures Mocha (replacing `mocha.opts`) - this does Babel transpiling and hooks in the helper script - code coverage is provided by `nyc` (see above) **Browser Testing**: Karma has been updated. - the SauceLabs Karma configuration has been removed entirely because it wasn't being used - Karma has been updated with a code coverage integration with `nyc` ([docs](https://github.com/istanbuljs/babel-plugin-istanbul#karma), see above) - It relies on the Webpack configuration but makes some minor changes Run `yarn test` to run both suites. # Scripts Development has a slightly different workflow now: - build+test locally with `yarn test:node` - this will only run node tests (which are faster/simpler) - you can `yarn build && yarn test:all` to get the both test suites (note that building first is *required*) - run `yarn preversion` when you want a thorough, clean test of the whole system in "production" mode
- Loading branch information
Showing
67 changed files
with
5,379 additions
and
7,772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
"targets": { | ||
"ie": "11" | ||
"@babel/preset-env" | ||
], | ||
"env": { | ||
"development": { | ||
"plugins": [ | ||
"istanbul" | ||
] | ||
} | ||
}] | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
.nvmrc | ||
.nyc_output/ | ||
/node_modules/ | ||
/tmp/ | ||
/lib/ | ||
/dist/ | ||
/config/dist/ | ||
/coverage/ | ||
/jsdoc/ | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@istanbuljs/nyc-config-babel" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
../package.json | ||
../node_modules | ||
../lib | ||
../dist | ||
../src/generated | ||
../src/vendor | ||
../docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const webpackConfig = require('./webpack.config.browser.js'); | ||
|
||
delete webpackConfig.output; | ||
webpackConfig.entry = {}; // karma fills these in | ||
webpackConfig.plugins.shift(); // drop eslinter plugin | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
frameworks: ['mocha', 'sinon-chai'], | ||
browsers: ['FirefoxHeadless', 'ChromeHeadless'], | ||
|
||
files: [ | ||
'../dist/stellar-base.js', // webpack should build this first | ||
'../test/unit/**/*.js' | ||
], | ||
|
||
preprocessors: { | ||
'../test/unit/**/*.js': ['webpack'] | ||
}, | ||
|
||
webpack: webpackConfig, | ||
webpackMiddleware: { | ||
noInfo: true | ||
}, | ||
|
||
colors: true, | ||
singleRun: true, | ||
|
||
reporters: ['dots', 'coverage'], | ||
coverageReporter: { | ||
type: 'text-summary', | ||
instrumenterOptions: { | ||
istanbul: { noCompact: true } | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
module.exports = { | ||
arrowParens: 'always', | ||
bracketSpacing: true, | ||
jsxBracketSameLine: false, | ||
bracketSameLine: false, | ||
printWidth: 80, | ||
proseWrap: 'always', | ||
semi: true, | ||
singleQuote: true, | ||
tabWidth: 2, | ||
parser: 'babel', | ||
trailingComma: 'none', | ||
useTabs: false | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
var ESLintPlugin = require('eslint-webpack-plugin'); | ||
var TerserPlugin = require('terser-webpack-plugin'); | ||
var NodePolyfillPlugin = require('node-polyfill-webpack-plugin'); | ||
|
||
const config = { | ||
target: 'web', | ||
// https://stackoverflow.com/a/34018909 | ||
entry: { | ||
'stellar-base': path.resolve(__dirname, '../src/index.js'), | ||
'stellar-base.min': path.resolve(__dirname, '../src/index.js') | ||
}, | ||
resolve: { | ||
fallback: { | ||
crypto: require.resolve('crypto-browserify'), | ||
stream: require.resolve('stream-browserify'), | ||
buffer: require.resolve('buffer') | ||
}, | ||
extensions: ['.ts', '.js'] | ||
}, | ||
output: { | ||
clean: true, | ||
library: 'StellarBase', | ||
compareBeforeEmit: true, | ||
path: path.resolve(__dirname, '../dist') | ||
}, | ||
mode: process.env.NODE_ENV ?? 'development', | ||
devtool: process.env.NODE_ENV === 'production' ? false : 'inline-source-map', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.m?js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
cacheDirectory: true | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
optimization: { | ||
minimize: true, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
include: /\.min\.js$/, | ||
terserOptions: { | ||
format: { | ||
ascii_only: true | ||
} | ||
} | ||
}) | ||
] | ||
}, | ||
plugins: [ | ||
// this must be first for karma to work (see line 5 of karma.conf.js) | ||
new ESLintPlugin({ | ||
overrideConfigFile: path.resolve(__dirname, './.eslintrc.js') | ||
}), | ||
// Ignore native modules (sodium-native) | ||
new webpack.IgnorePlugin({ resourceRegExp: /sodium-native/ }), | ||
new NodePolyfillPlugin(), | ||
new webpack.ProvidePlugin({ | ||
Buffer: ['buffer', 'Buffer'] | ||
}) | ||
], | ||
watchOptions: { | ||
ignored: /(node_modules|coverage|lib|dist)/ | ||
} | ||
}; | ||
|
||
module.exports = config; |
Oops, something went wrong.