0

For organization and readability, I often wish to break JavaScript files apart into multiple files. However, I also often want these files I extract to be "private" or "internal" to some parent concept.

Something similar to the .NET concept of internal. NPM packages seem to get close, but I worry about ease of use and management using packages in this way just for encapsulation. I'd rather not have to do a version bump every change.

Is there some sort of encapsulation tool that can span multiple files for JavaScript in a Node/Webpack ecosystem?

Joshua Enfield
  • 17,642
  • 10
  • 51
  • 98
  • Write directories containing your files plus an `index.js` defining the public API? This isn't specific to CRA. See e.g. https://stackoverflow.com/q/21063587/3001761. – jonrsharpe Jul 20 '20 at 20:52
  • @jonrsharpe That's almost perfect. I think my main hangup is preventing imports/autocomplete imports of files in those directories that are not index.js. I'm looking into if at-least blocking autocomplete is an option in VSCode. I'd really like have the encapsulation _enforced._ – Joshua Enfield Jul 20 '20 at 21:36

0 Answers0