Skip to content

Commit

Permalink
chore: split tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Nov 1, 2023
1 parent 16eeac1 commit 3bfbf7e
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 28 deletions.
2 changes: 0 additions & 2 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
declare const SERVICE_WORKER_CHECKSUM: string

declare module '@bundled-es-modules/cookie' {
export * as default from 'cookie'
}
Expand Down
12 changes: 0 additions & 12 deletions src/_t_sconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions src/browser/global.browser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const SERVICE_WORKER_CHECKSUM: string
6 changes: 6 additions & 0 deletions src/browser/tsconfig.browser.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.browser.json",
"compilerOptions": {
"composite": false
}
}
7 changes: 4 additions & 3 deletions src/browser/tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "../../tsconfig.src.json",
"extends": "../tsconfig.src.json",
"compilerOptions": {
// Expose browser-specific libraries only for the
// source code under the "src/browser" directory.
"lib": ["DOM", "WebWorker"]
},
"include": ["./**/*.ts"],
"exclude": ["**/*.test.ts"]
"include": ["./global.browser.d.ts", "./**/*.ts"]
}
File renamed without changes.
6 changes: 6 additions & 0 deletions src/tsconfig.core.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.src.json",
"compilerOptions": {
"composite": false
}
}
6 changes: 6 additions & 0 deletions src/tsconfig.node.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.node.json",
"compilerOptions": {
"composite": false
}
}
2 changes: 1 addition & 1 deletion src/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.src.json",
"extends": "./tsconfig.src.json",
"compilerOptions": {
"types": ["node"]
},
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.src.json → src/tsconfig.src.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
// Common configuration for everything
// living in the "src" directory.
"extends": "./tsconfig.base.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"baseUrl": "src",
"baseUrl": "./",
"paths": {
"~/core": ["core"],
"~/core/*": ["core/*"]
}
},
"include": ["src"],
"exclude": ["**/*.test.ts"]
"include": ["../global.d.ts", "./**/*.ts"],
"exclude": ["./**/*.test.ts"]
}
10 changes: 6 additions & 4 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"target": "es6",
"module": "esnext",
"moduleResolution": "node"
"moduleResolution": "node",
"strict": true,
"strictNullChecks": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": false
},
"include": ["global.d.ts"],
"include": ["./global.d.ts"],
"exclude": ["node_modules", "lib"]
}
4 changes: 3 additions & 1 deletion tsconfig.test.unit.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
// Configuration for the unit tests living
// next to the source code.
"extends": "./tsconfig.base.json",
"compilerOptions": {
"composite": true,
Expand All @@ -9,7 +11,7 @@
"include": ["./src/**/*.test.ts", "./test/support"],
"references": [
{
"path": "./tsconfig.src.json"
"path": "./src/tsconfig.src.json"
}
]
}
12 changes: 11 additions & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from 'node:path'
import { defineConfig, Options } from 'tsup'
import * as glob from 'glob'
import {
Expand Down Expand Up @@ -29,6 +30,7 @@ const coreConfig: Options = {
bundle: false,
splitting: false,
dts: true,
tsconfig: path.resolve(__dirname, 'src/tsconfig.core.build.json'),
esbuildPlugins: [forceEsmExtensionsPlugin()],
}

Expand All @@ -44,7 +46,7 @@ const nodeConfig: Options = {
bundle: true,
splitting: false,
dts: true,

tsconfig: path.resolve(__dirname, 'src/tsconfig.node.build.json'),
esbuildPlugins: [resolveCoreImportsPlugin(), forceEsmExtensionsPlugin()],
}

Expand All @@ -58,6 +60,12 @@ const browserConfig: Options = {
bundle: true,
splitting: false,
dts: true,
/**
* @note Use a proxy TypeScript configuration where the "compilerOptions.composite"
* option is set to false.
* @see https://github.com/egoist/tsup/issues/571
*/
tsconfig: path.resolve(__dirname, 'src/browser/tsconfig.browser.build.json'),
define: {
SERVICE_WORKER_CHECKSUM: JSON.stringify(SERVICE_WORKER_CHECKSUM),
},
Expand All @@ -78,6 +86,7 @@ const reactNativeConfig: Options = {
bundle: true,
splitting: false,
dts: true,
tsconfig: path.resolve(__dirname, 'src/tsconfig.node.build.json'),
esbuildPlugins: [resolveCoreImportsPlugin(), forceEsmExtensionsPlugin()],
}

Expand All @@ -96,6 +105,7 @@ const iifeConfig: Options = {
bundle: true,
splitting: false,
dts: false,
tsconfig: path.resolve(__dirname, 'src/browser/tsconfig.browser.build.json'),
define: {
// Sign the IIFE build as well because any bundle containing
// the worker API must have the the integrity checksum defined.
Expand Down

0 comments on commit 3bfbf7e

Please sign in to comment.