From 7e8a2c6129342c8fa1ae2edcffccd472079a42ba Mon Sep 17 00:00:00 2001 From: AverageHelper <1500092+AverageHelper@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:02:47 -0600 Subject: [PATCH] fix: Enforce type safety where ESBuild won't --- package-lock.json | 27 +++++++++++++++++++++++++++ package.json | 1 + rollup.config.ts | 6 ++++++ tsconfig.prod.json | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a8913fab..d20e5dba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "@rollup/plugin-json": "6.0.0", "@rollup/plugin-node-resolve": "15.0.1", "@rollup/plugin-replace": "5.0.2", + "@rollup/plugin-typescript": "11.1.5", "@types/lodash-es": "4.17.8", "@types/node": "20.8.8", "@types/source-map-support": "0.5.6", @@ -1346,6 +1347,32 @@ } } }, + "node_modules/@rollup/plugin-typescript": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.5.tgz", + "integrity": "sha512-rnMHrGBB0IUEv69Q8/JGRD/n4/n6b3nfpufUu26axhUcboUzv/twfZU8fIBbTOphRAe0v8EyxzeDpKXqGHfyDA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.3.tgz", diff --git a/package.json b/package.json index 277d4e8a..b61cff59 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "@rollup/plugin-json": "6.0.0", "@rollup/plugin-node-resolve": "15.0.1", "@rollup/plugin-replace": "5.0.2", + "@rollup/plugin-typescript": "11.1.5", "@types/lodash-es": "4.17.8", "@types/node": "20.8.8", "@types/source-map-support": "0.5.6", diff --git a/rollup.config.ts b/rollup.config.ts index 09f9120b..24710818 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -6,6 +6,7 @@ import commonjs from '@rollup/plugin-commonjs'; import esbuild from 'rollup-plugin-esbuild'; import json from '@rollup/plugin-json'; import replace from '@rollup/plugin-replace'; +import typescript from '@rollup/plugin-typescript'; const HOME = process.env['HOME']; const NODE_ENV = process.env['NODE_ENV']; @@ -23,6 +24,11 @@ export default defineConfig({ }) : null, + // Check types + typescript({ + tsconfig: './tsconfig.prod.json', + }), + // Transpile source esbuild({ tsconfig: './tsconfig.prod.json', diff --git a/tsconfig.prod.json b/tsconfig.prod.json index 85aedf40..f70a11bb 100644 --- a/tsconfig.prod.json +++ b/tsconfig.prod.json @@ -3,7 +3,7 @@ "exclude": ["src/**/*.test.ts", "**/__mocks__/**/*.ts"], "compilerOptions": { "target": "ES2022", - "module": "CommonJS", + "module": "ESNext", "lib": ["ES2022"], "allowSyntheticDefaultImports": true, "moduleResolution": "node",