Skip to content

Commit

Permalink
🔧 [#445] Update configuration for typescript
Browse files Browse the repository at this point in the history
The babel presets are no longer requires, since vite/esbuild takes care
of that. The module resolution and formatjs plugins are still necessary
since the tsconfig.json doesn't cover that.

When imports are converted to use the @/ prefix, we can drop the
module resolution plugin.
  • Loading branch information
sergei-maertens committed Mar 3, 2025
1 parent b3329d7 commit aece75c
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 218 deletions.
6 changes: 0 additions & 6 deletions jsconfig.json

This file was deleted.

234 changes: 39 additions & 195 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@
"typescript": "^5.7.3",
"typescript-eslint": "^8.25.0",
"vite": "^6.0.11",
"vite-jsconfig-paths": "^2.0.1",
"vite-plugin-eslint2": "^5.0.3",
"vite-plugin-svgr": "^4.3.0",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.3",
"yargs": "^17.1.1"
},
Expand All @@ -176,20 +176,6 @@
"formiojs": "npm:@open-formulieren/formiojs@4.13.14"
},
"babel": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
],
"plugins": [
[
"formatjs",
Expand Down
27 changes: 27 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"baseUrl": "src",
"outDir": "dist",
"module": "esnext",
"target": "ES2021",
"jsx": "react-jsx",
"declaration": true,
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictBindCallApply": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"noErrorTruncation": true,
"paths": {
"@/*": ["./*"],
"@/sb-decorators": ["../.storybook/decorators.tsx"]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
4 changes: 2 additions & 2 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import react from '@vitejs/plugin-react';
import path from 'path';
import type {OutputOptions} from 'rollup';
import {defineConfig, loadEnv} from 'vite';
import jsconfigPaths from 'vite-jsconfig-paths';
import eslint from 'vite-plugin-eslint2';
import tsconfigPaths from 'vite-tsconfig-paths';
import {coverageConfigDefaults} from 'vitest/config';

import {cjsTokens, ejsPlugin} from './build/plugins.mjs';
Expand Down Expand Up @@ -126,7 +126,7 @@ export default defineConfig(({mode}) => {
// they don't get transformed to inject the message ID. The solution is to rename the
// file extension to .jsx/.tsx
react({babel: {babelrc: true}}),
jsconfigPaths(),
tsconfigPaths(),
eslint({
build: true,
emitErrorAsWarning: mode === 'development',
Expand Down

0 comments on commit aece75c

Please sign in to comment.