Skip to content

feat(exports): Setup ESM first #21

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

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions eslint.config.mjs → eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export default eslintTs.config(
"@stylistic/switch-colon-spacing": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-exports": "off",
"@typescript-eslint/consistent-type-imports": ["off", { fixStyle: "inline-type-imports" }],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }],
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
"@typescript-eslint/explicit-member-accessibility": "error",
Expand Down
29 changes: 23 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,33 @@
"emotion",
"styled-components"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"sideEffects": false,
"source": "./src/main.ts",
"main": "./dist/main.cjs",
"module": "./dist/main.js",
"unpkg": "./dist/main.umd.cjs",
"types": "./dist/main.d.ts",
"exports": {
".": {
"import": "./dist/main.js",
"require": "./dist/main.cjs",
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
},
"./package.json": "./package.json"
},
"files": [
"dist/",
"src/"
"./dist",
"./src",
"./package.json"
],
"engines": {
"node": ">=18"
},
"packageManager": "[email protected]",
"scripts": {
"build": "tsc -p tsconfig.prod.json",
"build": "vite build",
"check": "yarn compile && yarn lint && yarn test",
"compile": "tsc",
"docs": "typedoc",
Expand Down Expand Up @@ -62,6 +77,8 @@
"typedoc-plugin-markdown": "^4.1.0",
"typedoc-plugin-merge-modules": "^5.1.0",
"typescript": "^5.5.2",
"typescript-eslint": "^7.13.1"
"typescript-eslint": "^7.13.1",
"vite": "^5.3.1",
"vite-plugin-dts": "^3.9.1"
}
}
13 changes: 0 additions & 13 deletions src/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/mergeCssVars.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NonEmptyArray } from "../helpers/common";
import { type CssVarContext, makeCssVars } from "./makeCssVars";

import { CssVarContext, makeCssVars } from "./makeCssVars";
import type { NonEmptyArray } from "../helpers/common";

/**
* Recursively merge all CssVarContext on an array into a single CssVarContext.
Expand Down
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { makeCssVars } from "./lib/makeCssVars";
export { mergeCssVars } from "./lib/mergeCssVars";

export type { NonEmptyArray } from "./helpers/common";
export type { CssVarContext, CssVars, VarKey } from "./lib/makeCssVars";
export type { MergeVars } from "./lib/mergeCssVars";
2 changes: 1 addition & 1 deletion test/types/helpers/common.typetest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectTypeOf } from "expect-type";

import { NonEmptyArray } from "../../../src/helpers/common";
import type { NonEmptyArray } from "../../../src/helpers/common";

expectTypeOf<NonEmptyArray<number>>().toMatchTypeOf([1]);
expectTypeOf<NonEmptyArray<number>>().toMatchTypeOf([1, 2]);
Expand Down
2 changes: 1 addition & 1 deletion test/types/lib/makeCssVars.typetest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectTypeOf } from "expect-type";

import { CssVarContext, CssVars, VarKey, makeCssVars } from "../../../src/lib/makeCssVars";
import { type CssVarContext, type CssVars, type VarKey, makeCssVars } from "../../../src/lib/makeCssVars";

type OneVar = `
--gap: 10;
Expand Down
4 changes: 2 additions & 2 deletions test/types/lib/mergeCssVars.typetest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expectTypeOf } from "expect-type";

import { CssVarContext, makeCssVars } from "../../../src/lib/makeCssVars";
import { MergeVars, mergeCssVars } from "../../../src/lib/mergeCssVars";
import { type CssVarContext, makeCssVars } from "../../../src/lib/makeCssVars";
import { type MergeVars, mergeCssVars } from "../../../src/lib/mergeCssVars";

type AllVars = `
--primary-color: red;
Expand Down
4 changes: 2 additions & 2 deletions test/types/index.typetest.ts → test/types/main.typetest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expectTypeOf } from "expect-type";

import { NonEmptyArray } from "../../src/helpers/common";
import { CssVarContext, CssVars, MergeVars, VarKey } from "../../src/index";
import type { NonEmptyArray } from "../../src/helpers/common";
import type { CssVarContext, CssVars, MergeVars, VarKey } from "../../src/main";

expectTypeOf<CssVarContext<string>>().not.toBeAny();
expectTypeOf<CssVars<string>>().not.toBeAny();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/index.test.ts → test/unit/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "@assertive-ts/core";

import { makeCssVars, mergeCssVars } from "../../src/index";
import { makeCssVars, mergeCssVars } from "../../src/main";

describe("[Unit] index.test.ts", () => {
it("exports the lib functions", () => {
Expand Down
24 changes: 12 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"incremental": true,
"module": "CommonJS",
"moduleResolution": "Node",
"isolatedModules": true,
"module": "ES2022",
"moduleResolution": "Bundler",
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./build/",
"outDir": "./build",
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ES6",
"typeRoots" : [
"./node_modules/@types/",
"./typings/"
],
"target": "ES2022",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true
},
"exclude": [
".yarn/*",
"build/*",
"dist/*",
"node_modules/*"
".yarn/**",
"build/**",
"dist/**",
"node_modules/**"
],
"ts-node": {
"transpileOnly": true
Expand Down
11 changes: 0 additions & 11 deletions tsconfig.prod.json

This file was deleted.

6 changes: 3 additions & 3 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"$schema": "https://typedoc.org/schema.json",
"cleanOutputDir": true,
"entryPoints": ["src/index.ts"],
"entryPoints": ["./src/main.ts"],
"entryPointStrategy": "expand",
"gitRevision": "release",
"gitRevision": "main",
"githubPages": false,
"hideGenerator": true,
"includeVersion": false,
"mergeModulesMergeMode": "project",
"mergeModulesRenameDefaults": true,
"name": "TS CSSVars - API Reference",
"out": "docs/build",
"out": "./docs/build",
"plugin": [
"typedoc-plugin-markdown",
"typedoc-plugin-merge-modules"
Expand Down
23 changes: 23 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";

export default defineConfig({
build: {
lib: {
entry: "./src/main.ts",
fileName: "main",
formats: ["cjs", "es", "umd"],
name: "TsCssvars",
},
sourcemap: true,
},
plugins: [
dts({
compilerOptions: {
emitDeclarationOnly: true,
incremental: false,
},
include: "src/**",
}),
],
});
Loading
Loading