Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tsdx to Rollup (Close #22) #26

Merged
merged 3 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
node_modules
.cache
dist
dist_
.idea
package-lock.json
.parcel-cache
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
transform: {
'^.+\\.ts$': 'ts-jest'
},
testEnvironment: "jsdom",
testRegex: '/(src|test)/.*\\.test\\.ts$',
moduleFileExtensions: ['ts', 'js', 'json', 'node']
};
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
{
"version": "0.8.5",
"version": "0.8.6",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"engines": {
"node": ">=10"
},
"repository": "https://github.com/kubk/mobx-log",
"types": "dist/mobx-log.d.ts",
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test --passWithNoTests",
"test:update-snapshot": "tsdx test --updateSnapshot",
"test:cache": "tsdx test --clearCache",
"build": "rollup -c",
"test": "jest test --passWithNoTests",
"test:update-snapshot": "jest test --updateSnapshot",
"test:cache": "jest test --clearCache",
"lint": "tsdx lint",
"prepare": "tsdx build"
"prepare": "npm run build"
},
"peerDependencies": {
"react": ">=16"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"prettier": {
"singleQuote": true
},
Expand All @@ -35,7 +30,7 @@
"module": "dist/mobx-log.esm.js",
"size-limit": [
{
"path": "dist/mobx-log.cjs.production.min.js",
"path": "dist/index.js",
"limit": "10 KB"
},
{
Expand All @@ -44,17 +39,24 @@
}
],
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.1",
"@rollup/plugin-typescript": "^8.3.0",
"@size-limit/preset-small-lib": "^5.0.3",
"@types/jest": "^27.0.3",
"@types/react": "^17.0.21",
"@types/react-dom": "^17.0.9",
"husky": "^7.0.2",
"jest": "^27.4.5",
"mobx": "^6.3.5",
"mobx-react-lite": "^3.2.1",
"prettier": "^2.4.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rollup": "^2.61.1",
"rollup-plugin-dts": "^4.0.1",
"size-limit": "^5.0.3",
"tsdx": "^0.14.1",
"ts-jest": "^27.1.2",
"tslib": "^2.3.1",
"typescript": "^4.4.3"
},
Expand Down
35 changes: 35 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';

const packageJson = require('./package.json');

export default [
{
input: 'src/index.ts',
external: ['mobx', 'mobx-react-lite', 'react'],
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [
resolve(),
commonjs(),
typescript({ tsconfig: './tsconfig.json' }),
],
},
{
input: './dist/types/index.d.ts',
output: [{ file: packageJson.types, format: 'es' }],
plugins: [dts()],
},
];
18 changes: 4 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"include": ["src", "types"],
"compilerOptions": {
"module": "esnext",
"lib": ["dom", "esnext"],
"importHelpers": true,
// output .d.ts declaration files for consumers
"outDir": "dist",
"declarationDir": "types",
"declaration": true,
// output .js.map sourcemap files for consumers
"emitDeclarationOnly": true,
"sourceMap": true,
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// stricter type-checking for stronger correctness. Recommended by TS
"strict": true,
// linter checks for common issues
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
// use Node's module resolution algorithm, instead of the legacy TS one
"moduleResolution": "node",
// transpile JSX to React.createElement
"jsx": "react",
// interop between ESM and CJS modules. Recommended by TS
"esModuleInterop": true,
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
"skipLibCheck": true,
// error out if import and file system have a casing mismatch. Recommended by TS
"forceConsistentCasingInFileNames": true,
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}