aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinigami <[email protected]>2024-09-14 21:44:33 +0200
committerGitHub <[email protected]>2024-09-14 21:44:33 +0200
commit53ef42cc192996a0e09bba9d5f5f8a70a7932275 (patch)
tree0f1e6f4bf5d9257ac0b7b09d2921b3a53b13d4cc
parent18ab2c7b3c8fa78c46d4abafc07c3219f41caa46 (diff)
downloadfaker-53ef42cc192996a0e09bba9d5f5f8a70a7932275.tar.xz
faker-53ef42cc192996a0e09bba9d5f5f8a70a7932275.zip
fix: emit cts types (#3093)
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--CONTRIBUTING.md1
-rw-r--r--package.json36
-rw-r--r--scripts/apidocs/project.ts2
-rw-r--r--test/faker.spec.ts2
-rw-r--r--tsconfig.build.json16
-rw-r--r--tsconfig.json5
-rw-r--r--tsup.config.ts2
8 files changed, 29 insertions, 37 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index be5496da..a5463975 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -174,7 +174,7 @@ jobs:
CYPRESS_INSTALL_BINARY: 0
- name: Build types
- run: pnpm run build:types
+ run: pnpm run build
- name: Check scripts
run: pnpm run ts-check
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 487c99e0..c3982b27 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -24,7 +24,6 @@ This is a shorthand for running the following scripts in order:
- `pnpm run lint` - runs [ESLint](https://github.com/eslint/eslint) to enforce project code standards
- `pnpm run build:clean` - removes artifacts from previous builds
- `pnpm run build:code` - builds the code, both CommonJS and ESM versions
-- `pnpm run build:types` - builds the TypeScript type definitions
- `pnpm run test:update-snapshots` - runs all tests, and updates any snapshots if needed
- `pnpm run ts-check` - checks that there are no TypeScript errors in any files
diff --git a/package.json b/package.json
index cc3011e6..41b1da55 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,7 @@
"clean": "rimraf coverage .eslintcache dist docs/.vitepress/cache docs/.vitepress/dist node_modules",
"build:clean": "rimraf dist",
"build:code": "tsup-node",
- "build:types": "tsc --project tsconfig.build.json",
- "build": "run-s build:clean build:code build:types",
+ "build": "run-s build:clean build:code",
"generate": "run-s generate:locales generate:api-docs",
"generate:api-docs": "tsx ./scripts/apidocs.ts",
"generate:locales": "tsx ./scripts/generate-locales.ts",
@@ -65,26 +64,37 @@
"type": "module",
"exports": {
".": {
- "types": "./dist/types/index.d.ts",
- "import": "./dist/index.js",
- "require": "./dist/index.cjs",
- "default": "./dist/index.js"
+ "require": {
+ "types": "./dist/index.d.cts",
+ "default": "./dist/index.cjs"
+ },
+ "default": {
+ "types": "./dist/index.d.ts",
+ "default": "./dist/index.js"
+ }
},
"./locale/*": {
- "types": "./dist/types/locale/*.d.ts",
- "import": "./dist/locale/*.js",
- "require": "./dist/locale/*.cjs",
- "default": "./dist/locale/*.js"
+ "require": {
+ "types": "./dist/locale/*.d.cts",
+ "default": "./dist/locale/*.cjs"
+ },
+ "default": {
+ "types": "./dist/locale/*.d.ts",
+ "default": "./dist/locale/*.js"
+ }
},
"./package.json": "./package.json"
},
"main": "dist/index.cjs",
"module": "dist/index.js",
- "types": "index.d.ts",
+ "types": "dist/index.d.ts",
"typesVersions": {
">=5.0": {
- "*": [
- "dist/types/*"
+ ".": [
+ "./dist/index.d.ts"
+ ],
+ "locale/*": [
+ "./dist/locale/*.d.ts"
]
}
},
diff --git a/scripts/apidocs/project.ts b/scripts/apidocs/project.ts
index c63bad8e..9cf5ce10 100644
--- a/scripts/apidocs/project.ts
+++ b/scripts/apidocs/project.ts
@@ -4,6 +4,6 @@ import { Project } from 'ts-morph';
export function getProject(options: Partial<ProjectOptions> = {}): Project {
return new Project({
...options,
- tsConfigFilePath: options.tsConfigFilePath ?? 'tsconfig.build.json',
+ tsConfigFilePath: options.tsConfigFilePath ?? 'tsconfig.json',
});
}
diff --git a/test/faker.spec.ts b/test/faker.spec.ts
index 749e8501..6d928d63 100644
--- a/test/faker.spec.ts
+++ b/test/faker.spec.ts
@@ -18,6 +18,8 @@ describe('faker', () => {
.filter((key) => typeof console[key] === 'function')
.map((methodName) => vi.spyOn(console, methodName));
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore: Types may or may not exist, depending on whether the project was built first.
const file: unknown = await import('..');
expect(file).toBeDefined();
diff --git a/tsconfig.build.json b/tsconfig.build.json
deleted file mode 100644
index 0d07a4fc..00000000
--- a/tsconfig.build.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "target": "ES2022",
- "noEmit": false,
- "emitDeclarationOnly": true,
- "rootDir": "src",
- "outDir": "dist/types",
-
- // This negates what is set in the extended tsconfig.json
- "skipLibCheck": false,
- "allowSyntheticDefaultImports": false,
- "resolveJsonModule": false
- },
- "include": ["src"]
-}
diff --git a/tsconfig.json b/tsconfig.json
index cc4809da..c8ffb862 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,15 +1,12 @@
{
"compilerOptions": {
"target": "ESNext",
- "moduleResolution": "node",
+ "moduleResolution": "Bundler",
"module": "ESNext",
"strict": true,
"noEmit": true,
- "declaration": true,
"stripInternal": true,
"verbatimModuleSyntax": true,
-
- // These are configs specifically for !build and have to be reverted in the tsconfig.build.json
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
diff --git a/tsup.config.ts b/tsup.config.ts
index d9b3970f..214eb718 100644
--- a/tsup.config.ts
+++ b/tsup.config.ts
@@ -10,7 +10,7 @@ export default defineConfig({
clean: true,
format: ['esm', 'cjs'],
target: ['es2022', 'node18'],
- dts: false, // will be generated with the "build:types" script
+ dts: true,
minify: true,
sourcemap: false,
splitting: true,