Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling multiple typescript files #83

Closed
MrMatthewLayton opened this issue Sep 8, 2017 · 5 comments
Closed

Compiling multiple typescript files #83

MrMatthewLayton opened this issue Sep 8, 2017 · 5 comments

Comments

@MrMatthewLayton
Copy link

This starter works great when your library has only one TypeScript file, but not to well it you have > 1 file. Would it be possible to configure the build process to build everything in a folder rather than a single? file

Source...

src
    \foo
        \bar.ts
        \baz.ts

...should produce...

\dist
    \compiled
        \foo
            \bar.js
            \baz.js
@tonysneed
Copy link

@series0ne Rollup does the job of bundling for the starter kit, so whatever folder structure you have, it produces just one bundle. For it all to work, you need to export each of your classes, then have one file with the same name as the project that exports all of them. For example, with two exported classes, HelloWorld and ItalianHelloWorld, you need a ts file with the same name as your project that has the following:

export { HelloWorld } from './hello/hello-world';
export { ItalianHelloWorld } from './hello/italian-hello-world';

Then rollup produces one js file with the two classes and has this at the bottom: export { HelloWorld, ItalianHelloWorld };

Hope this helps!

@alexjoverm
Copy link
Owner

@tonysneed said it clearly, that's the way to go for lib/app dev

@nareshbhatia
Copy link

I have a naive followup question - what's the point of the bundler when working on libraries? Isn't it something that only the "end-product" needs to do, e.g. a web-app that must be deployed? My current requirements are to have maybe 5-10 classes in a library. I simply use tsc to compile and throw them in the dist directory (including type definitions), set up the dependencies/peer dependencies correctly in package.json and everything seems to work fine. I am not seeing the reason for bundling dependencies along with a library. Isn't this something the final client should worry about? Again this may be a very naive question - just looking for the correct use case for bundling!

@alexjoverm
Copy link
Owner

There are several ways a lib can be used, and having a bundled one-file app in UMD format works universally, and needed for example if you use the lib from a CDN.

@nareshbhatia
Copy link

@alexjoverm, makes sense. Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants