Monday, 15 May 2017

Splitting single typescript project into smaller modules (webpack)

Right now, I have a huge Typescript project, and a single webpack config.

I would like to break them into smaller modules/libraries.

Core
    CoreClass1.ts
    CoreClass2.ts
Core.Test (Uses Core)
    CoreClass1UnitTest.ts
    CoreClass2UnitTest.ts
Common (Uses Core)
    CommonClass1.ts
    CommonClass2.ts       
Common.Test (Uses Common, Core)
    CommonClass1UnitTest.ts
    CommonClass2UnitTest.ts
WebApp (uses Core, Common)
    index.ts

I'm hoping to end up with just core.js, common.js, core.test.js, common.test.js and webapp.js.

When everything was in a single project, my webpack.config.js would simply pull all typescript files into a single bundle, and had no issues with intellisense/declaration files.

If I wish to refactor my project into smaller projects/modules, how should I reconfigure my tsconfig.json and webpack.config.js (or even package.json)?

Not sure what to search for online (sibling projects?). I'm using webpack@1, but should be fine reading/translating webpack@2 configurations. Just need a push in the right direction.



via jayars

No comments:

Post a Comment