# How do you automatically create multiple modules based on the files in a folder

**URL:** https://clojureverse.org/t/how-do-you-automatically-create-multiple-modules-based-on-the-files-in-a-folder/8421
**Category:** shadow-cljs
**Created:** [December 12, 2021, 11:42pm UTC](https://clojureverse.org/t/how-do-you-automatically-create-multiple-modules-based-on-the-files-in-a-folder/8421 "2021-12-12T23:42:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![teez](https://clojureverse.org/letter_avatar_proxy/v4/letter/t/b9e5f3/32.png) [@teez](https://clojureverse.org/u/teez)
#### Post date: [December 12, 2021, 11:42pm UTC](https://clojureverse.org/t/how-do-you-automatically-create-multiple-modules-based-on-the-files-in-a-folder/8421/1 "2021-12-12T23:42:22Z")

</div>

Not sure if this use case is supported, or even if it’s a sane one. Basically, I want JS specific to each page. I will have .cljc file for each page. I basically want this file compiled into its own module. So for example, given the files “pages/login.cljc” and “pages/contact.cljc”, I would like to generate a “login.js” and “contact.js”. Right now I’m doing that with this shadow-cljs.edn modules config:

```auto
:app {:entries [project.app]}
:login {:entries [project.pages.login]
        :depends-on #{:app}}
:contact {:entire [project.pages.contact]
          :depends-on #{:app}}

```

But I already have a list of pages elsewhere in the code for things like routes. I would love to use that list of pages to generate these modules, or even just infer it from the files in the `pages` directory. Is this possible?

---

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [December 13, 2021, 6:04am UTC](https://clojureverse.org/t/how-do-you-automatically-create-multiple-modules-based-on-the-files-in-a-folder/8421/2 "2021-12-13T06:04:49Z")

</div>

Not supported and usually not desireable.

I sort of explained this in my [blog post about code splitting](https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html). Generally splitting by page will lead to non-optimal results in almost all cases. Ending up with with large `app.js` module and possibly tiny (\<1KB) `.js` file for each page. Also the `:depends-on` here is crucial since it will be very common where certain pages share certain code but others do that. With only one shared module it only has one place to go.

Tweaking the `:modules` is something you should be doing when the code is written based on the build reports.

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [June 13, 2022, 6:05pm UTC](https://clojureverse.org/t/how-do-you-automatically-create-multiple-modules-based-on-the-files-in-a-folder/8421/3 "2022-06-13T18:05:29Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
