Skip to content

Commit 5d5b0e4

Browse files
authored
feat(exports): Setup ESM first (#21)
* feat(exports): Setup ESM first * Switch to Vitest
1 parent e11eede commit 5d5b0e4

22 files changed

+1633
-662
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- run: yarn install --immutable
2727
- run: yarn compile
2828
- run: yarn lint
29-
- run: yarn test --forbid-only
29+
- run: yarn test

.mocharc.json

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

eslint.config.mjs renamed to eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export default eslintTs.config(
112112
"@stylistic/switch-colon-spacing": "error",
113113
"@typescript-eslint/ban-types": "error",
114114
"@typescript-eslint/consistent-type-assertions": "error",
115-
"@typescript-eslint/consistent-type-exports": "off",
116-
"@typescript-eslint/consistent-type-imports": ["off", { fixStyle: "inline-type-imports" }],
115+
"@typescript-eslint/consistent-type-exports": "error",
116+
"@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }],
117117
"@typescript-eslint/dot-notation": "error",
118118
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
119119
"@typescript-eslint/explicit-member-accessibility": "error",

package.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,39 @@
1616
"emotion",
1717
"styled-components"
1818
],
19-
"main": "./dist/index.js",
20-
"types": "./dist/index.d.ts",
19+
"type": "module",
20+
"sideEffects": false,
21+
"source": "./src/main.ts",
22+
"main": "./dist/main.cjs",
23+
"module": "./dist/main.js",
24+
"unpkg": "./dist/main.umd.cjs",
25+
"types": "./dist/main.d.ts",
26+
"exports": {
27+
".": {
28+
"import": "./dist/main.js",
29+
"require": "./dist/main.cjs",
30+
"types": "./dist/main.d.ts",
31+
"default": "./dist/main.js"
32+
},
33+
"./package.json": "./package.json"
34+
},
2135
"files": [
22-
"dist/",
23-
"src/"
36+
"./dist",
37+
"./src",
38+
"./package.json"
2439
],
2540
"engines": {
2641
"node": ">=18"
2742
},
2843
"packageManager": "[email protected]",
2944
"scripts": {
30-
"build": "tsc -p tsconfig.prod.json",
31-
"check": "yarn compile && yarn lint && yarn test",
45+
"build": "vite build",
46+
"check": "yarn compile && yarn lint && yarn test --run",
3247
"compile": "tsc",
3348
"docs": "typedoc",
3449
"lint": "eslint .",
3550
"release": "semantic-release",
36-
"test": "NODE_ENV=test mocha \"test/**/*.test.ts\""
51+
"test": "NODE_ENV=test vitest"
3752
},
3853
"devDependencies": {
3954
"@assertive-ts/core": "^2.1.0",
@@ -43,7 +58,6 @@
4358
"@stylistic/eslint-plugin": "^2.2.2",
4459
"@types/eslint__eslintrc": "^2.1.1",
4560
"@types/eslint__js": "^8.42.3",
46-
"@types/mocha": "^10.0.7",
4761
"@types/node": "^20.14.8",
4862
"eslint": "^9.5.0",
4963
"eslint-import-resolver-typescript": "^3.6.1",
@@ -53,15 +67,15 @@
5367
"eslint-plugin-import": "^2.29.1",
5468
"eslint-plugin-jsdoc": "^48.3.0",
5569
"eslint-plugin-sonarjs": "^1.0.3",
56-
"expect-type": "^0.19.0",
57-
"mocha": "^10.4.0",
5870
"semantic-release": "^24.0.0",
5971
"semantic-release-yarn": "^3.0.2",
60-
"ts-node": "^10.9.2",
6172
"typedoc": "^0.26.2",
6273
"typedoc-plugin-markdown": "^4.1.0",
6374
"typedoc-plugin-merge-modules": "^5.1.0",
6475
"typescript": "^5.5.2",
65-
"typescript-eslint": "^7.13.1"
76+
"typescript-eslint": "^7.13.1",
77+
"vite": "^5.3.1",
78+
"vite-plugin-dts": "^3.9.1",
79+
"vitest": "^1.6.0"
6680
}
6781
}

src/index.ts

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

src/lib/mergeCssVars.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { NonEmptyArray } from "../helpers/common";
1+
import { type CssVarContext, makeCssVars } from "./makeCssVars";
22

3-
import { CssVarContext, makeCssVars } from "./makeCssVars";
3+
import type { NonEmptyArray } from "../helpers/common";
44

55
/**
66
* Recursively merge all CssVarContext on an array into a single CssVarContext.

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { makeCssVars } from "./lib/makeCssVars";
2+
export { mergeCssVars } from "./lib/mergeCssVars";
3+
4+
export type { NonEmptyArray } from "./helpers/common";
5+
export type { CssVarContext, CssVars, VarKey } from "./lib/makeCssVars";
6+
export type { MergeVars } from "./lib/mergeCssVars";

test/types/helpers/common.typetest.ts

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

test/types/index.typetest.ts

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

test/types/lib/makeCssVars.typetest.ts

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

0 commit comments

Comments
 (0)