diff --git a/global.d.ts b/global.d.ts index e8970504b..05a292826 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,5 +1,3 @@ -declare const SERVICE_WORKER_CHECKSUM: string - declare module '@bundled-es-modules/cookie' { export * as default from 'cookie' } diff --git a/src/_t_sconfig.json b/src/_t_sconfig.json deleted file mode 100644 index 6d1fb7c49..000000000 --- a/src/_t_sconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "baseUrl": ".", - "paths": { - "~/core": ["./core"], - "~/core/*": ["./core/*"] - } - }, - "include": ["./**/*.ts"], - "exclude": ["**/*.test.ts"] -} diff --git a/src/browser/global.browser.d.ts b/src/browser/global.browser.d.ts new file mode 100644 index 000000000..8976bba1f --- /dev/null +++ b/src/browser/global.browser.d.ts @@ -0,0 +1 @@ +declare const SERVICE_WORKER_CHECKSUM: string diff --git a/src/browser/tsconfig.browser.build.json b/src/browser/tsconfig.browser.build.json new file mode 100644 index 000000000..8887b4565 --- /dev/null +++ b/src/browser/tsconfig.browser.build.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.browser.json", + "compilerOptions": { + "composite": false + } +} diff --git a/src/browser/tsconfig.browser.json b/src/browser/tsconfig.browser.json index ae34d1363..0bfc7dd8b 100644 --- a/src/browser/tsconfig.browser.json +++ b/src/browser/tsconfig.browser.json @@ -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"] } diff --git a/src/core/http.spec.ts b/src/core/http.test.ts similarity index 100% rename from src/core/http.spec.ts rename to src/core/http.test.ts diff --git a/src/tsconfig.core.build.json b/src/tsconfig.core.build.json new file mode 100644 index 000000000..0852a1d01 --- /dev/null +++ b/src/tsconfig.core.build.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.src.json", + "compilerOptions": { + "composite": false + } +} diff --git a/src/tsconfig.node.build.json b/src/tsconfig.node.build.json new file mode 100644 index 000000000..db4cc04cd --- /dev/null +++ b/src/tsconfig.node.build.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.node.json", + "compilerOptions": { + "composite": false + } +} diff --git a/src/tsconfig.node.json b/src/tsconfig.node.json index a805dcb5f..c98a860ae 100644 --- a/src/tsconfig.node.json +++ b/src/tsconfig.node.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.src.json", + "extends": "./tsconfig.src.json", "compilerOptions": { "types": ["node"] }, diff --git a/tsconfig.src.json b/src/tsconfig.src.json similarity index 60% rename from tsconfig.src.json rename to src/tsconfig.src.json index 3dc433e12..1399d3535 100644 --- a/tsconfig.src.json +++ b/src/tsconfig.src.json @@ -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"] } diff --git a/tsconfig.base.json b/tsconfig.base.json index e7284865d..bb6721e63 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -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"] } diff --git a/tsconfig.test.unit.json b/tsconfig.test.unit.json index 404dda25d..abea30c95 100644 --- a/tsconfig.test.unit.json +++ b/tsconfig.test.unit.json @@ -1,4 +1,6 @@ { + // Configuration for the unit tests living + // next to the source code. "extends": "./tsconfig.base.json", "compilerOptions": { "composite": true, @@ -9,7 +11,7 @@ "include": ["./src/**/*.test.ts", "./test/support"], "references": [ { - "path": "./tsconfig.src.json" + "path": "./src/tsconfig.src.json" } ] } diff --git a/tsup.config.ts b/tsup.config.ts index 609045a35..3e3807145 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,3 +1,4 @@ +import * as path from 'node:path' import { defineConfig, Options } from 'tsup' import * as glob from 'glob' import { @@ -29,6 +30,7 @@ const coreConfig: Options = { bundle: false, splitting: false, dts: true, + tsconfig: path.resolve(__dirname, 'src/tsconfig.core.build.json'), esbuildPlugins: [forceEsmExtensionsPlugin()], } @@ -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()], } @@ -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), }, @@ -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()], } @@ -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.