Open orrin-naylor-instacart opened 2 years ago
This demonstrates the issue really well
Running a mock test sweet with our no barrel imports version of openAPI 5s With the existing version 15s
The worst part is it continues to scale like this as you add tests. EG I'm running this test 14 times together. No barrel 9s
Existing 28s
I might not even need to add a new parameter. If I could just change the defaults templates from generating imports that look like this.
import {
GetAdminProductMappingRequestsParamData,
GetAdminProductMappingRequestsParamDataFromJSON,
GetAdminProductMappingRequestsParamDataFromJSONTyped,
} from './'
To this
import {
GetAdminProductMappingRequestsParamData,
GetAdminProductMappingRequestsParamDataFromJSON,
GetAdminProductMappingRequestsParamDataFromJSONTyped,
} from './GetAdminProductMappingRequestsParamData'
We'd be good. It's not a breaking change. The barrel exports can still exist, but people who choose not to use them can import directly.
@macjohnny We finished rooting this issue out of our codebase today. Result: Our CI tests are running in half the time. I'd love to contribute this back to the community. I just need the go ahead so I don't waste my time.
Sounds good, happy to review your PR
Is your feature request related to a problem? Please describe.
At instacart we are power users of openapi-generator. We have thousands of files in the /models directory. Because of the barrel imports, importing one file from models or apis imports everything from models or apis. EG
Parsing all that typescript causes our tests to run significantly slower. We've experimented with manually removing the barrel imports. Which resulted in a ~3x speedup. Individual test ran in 12s rather than 33s.
Describe the solution you'd like
I'd like to add a
--noBarrelImports
flag to the generatorDescribe alternatives you've considered
We tried creating our own .mustache templates. And it worked! It'd be nice to it have built in, so we can continue to get updates and bug fixes.