Giter Site home page Giter Site logo

Comments (5)

alexjoverm avatar alexjoverm commented on May 18, 2024 1

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

from typescript-library-starter.

nareshbhatia avatar nareshbhatia commented on May 18, 2024 1

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!

from typescript-library-starter.

tonysneed avatar tonysneed commented on May 18, 2024

@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!

from typescript-library-starter.

alexjoverm avatar alexjoverm commented on May 18, 2024

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.

from typescript-library-starter.

nareshbhatia avatar nareshbhatia commented on May 18, 2024

@alexjoverm, makes sense. Thanks for the clarification.

from typescript-library-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.