Skip to content

Commit

Permalink
Upgrade package
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy committed Oct 28, 2020
1 parent d62b93c commit bc98874
Show file tree
Hide file tree
Showing 12 changed files with 448 additions and 318 deletions.
10 changes: 4 additions & 6 deletions .gitignore
Expand Up @@ -3,10 +3,8 @@ node_modules/
package-lock.json
yarn.lock
npm-debug.log
browserstack.err
local.log
index.cjs.js
index.esm.js
index.umd.js
index.cjs.js.map
index.esm.js.map
index.umd.js.map
cjs/
esm/
umd/
7 changes: 3 additions & 4 deletions .lintstagedrc
@@ -1,8 +1,7 @@
{
"*.js": ["eslint --fix", "git add"],
"*.md": ["prettier --ignore-path .gitignore --write", "git add"],
"*.js": ["eslint --fix"],
"*.md": ["prettier --ignore-path .gitignore --write"],
".!(npm|browserslist)*rc": [
"prettier --ignore-path .gitignore --parser json --write",
"git add"
"prettier --ignore-path .gitignore --parser json --write"
]
}
3 changes: 2 additions & 1 deletion .prettierrc
Expand Up @@ -15,5 +15,6 @@
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"vueIndentScriptAndStyle": false,
"endOfLine": "lf"
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto"
}
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,3 +1,3 @@
language: node_js
node_js:
- '8'
- '10'
9 changes: 7 additions & 2 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,12 @@

