Comments (5)
@tonysneed said it clearly, that's the way to go for lib/app dev
from typescript-library-starter.
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.
@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.
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.
@alexjoverm, makes sense. Thanks for the clarification.
from typescript-library-starter.
Related Issues (20)
- [typings] How to merge d.ts files under one namespace?
- ES6 imports
- `Error: '__spreadArrays' is not exported by tslib` occurs when `npm run build` HOT 8
- automatically update year in license to current year
- use ISC license
- found 326 vulnerabilities (73 low, 1 moderate, 252 high) HOT 1
- Source maps pointing outside of dist folder
- Import does not work HOT 1
- when i clone github project directly install times error
- README: add instructions/steps on how to use this together with `google/clasp`
- How to integrate REACT HOT 1
- Not getting autocompletion when importing published library in a project HOT 1
- Better post-install markdown file generation.
- some dependencies need upgrade
- How to use library version in package.json
- How should I got the correct version field in package.json?
- Is this package dead? HOT 7
- node_modules/@types/node/assert.d.ts(1) '{' or ';' expected. HOT 5
- Is it possible to use this to export a function that calls ReactDOM.render, rather than rendering automatically?
- Error: Cannot find module scoped private package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-library-starter.