Skip to content

Commit

Permalink
feat(package): Use microbundle to create cjs and mjs builds and conve…
Browse files Browse the repository at this point in the history
…rt package to module

Signed-off-by: Tilman Vatteroth <[email protected]>
  • Loading branch information
mrdrogdrog committed Oct 23, 2022
1 parent 82c5b19 commit df4b698
Show file tree
Hide file tree
Showing 9 changed files with 3,672 additions and 348 deletions.
37 changes: 22 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,33 @@
* SPDX-License-Identifier: CC0-1.0
*/
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig-eslint.json"]
"parser" : "@typescript-eslint/parser",
"parserOptions" : {
"project" : [
"./tsconfig.json"
]
},
"plugins": ["@typescript-eslint", "jest"],
"env": {
"jest": true,
"jest/globals": true
"plugins" : [
"@typescript-eslint",
"jest",
"prettier"
],
"env" : {
"jest" : true,
"jest/globals" : true
},
"extends": [
"extends" : [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error"
"rules" : {
"jest/no-disabled-tests" : "warn",
"jest/no-focused-tests" : "error",
"jest/no-identical-title" : "error",
"jest/prefer-to-have-length" : "warn",
"jest/valid-expect" : "error"
}
}
23 changes: 12 additions & 11 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"preset": "ts-jest",
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testEnvironment": "node",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$",
"testPathIgnorePatterns": [
"/dist/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js"
"extensionsToTreatAsEsm" : [
".ts"
],
"globals": {
"ts-jest": {
"tsconfig": "tsconfig-cjs.json"
}
"moduleNameMapper" : {
"^(\\.{1,2}/.*)\\.js$" : "$1"
},
"transform" : {
"^.+\\.tsx?$" : [
"ts-jest",
{
"useESM" : true
}
]
}
}
45 changes: 24 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
{
"name": "@mrdrogdrog/optional",
"version": "0.2.0",
"version": "1.0.0",
"description": "Provides a java-like optional class",
"author": "Tilman Vatteroth <[email protected]>",
"license": "MIT",
"scripts": {
"build": "tsc-esm && tsc -p tsconfig-cjs.json && find dist/cjs -type d -execdir sh -c 'cd {}; mmv -rd \"*.js*\" \"#1#2\"' \\;",
"build": "microbundle",
"test": "jest",
"prepublish": "rm -rf dist && yarn format && yarn lint && yarn build && yarn test",
"prepublish": "rm -rf dist && yarn lint && yarn build && yarn test",
"lint": "eslint src --ext .ts",
"format": "prettier -c \"src/**/*.{ts,tsx,js}\"",
"format:fix": "prettier -w \"src/**/*.{ts,tsx,js}\"",
"lint:fix": "eslint --fix --ext .ts src",
"docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts"
},
"type": "module",
"main": "dist/cjs/index",
"module": "dist/mjs/index.js",
"types": "dist/cjs/index.d.ts",
"source": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "./dist/index.esm.js",
"unpkg": "./dist/index.umd.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index"
}
},
"typesVersions": {
"*": {
"index.d.ts": [
"dist/mjs/index.d.ts"
]
}
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"files": [
"LICENSES/*",
"package.json",
"README.md",
"dist/**"
"dist/index.d.ts",
"dist/index.test.d.ts",
"dist/index.cjs.map",
"dist/index.cjs",
"dist/index.mjs.map",
"dist/index.mjs",
"dist/index.esm.js.map",
"dist/index.esm.js",
"dist/index.umd.js.map",
"dist/index.umd.js"
],
"repository": {
"type": "git",
"url": "https://github.com/mrdrogdrog/optional.git"
},
"devDependencies": {
"@digitak/tsc-esm": "3.1.4",
"@jest/types": "29.2.1",
"@typescript-eslint/eslint-plugin": "5.40.1",
"@typescript-eslint/parser": "5.40.1",
"eslint": "8.26.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "27.1.3",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.2.1",
"microbundle": "0.15.1",
"prettier": "2.7.1",
"ts-jest": "29.0.3",
"typescript": "4.8.4"
Expand Down
8 changes: 0 additions & 8 deletions tsconfig-cjs.json

This file was deleted.

3 changes: 0 additions & 3 deletions tsconfig-cjs.json.license

This file was deleted.

4 changes: 0 additions & 4 deletions tsconfig-eslint.json

This file was deleted.

3 changes: 0 additions & 3 deletions tsconfig-eslint.json.license

This file was deleted.

6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"outDir": "dist/mjs",
"rootDir": "./src",
"allowJs": true,
"sourceMap": true
},
"include": ["./src"],
"exclude": ["./dist", "**/*.test.*", "**/__mocks__/*", "**/__tests__/*"]
"include": ["src"],
"exclude": ["dist"]
}
Loading

0 comments on commit df4b698

Please sign in to comment.