- Avoid having bundles like Webpack load the UMD module
([#42](https://github.com/niksy/throttle-debounce/pull/42))
- Upgrade package

### Removed

- **Breaking**: Drop Node 8 support, package is no longer tested against it,
but it should still work since there are no code changes

## [2.3.0][] - 2020-08-12

Expand All @@ -24,7 +30,6 @@
([#36](https://github.com/niksy/throttle-debounce/pull/36))
- Use ES2015+ features

[unreleased]: https://github.com/niksy/throttle-debounce/compare/v2.2.1...HEAD
[2.2.1]: https://github.com/niksy/throttle-debounce/tree/v2.2.1
[unreleased]: https://github.com/niksy/throttle-debounce/compare/v2.3.0...HEAD
[2.3.0]: https://github.com/niksy/throttle-debounce/tree/v2.3.0
[unreleased]: https://github.com/niksy/throttle-debounce/compare/v2.3.0...HEAD
2 changes: 1 addition & 1 deletion debounce.js
Expand Up @@ -16,7 +16,7 @@ import throttle from './throttle';
*
* @returns {Function} A new, debounced function.
*/
export default function(delay, atBegin, callback) {
export default function (delay, atBegin, callback) {
return callback === undefined
? throttle(delay, atBegin, false)
: throttle(delay, callback, atBegin !== false);
Expand Down
13 changes: 9 additions & 4 deletions karma.conf.js
Expand Up @@ -4,9 +4,14 @@ const path = require('path');

let config;

const local =
typeof process.env.CI === 'undefined' || process.env.CI === 'false';
const port = process.env.SERVICE_PORT;
const isCI =
typeof process.env.CI !== 'undefined' && process.env.CI !== 'false';
const isPR =
typeof process.env.TRAVIS_PULL_REQUEST !== 'undefined' &&
process.env.TRAVIS_PULL_REQUEST !== 'false';
const local = !isCI || (isCI && isPR);

const port = 0;

if (local) {
config = {
Expand Down Expand Up @@ -57,7 +62,7 @@ if (local) {
};
}

module.exports = function(baseConfig) {
module.exports = function (baseConfig) {
baseConfig.set({
basePath: '',
frameworks: ['qunit'],
Expand Down
84 changes: 46 additions & 38 deletions package.json
Expand Up @@ -2,86 +2,94 @@
"name": "throttle-debounce",
"version": "2.3.0",
"description": "Throttle and debounce functions.",
"main": "index.cjs.js",
"module": "index.esm.js",
"unpkg": "index.umd.js",
"jsdelivr": "index.umd.js",
"license": "MIT",
"author": "Ivan Nikolić <niksy5@gmail.com> (http://ivannikolic.com)",
"contributors": [
"Ben Alman (http://benalman.com)"
],
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"import": "./esm/index.js",
"require": "./cjs/index.js"
}
},
"main": "cjs/index.js",
"jsdelivr": "umd/index.js",
"unpkg": "umd/index.js",
"module": "esm/index.js",
"directories": {
"test": "test"
},
"files": [
"index.cjs.{js,js.map}",
"index.esm.{js,js.map}",
"index.umd.{js,js.map}",
"cjs/",
"esm/",
"umd/",
"CHANGELOG.md",
"LICENSE.md",
"README.md"
],
"sideEffects": false,
"directories": {
"test": "test"
},
"scripts": {
"build": "rollup --config rollup.config.js",
"lint": "eslint '{index,debounce,throttle,test/**/*}.js'",
"postpublish": "GITHUB_TOKEN=$GITHUB_RELEASE_TOKEN echo 'github-release-from-changelog'",
"prepublishOnly": "npm run build",
"release": "np",
"module-check": "node -e 'require(\"throttle-debounce\");' && node --input-type=module -e 'import \"throttle-debounce\";'",
"prepublishOnly": "npm run build && npm run module-check",
"postpublish": "GITHUB_TOKEN=$GITHUB_RELEASE_TOKEN github-release-from-changelog",
"release": "np --no-release-draft",
"test": "npm run lint && npm run test:automated",
"test:automated": "BABEL_ENV=test SERVICE_PORT=$(get-port) karma start",
"test:automated": "BABEL_ENV=test karma start",
"test:automated:watch": "npm run test:automated -- --auto-watch --no-single-run",
"version": "version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/runtime": "^7.2.0",
"babel-loader": "^8.0.4",
"@rollup/plugin-babel": "^5.2.1",
"babel-loader": "^8.1.0",
"babel-preset-niksy": "^4.1.0",
"changelog-verify": "^1.1.2",
"core-js": "^2.6.5",
"eslint": "^6.7.2",
"eslint-config-niksy": "^8.0.0",
"eslint-config-prettier": "^4.2.0",
"eslint": "^7.11.0",
"eslint-config-niksy": "^9.0.0",
"eslint-config-prettier": "^6.14.0",
"eslint-plugin-extend": "^0.1.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsdoc": "^18.4.3",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.7.3",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.9.1",
"eslint-plugin-unicorn": "^14.0.1",
"eslint-plugin-unicorn": "^23.0.0",
"esm": "^3.0.51",
"get-port": "^4.0.0",
"get-port-cli": "^2.0.0",
"github-release-from-changelog": "^2.1.1",
"husky": "^3.1.0",
"karma": "^4.0.1",
"karma-browserstack-launcher": "^1.0.0",
"karma-chrome-launcher": "^2.2.0",
"husky": "^4.3.0",
"karma": "^5.2.3",
"karma-browserstack-launcher": "^1.6.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha-reporter": "^2.2.5",
"karma-qunit": "^0.1.9",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.0",
"lint-staged": "^9.5.0",
"karma-webpack": "^4.0.2",
"lint-staged": "^10.4.2",
"minimist": "^1.2.0",
"np": "^3.0.4",
"prettier": "^1.17.0",
"mocha": "^4.1.0",
"np": "^6.5.0",
"prettier": "^2.1.2",
"qunitjs": "^1.23.1",
"rollup": "^1.0.0",
"rollup": "^2.32.1",
"rollup-plugin-babel": "^4.2.0",
"version-changelog": "^3.1.1",
"webpack": "^4.12.0"
"webpack": "^4.44.2"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"keywords": [
"debounce",
Expand Down
40 changes: 36 additions & 4 deletions rollup.config.js
@@ -1,29 +1,61 @@
'use strict';

const babel = require('rollup-plugin-babel');
const path = require('path');
const { promises: fs } = require('fs');
const { default: babel } = require('@rollup/plugin-babel');

module.exports = {
input: 'index.js',
output: [
{
file: 'index.cjs.js',
file: 'cjs/index.js',
format: 'cjs',
sourcemap: true
},
{
file: 'index.esm.js',
file: 'esm/index.js',
format: 'esm',
sourcemap: true
},
{
file: 'index.umd.js',
file: 'umd/index.js',
format: 'umd',
sourcemap: true,
name: 'throttleDebounce'
}
],
plugins: [
(() => {
return {
name: 'package-type',
async writeBundle(output) {
let prefix, type;
if (output.file.includes('cjs/')) {
prefix = 'cjs';
type = 'commonjs';
} else if (output.file.includes('esm/')) {
prefix = 'esm';
type = 'module';
} else if (output.file.includes('umd/')) {
prefix = 'umd';
type = 'commonjs';
}
if (typeof prefix !== 'undefined') {
const package_ = path.join(prefix, 'package.json');
try {
await fs.unlink(package_);
} catch (error) {}
await fs.writeFile(
package_,
JSON.stringify({ type }),
'utf8'
);
}
}
};
})(),
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**'
})
]
Expand Down
5 changes: 2 additions & 3 deletions test/.eslintrc
@@ -1,5 +1,4 @@
{
"extends": [
"niksy/tests"
]
"extends": ["niksy/tests"],
"ignorePatterns": ["/**/fixtures"]
}

0 comments on commit bc98874

Please sign in to comment.