We are working on a typescript react 'main' project. In the package.json file, there is a dependency on another internal library that we utilize. The 'main' project builds successfully when both projects are set to target es5. However, changing to es2017 results in the following error:
You may need an appropriate loader to handle this file type, as currently no loaders are configured to process this file.
This error occurs for all files that declare enums in the dependent project.
Here is the tsconfig.json configuration for the main project:
{
"compilerOptions": {
"resolveJsonModule": true,
"noImplicitAny": false,
"module": "commonjs",
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es2017",
"jsx": "react",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"types": ["node", "jest"],
"baseUrl": "./src"
},
"exclude": ["node_modules"],
"includes": ["./src"]
}
And here is the webpack.config.js settings:
// webpack configurations here...
This is the babel.config.json setup:
// babel configurations here...
The issue arises when trying to target es2017, and one solution was found by changing the package json to point to the local copy of the dependent repository ('models').
For more information, refer to the IMPORTANT UPDATE section above.
Additionally, be aware of the 2nd UPDATE regarding the preset-react setting in babel.config.json causing issues with enum declarations.