Split a file into smaller files preserving the module name

I have a large file representing a module, and I would like to split that module into smaller files, but preserving the module name. Is that possible?

You can do something like this…

Let’s say you have a module file called MyModule.res, and you want to split it up. First, you extract parts of this module into separate files. Let’s call them MyModule__A.res and MyModule__B.res. Then inside MyModule.res you use the include keyword to “include” the contents of the sub-modules inside your main module, like this:

/* MyModule.res */

include MyModule__A
include MyModule__B

Then everything inside MyModule__A and MyModule__B can be accessed from MyModule.

8 Likes