Skip to content

Commit

Permalink
chore(frontend): manually compile with tsconfig.build.json before run…
Browse files Browse the repository at this point in the history
…ning react-scripts
  • Loading branch information
Falinor authored and loicguillois committed Oct 9, 2024
1 parent 9933732 commit eb01f62
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
19 changes: 13 additions & 6 deletions frontend/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@ module.exports = {
// See https://github.com/alex3165/react-mapbox-gl/issues/931
// See https://github.com/mapbox/mapbox-gl-js/issues/10565
// eslint-disable-next-line import/no-webpack-loader-syntax
ignore: ['./node_modules/maplibre-gl/dist/maplibre-gl.js'],
},
ignore: ['./node_modules/maplibre-gl/dist/maplibre-gl.js']
}
},
typescript: {
// Disable type checking by react-scripts because it takes tsconfig.json
// blindlessly, and compiles tests and mocks, although it should not.
// Instead, we manually compile with tsconfig.build.json,
// as we would do using vite.
enableTypeChecking: false
},
jest: {
configure(config) {
config.rootDir = '.';
config.setupFiles = ['<rootDir>/jest.polyfills.js'];
config.setupFilesAfterEnv = [
'jest-extended/all',
'<rootDir>/src/setupTests.ts',
'<rootDir>/src/setupTests.ts'
];
config.testTimeout = 30_000;
config.transformIgnorePatterns = [
'<rootDir>/node_modules/(?!@codegouvfr)/.+\\.js$',
'<rootDir>/node_modules/.store/(?!@codegouvfr)/.+\\.js$',
'<rootDir>/node_modules/.store/(?!@codegouvfr)/.+\\.js$'
];
return config;
},
},
}
}
};
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scripts": {
"clean": "rimraf build",
"icons": "only-include-used-icons",
"build": "yarn clean && yarn icons && DISABLE_ESLINT_PLUGIN=true craco build",
"build": "yarn clean && yarn icons && tsc -b tsconfig.build.json && DISABLE_ESLINT_PLUGIN=true craco build",
"dev": "yarn icons && DISABLE_ESLINT_PLUGIN=true craco start",
"test": "DISABLE_ESLINT_PLUGIN=true craco test",
"postinstall": "copy-dsfr-to-public"
Expand Down
13 changes: 9 additions & 4 deletions frontend/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"moduleResolution": "bundler"
},
"exclude": ["node_modules", "dist","src/**/*.test.ts", "src/**/*.test.tsx"]
"exclude": [
"node_modules",
"build",
"src/mocks/**/*.ts",
"src/setupTests.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"test/fixtures.test.ts"
]
}
3 changes: 0 additions & 3 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
"moduleResolution": "node"
},
"include": ["src"]
}

0 comments on commit eb01f62

Please sign in to comment.