Skip to content

Commit 822a509

Browse files
committed
Add building type definitions
1 parent d3a35be commit 822a509

16 files changed

+855
-101
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
!.*
22
node_modules/**
33
dist/**
4+
build/**
45

56
**/.yarn
67
**/.pnp.*

.eslintrc.cjs

+6-24
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ module.exports = {
4141
ignoreProperties: true,
4242
},
4343
],
44-
"@typescript-eslint/no-unused-vars": [
45-
"error",
46-
{ argsIgnorePattern: "^_" },
47-
],
44+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
4845
"@typescript-eslint/prefer-includes": "warn",
4946
"@typescript-eslint/prefer-literal-enum-member": [
5047
"error",
@@ -87,7 +84,7 @@ module.exports = {
8784
},
8885
},
8986
{
90-
files: [".eslintrc.cjs", "rollup.config.ts"],
87+
files: ["scripts/**", "build-plugins/**", ".eslintrc.cjs", "rollup.config.ts"],
9188
env: {
9289
node: true,
9390
},
@@ -110,6 +107,7 @@ module.exports = {
110107
{
111108
devDependencies: [
112109
"**/__tests__/**",
110+
"build-plugins/**",
113111
"scripts/**",
114112
".eslintrc.cjs",
115113
"rollup.config.ts",
@@ -123,16 +121,7 @@ module.exports = {
123121
alphabetize: {
124122
order: "asc",
125123
},
126-
groups: [
127-
"builtin",
128-
"external",
129-
"internal",
130-
"parent",
131-
"sibling",
132-
"index",
133-
"object",
134-
"type",
135-
],
124+
groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
136125
"newlines-between": "always",
137126
},
138127
],
@@ -143,10 +132,7 @@ module.exports = {
143132

144133
"no-array-constructor": "error",
145134
"no-caller": "error",
146-
"no-console": [
147-
"warn",
148-
{ allow: ["warn", "error", "time", "timeEnd", "timeStamp"] },
149-
],
135+
"no-console": ["warn", { allow: ["warn", "error", "time", "timeEnd", "timeStamp"] }],
150136
"no-eval": "error",
151137
"no-extend-native": "warn",
152138
"no-extra-bind": "warn",
@@ -183,11 +169,7 @@ module.exports = {
183169
"prefer-rest-params": "warn",
184170
"prefer-spread": "warn",
185171
"prefer-template": "error",
186-
quotes: [
187-
"error",
188-
"double",
189-
{ allowTemplateLiterals: false, avoidEscape: false },
190-
],
172+
quotes: ["error", "double", { allowTemplateLiterals: false, avoidEscape: false }],
191173
radix: "warn",
192174
"sort-imports": ["error", { ignoreDeclarationSort: true }],
193175
},

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto eol=lf
2+
api-extractor.json linguist-language=JSON-with-Comments

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Dependencies/Build.
99
/node_modules/
1010
/dist/
11+
/build/
1112

1213
# Logs.
1314
npm-debug.log*

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Dependencies/Build.
99
/node_modules/
1010
/dist/
11+
/build/
1112

1213
# Yarn.
1314
**/.yarn

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"trailingComma": "all",
44
"singleQuote": false,
55
"semi": true,
6-
"endOfLine": "lf"
6+
"endOfLine": "lf",
7+
"printWidth": 100
78
}

build-plugins/emit-module-package-json.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Plugin } from "rollup";
22

3-
export default function emitModulePackageJson(
4-
type: "commonjs" | "module",
5-
): Plugin {
3+
export default function emitModulePackageJson(type: "commonjs" | "module"): Plugin {
64
return {
75
name: "emit-module-package-json",
86
generateBundle() {

jest.config.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* @type {import("jest").Config}
3+
*/
4+
export default {};

package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
"type": "git",
1414
"url": "https://github.com/Juici/bigmath.git"
1515
},
16-
"types": "src/index.ts",
16+
"types": "dist/index.d.ts",
1717
"main": "dist/cjs/index.js",
1818
"module": "dist/esm/index.js",
1919
"exports": {
2020
".": {
21+
"types": "./dist/index.d.ts",
2122
"node": {
2223
"import": "./dist/esm/index.js",
2324
"require": "./dist/cjs/index.js",
@@ -32,11 +33,14 @@
3233
"scripts": {
3334
"lint": "eslint . --cache --ext js,cjs,mjs,ts,md",
3435
"test": "yarn lint && jest",
35-
"build": "rimraf dist && rollup --config rollup.config.ts --configPlugin typescript",
36+
"build": "rimraf dist && yarn build:ts && yarn build:types",
37+
"build:ts": "rollup --config rollup.config.ts --configPlugin typescript",
38+
"build:types": "node ./scripts/build-types.mjs",
3639
"prepare": "yarn build",
3740
"prepublishOnly": "yarn test"
3841
},
3942
"devDependencies": {
43+
"@microsoft/api-extractor": "^7.31.0",
4044
"@rollup/plugin-commonjs": "^22.0.2",
4145
"@rollup/plugin-json": "^4.1.0",
4246
"@rollup/plugin-node-resolve": "^14.0.1",
@@ -46,6 +50,8 @@
4650
"@types/node": "^14.18.28",
4751
"@typescript-eslint/eslint-plugin": "^5.36.2",
4852
"@typescript-eslint/parser": "^5.36.2",
53+
"chalk": "^5.0.1",
54+
"deepmerge": "^4.2.2",
4955
"eslint": "^8.23.0",
5056
"eslint-config-prettier": "^8.5.0",
5157
"eslint-import-resolver-typescript": "^3.5.1",
@@ -54,11 +60,15 @@
5460
"eslint-plugin-jest": "^27.0.2",
5561
"eslint-plugin-markdown": "^3.0.0",
5662
"eslint-plugin-prettier": "^4.2.1",
63+
"execa": "^6.1.0",
64+
"graceful-fs": "^4.2.10",
5765
"jest": "^29.0.2",
66+
"pkg-dir": "^7.0.0",
5867
"prettier": "^2.7.1",
5968
"rimraf": "^3.0.2",
6069
"rollup": "^2.79.0",
6170
"rollup-plugin-terser": "^7.0.2",
71+
"ts-jest": "^29.0.1",
6272
"tslib": "^2.4.0",
6373
"typescript": "^4.8.3"
6474
},

rollup.config.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import type {
1616
const onwarn: WarningHandlerWithDefault = (warning, rollupWarn) => {
1717
rollupWarn(warning);
1818
if (warning.code === "CIRCULAR_DEPENDENCY") {
19-
throw new Error(
20-
"Please eliminate the circular dependencies listed above and retry the build",
21-
);
19+
throw new Error("Please eliminate the circular dependencies listed above and retry the build");
2220
}
2321
};
2422

0 commit comments

Comments
 (0)