diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index bfb4fda..098bbdd 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -4,7 +4,7 @@ on: workflow_call: push: pull_request: - branches: ["main"] + branches: ["master"] jobs: commitlint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31d7d7c..cf8815c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: release on: push: - branches: ["main"] + branches: ["master"] tags-ignore: ['**'] jobs: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8ba3381..60b63e9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: tests on: workflow_call: pull_request: - branches: ["main"] + branches: ["master"] jobs: test: diff --git a/_jest.config.no b/_jest.config.no deleted file mode 100644 index 7b32442..0000000 --- a/_jest.config.no +++ /dev/null @@ -1,32 +0,0 @@ -// jest.config.ts -import { createDefaultPreset, JestConfigWithTsJest } from 'ts-jest' - -const jestConfig: JestConfigWithTsJest = { - // [...] - ...createDefaultPreset(), -} -// const toNotIgnore = { -// modules: [].join('|'), -// }; - -// const toExport = { -// roots: [''], -// // moduleFileExtensions: ['js', 'css', 'ts'], -// transformIgnorePatterns: ['node_modules', '//lib', '//(?!src)'], -// verbose: true, -// collectCoverageFrom: [ -// 'src/**/*.{ts,js}', -// '!/node_modules/', -// '!/lib/', -// '!/umd/', -// '!/config/', -// '!/test/', -// ], -// testRegex: '(/test/.*(test|spec))\\.[jt]sx?$', -// }; - -// if (toNotIgnore.modules.length) { -// toExport.transformIgnorePatterns.push(`/node_modules/(?!(${toNotIgnore.modules}))`); -// } - -// module.exports = toExport; diff --git a/jest.config.js b/jest.config.js index 5fd4a4e..6c01718 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,16 @@ -/** @type {import('ts-jest').JestConfigWithTsJest} * */ -module.exports = { - testEnvironment: 'node', - transform: { - '^.+.tsx?$': ['ts-jest', {}], - }, - testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'], +const toNotIgnore = { + modules: [].join('|'), }; + +const toExport = { + roots: [''], + transformIgnorePatterns: ['node_modules', '//lib', '//(?!src)'], + verbose: true, + testRegex: '(/test/.*(test|spec))\\.[jt]sx?$', +}; + +if (toNotIgnore.modules.length) { + toExport.transformIgnorePatterns.push(`/node_modules/(?!(${toNotIgnore.modules}))`); +} + +module.exports = toExport; diff --git a/package.json b/package.json index e06316f..eb02dfa 100644 --- a/package.json +++ b/package.json @@ -22,16 +22,15 @@ "umd" ], "scripts": { - "build": "npx tsc", + "build": "rollup -c ./rollup.config.js", "coveralls": "cat ./coverage/lcov.info | coveralls", "docs:api:markdown": "npx typedoc --theme markdown --exclude ./src/test --out ./docs/api ./src", "docs:api:website": "npx typedoc --exclude ./src/test --out docs ./src", - "jest": "npx ts-jest", + "jest": "npx jest", "lint": "eslint --ext .js,.ts,.tsx *.js src test --color", "mocha": "mocha", "prepare": "npx sort-package-json", - "roll:it": "rollup -c ./rollup.config.ts", - "test": "npm run lint && npm run jest", + "test": "npm run build && npm run jest", "test:ci": "npm run build && npm run test --coverage && npm run coveralls", "preversion": "npm run build" }, @@ -43,26 +42,22 @@ "@biiaidt/node-memwatch": "2.0.1", "@commitlint/cli": "^19", "@commitlint/config-conventional": "^19", + "@rollup/plugin-commonjs": "^26.0.1", + "@rollup/plugin-typescript": "^11.1.6", "@types/debug": "^4", "@types/jest": "^29.5.13", "@znemz/js-common-eslint-config": "^0.2.2", + "@znemz/react-extras-jest": "1.5.1", + "JSONStream": "1.X", "commitlint": "19", "config": "^3.2.2", "coveralls": "^3.0.4", "del": "^4.1.1", - "esm": "^3.2.22", - "gulp": "^4.0.2", - "gulp-run": "^1.7.1", - "gulp-typescript": "^5.0.1", "hook-std": "0.X", "jest": "^29.7.0", - "jest-extended": "^0.11.5", - "JSONStream": "1.X", "prettier": "^1.18.2", + "rollup": "4.21.3", "sort-package-json": "^2.10.1", - "ts-jest": "^29.2.5", - "typedoc": "0.26.7", - "typedoc-plugin-markdown": "^4.2.7", "typescript": "^4.2.4" }, "engines": { diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..aa8b1c0 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,28 @@ +const typescript = require('@rollup/plugin-typescript'); +const commonjs = require('@rollup/plugin-commonjs'); + +const pkg = require('./package.json'); + +module.exports = { + external: ['memoizee'], + input: 'src/index.ts', + output: [ + { + file: pkg.umd, + format: 'umd', + name: 'DebugFabulous', + globals: { + memoizee: 'memoizee', + }, + }, + { + file: pkg.main, + format: 'commonjs', + name: 'DebugFabulous', + globals: { + memoizee: 'memoizee', + }, + }, + ], + plugins: [commonjs(), typescript()], +}; diff --git a/test/helpers/watchLeaks.js b/test/helpers/watchLeaks.js index 7891b0d..b5ed424 100644 --- a/test/helpers/watchLeaks.js +++ b/test/helpers/watchLeaks.js @@ -12,4 +12,4 @@ const watchLeaks = () => { return new memwatch.HeapDiff(); }; -export default watchLeaks; +module.exports = watchLeaks; diff --git a/test/index.test.js b/test/index.test.js index 04bf995..0a83db2 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1,6 +1,6 @@ -import hook from 'hook-std'; -import config from 'config'; -import watchLeaks from './helpers/watchLeaks'; +const hook = require('hook-std'); +const config = require('config'); +const watchLeaks = require('./helpers/watchLeaks'); /* eslint-disable no-console */ const heapDiff = watchLeaks(); @@ -33,11 +33,11 @@ describe('index / spawn', () => { describe('namespacing', () => { beforeEach(() => { - const origDebug = require('../src')(); + const origDebug = require('../lib')(); origDebug.save('root*'); origDebug.enable(origDebug.load()); - rootDbg = require('../src').spawnable('root', origDebug); + rootDbg = require('../lib').spawnable('root', origDebug); // console.log(rootDbg); }); diff --git a/test/lazyEval.test.js b/test/lazyEval.test.js index 00ddd43..1a28dad 100644 --- a/test/lazyEval.test.js +++ b/test/lazyEval.test.js @@ -1,8 +1,8 @@ -import hook from 'hook-std'; -import config from 'config'; -import watchLeaks from './helpers/watchLeaks'; +const hook = require('hook-std'); +const config = require('config'); +const watchLeaks = require('./helpers/watchLeaks'); -const debugFact = require('../src/debugFabFactory')(); +const debugFact = require('../lib')(); /* eslint-disable no-console */ const heapDiff = watchLeaks(); @@ -131,7 +131,7 @@ describe('lazyEval', () => { return 'crap'; }); unhook(); - expect(called).toBeFalse(); + expect(called).toEqual(false); }); it('normal', () => { @@ -143,7 +143,7 @@ describe('lazyEval', () => { debug('crap'); unhook(); - expect(called).toBeFalse(); + expect(called).toEqual(false); }); }); }); diff --git a/test/spawn.test.js b/test/spawn.test.js index 168abfd..fd3785f 100644 --- a/test/spawn.test.js +++ b/test/spawn.test.js @@ -1,4 +1,4 @@ -import debugFabAPI from '../src'; +const debugFabAPI = require('../lib'); const origDebug = debugFabAPI(); origDebug.save('root*'); diff --git a/tsconfig.json b/tsconfig.json index 8d210a8..bf4dfb6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,13 +5,14 @@ "noLib": false, "emitDecoratorMetadata": true, "noImplicitAny": false, - "module": "commonjs", + "module": "ESNext", "target": "ES2020", "experimentalDecorators": true, - "sourceMap": false, "declaration": true, "noResolve": false, "moduleResolution": "node", - "outDir": ".tmp" - } + "outDir": ".tmp", + "allowJs": true, + }, + "exclude": ["node_modules", ".tmp", "jest.config.js"] }