Skip to content

Commit

Permalink
build: correct tsconfig for test files in src
Browse files Browse the repository at this point in the history
  • Loading branch information
moontai0724 committed Oct 9, 2024
1 parent 88e49fd commit 029f63d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import globals from "globals";
import { config as typedConfig, configs as tsConfigs } from "typescript-eslint";

export default typedConfig(
{ ignores: ["node_modules", "dist", "build", "coverage"] },
{ ignores: ["node_modules", "dist", "build", "docs", "coverage"] },
{
files: ["src/**/*.ts"],
languageOptions: {
Expand Down
2 changes: 2 additions & 0 deletions src/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": false,
"noEmit": false,
"emitDeclarationOnly": false,
"declaration": true,
"noEmitOnError": true
},
Expand Down
19 changes: 14 additions & 5 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"noEmit": false,
"emitDeclarationOnly": true,
"target": "ES6",
"module": "ESNext",
// Bundler mode
"moduleResolution": "bundler",

"lib": ["ES6", "DOM", "DOM.Iterable"],

"rootDir": "."
"rootDir": ".",
"paths": {
"@/*": ["../src/*"]
}
},
"include": ["."]
"include": ["./**/*.ts"],
"exclude": ["./**/*.spec.ts"],
"references": [
{
"path": "../tests"
}
]
}
17 changes: 11 additions & 6 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "../src",
"paths": {
"@/*": ["../src/*"],
"~/*": ["../tests/*"]
}
"composite": true,
"noEmit": false,
"emitDeclarationOnly": true,
"target": "ESNext",
"baseUrl": "../src"
},
"include": [".", "../src"]
"include": ["./**/*.ts", "../src/**/*.spec.ts"],
"references": [
{
"path": "../src"
}
]
}
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
// Specify what module code is generated
"module": "ESNext",
// Specify how TypeScript looks up a file from a given module specifier
"moduleResolution": "Node",
"moduleResolution": "Bundler",

// Specify the root folder contains all ts files
"rootDir": ".",
// Specify the base directory to resolve non-relative module names
"baseUrl": "./src",
"paths": {
"@/*": ["./*"] // => `./src/*`
"@/*": ["../src/*"],
"~/*": ["../tests/*"]
},
"outDir": "./build",

Expand Down Expand Up @@ -40,7 +41,7 @@
"skipLibCheck": true,
"useDefineForClassFields": true
},
"exclude": ["node_modules", "dist"],
"exclude": ["node_modules", "dist", "build", "docs", "coverage"],
"tsc-alias": {
"resolveFullPaths": true,
"verbose": true
Expand Down
7 changes: 7 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { resolve } from "node:path";

import { defineConfig, mergeConfig } from "vitest/config";

import viteConfig from "./vite.config";

export default mergeConfig(
viteConfig,
defineConfig({
resolve: {
alias: {
"~": resolve(import.meta.dirname, "tests"),
},
},
test: {
coverage: {
enabled: true,
Expand Down

0 comments on commit 029f63d

Please sign in to comment.