Excluding specific files (or file extensions) from the final build when building a lib with `app-platform`


I am using the app-platform to build a reusable react components library and I would like to exclude some of the files (stories and test files) from the final build. Is this possible with the app-platform?

1 Like

Hi Gift. Thanks for the inquiry. Sounds like an interesting project you’re working on.

  1. We don’t currently have a way to specify files to ignore via a configuration, but our app-platform builds will only bundle files that are accessible from the entry point, so anything that is not brought into your code with import/require from the entry point should not be bundled (additionally, there should be some tree shaking to remove unused code). This should generally stop files like test files from being included in the bundle. If you find that’s not the case, please let us know.
  2. In terms of ideas for how to structure the build of a component library with app-platform, you might want to look at some our repos like app-runtime where we use yarn workspaces and then bundle into an overall app-runtime package, or at the analytics repo where we just build from a src/index.js entry point.

Let us know if that helps answer your question, or if you’re looking for some other information.


Hello @tzemp,

Thanks for the informative reply. The app platform build seems to work differently for me. I don’t reference any code from the test files but they are still included in the build. I have created a minimal example here with 2 projects, one in typescript and the other in javascript. Perhaps you can also try to see if it ignores the test files or if there is something I’m missing.


Hi Gift. Thanks for that example. I see what you mean. I’ll discuss this tomorrow with some more of the frontend team, and we’ll get back to you.

1 Like

Thanks @tzemp

1 Like

Hi @nnkogift,
I’ve looked into this in some more detail and discussed with @ismay. Before proceeding there is one important distinction to take into account:

  • Files included into the build folder
  • Files included into the published (tarball) bundle

Our tooling presently does not offer a way to exclude files from the build folder, but when publishing to NPM we simply use the standard NPM tools, which support including and excluding specific files in various ways.

I recommend relying on the files field in package.json and will also provide a code example, which represents a section of a package.json file:

    "files": [

This will be interpreted as follows:

  • include files from the build folder
  • include files from the codemods folder
  • exclude files from the __tests__ folder
  • exclude files with the .test.js extension

Hope this helps. Let me know if this works for you.

Best regards,