Skip to content

Commit 1842850

Browse files
committed
refactor: switch from TSDX to my ts-library-base boilerplate
- I've been away from OSS for a while due to abuse and toxicity and no one's maintained TSDX in my time away, so lots of things are dated now - and TSDX was a large source of the above as well - and this library doesn't need everything TSDX provides -- most don't - use my boilerplate from https://github.com/agilgur5/ts-library-base - babel.config.js is basically a duplicate plus preset-react - tsconfig.json is dupe plus more excludes - tsconfig.build.json is dupe plus typings dir (and tsx ext for index) - jest.config.ts is dupe plus jsdom, enzyme, window-resizeto - rollup.config.ts is dupe minus CJS build and with some custom naming - similar for package.json#main,module,source,exports - fix: previously #main was changed to CJS, which could be considered breaking since it's currently UMD -- back to UMD now - package.json#scripts is a dupe plus lint and start - deps: add rollup, rollup-plugin-typescript2 for the config - deps: add @rollup/plugin-node-resolve, @rollup/plugin-commonjs, @rollup/plugin-babel, and rollup-plugin-terser for the build - and package-json-type and @babel/preset-typescript for typings - and @babel/runtime and @babel/plugin-transform-runtime for reusing Babel's runtime helpers instead of duplicating them - deps: add jest, jest-config, @jest/globals, @jest/types, ts-node for testing - RIP my jest-without-globals library - deps: add concurrently for parallel script execution - deps: add @tsconfig/strictest to extend tsconfig from - deps: add TS ofc - ci: add type-checking to before script check - typings: improve typings with newer TS and stricter tsconfig - required `override` and required `import type` - fix(typings): move @types/react and @types/prop-types to deps - these are imported by the `.d.ts` declaration and even the DT lib: https://www.npmjs.com/package/@types/react-signature-canvas - also upgrade @types/react to v17 to match React v17 - (this is partially due to a merge conflict) - deps: upgrade @babel/core and @babel/preset-react to latest minor - and add @babel/preset-env as a direct devDep too - should upgrade compat-table etc and might as well do so to match minors of other babel deps and while changing so many deps anyway - deps: switch from eslint-config-standard-with-typescript to ts-standard - I didn't know this was a thing! standard-with-typescript was a relatively recent development in and of itself - should have used this from the beginning! - replaced all eslint deps with this one dep now - ignore the example dir for now as it errors (parsing?) and a line in the babel config as well (possibly due to old ESLint) - deps: fix position of @wojtekmaj/enzyme-adapter-react-17 in the package.json - it was higher up, which is alphabetically incorrect - (this is partially due to a merge conflict)
1 parent 7ab4ca6 commit 1842850

15 files changed

+30094
-20375
lines changed

.babelrc.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ language: node_js
22
# default is the very old 0.10.48; match local version instead
33
node_js: '10.16.0'
44

5-
before_script: npm run lint
5+
before_script:
6+
- npm run lint
7+
- npm run tsc
68
script: npm test -- --coverage
79
after_script:
810
# upload coverage reports to CodeCov

babel.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/** @type {import('@babel/core').ConfigFunction} */
2+
module.exports = api => {
3+
// eslint-disable-next-line dot-notation -- this conflicts with tsc, possibly due to outdated ESLint
4+
api.cache.using(() => process.env['NODE_ENV']) // cache based on NODE_ENV
5+
6+
// normally use browserslistrc, but for Jest, use current version of Node
7+
const isTest = api.env('test')
8+
const jestTargets = { targets: { node: 'current' } }
9+
/** @type {[import('@babel/core').PluginTarget, import('@babel/core').PluginOptions]} */
10+
const presetEnv = ['@babel/preset-env', { bugfixes: true }]
11+
if (isTest) presetEnv[1] = { ...presetEnv[1], ...jestTargets }
12+
13+
return {
14+
presets: [
15+
presetEnv,
16+
'@babel/preset-typescript',
17+
'@babel/preset-react'
18+
],
19+
plugins: [
20+
// used with @rollup/plugin-babel
21+
'@babel/plugin-transform-runtime'
22+
]
23+
}
24+
}

jest.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

jest.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Config } from '@jest/types'
2+
import { defaults } from 'jest-config'
3+
4+
const config: Config.InitialOptions = {
5+
injectGlobals: false, // use @jest/globals
6+
testEnvironment: 'jsdom',
7+
setupFilesAfterEnv: [
8+
// configure enzyme w/ react adapter
9+
'<rootDir>/test/config/configure-enzyme.js',
10+
// polyfill window.resizeTo
11+
'window-resizeto/polyfill'
12+
],
13+
coveragePathIgnorePatterns: [
14+
...defaults.coveragePathIgnorePatterns,
15+
'<rootDir>/test/' // ignore any test helper files
16+
]
17+
}
18+
19+
export default config

0 commit comments

Comments
 (0)