0

I have an autogenerated TypeScript file, that only exports an array of 65,000 small objects. The auto-generation is done on an ad-hoc basis, but the compilation is done each time the project is built. Since most of the build-time is spent on compiling this particular file, I would like to optimise it a bid.

This optimisation is primarily a good idea since the file is only being changed 1-3 times a year. Some other parts depend on this file, so I do not think I am able not to compile it.

Is it possible to somehow not compile a file, if it has not been changed, while still being able to reference it?

1 Answer 1

1

You can use the --watch compiler option to incrementally build the project as files change. While this will save time on subsequent build, the first one will still be slow.

A better option might be to compile the file individually (when you generate), and generate a d.ts(using the "declaration": true option), which will probably be smaller and use the js file in your actual project instead. You could also keep the ts file in the project and use "exclude": ["file.ts"] in your tsconfig.json to nto build the fiel every time.

Sign up to request clarification or add additional context in comments.

2 Comments

I am using --watch currently while developing, but some external factors require me to rebuild the whole project multiple times a day. I will look into referencing the js file instead.
@Hedam then you best option is to exclude the ts file from your main, and build it separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.