Comments (3)
dependencies
. If you are building a TS package and enable importHelpers
, then tslib
is a hard dependency and must be installed for those using your package, as though you had imported it yourself like any other library.
from tslib.
@jakebailey Just to be clear, is this the official recommendation even in the monorepo context as well? Say I have a monorepo with 2 projects that are shipped to end-users: P1
, P2
and libraries in the monorepo, used by those projects: L1
, L2
. Everything is written in TypeScript, libraries are not published in NPM, same TS/tslib
version everywhere.
My approach so far has been:
P1
,P2
listtslib
independencies
L1
,L2
listtslib
inpeerDependencies
(and sometimesdevDependencies
, if the library has tests and is compiled independently in CI to run the tests)
Feels like this is similar to e.g. react
or express
in shared libraries — we need them in runtime, but it's the consuming package that needs to provide those peerDependencies
. Otherwise (i.e. listing tslib
in dependencies
) might easily result in multiple copies of tslib
in the bundle in the frontend code.
TL;DR: I think that it makes sense to keep tslib
in peerDependencies
when building a library (especially in the monorepo context, where you control all versions of TS etc.)
from tslib.
I don't think it makes more sense, no. My personal mental model of peer deps is "this package augments or plugs into this other package". Some package managers (like yarn) don't auto install peers, shifting the burden of installing them onto downstream users. But, ideally, no user should ever be able to observe that you're using tslib or not; it's just a choice when compiling the code to share the helpers. It may even be the case that some package needs one version, while another package needs a different one. If they are the same, package managers are smart enough to dedupe (and usually it's only a v1/v2 thing).
Of course, in your private monorepo, you are free to do whatever you want. You can control the versions and the package manager.
from tslib.
Related Issues (20)
- Use standard `exports` in `package.json` HOT 3
- __importDefault method may return an object with undefined default property HOT 2
- __assign is not a function
- Type 'boolean' is not assignable to parameter of type '(false | Observable<false>) & (true | Observable<true>) HOT 1
- CI: set minimal permissions for GitHub Workflows HOT 1
- TypeError: (0 , tslib__WEBPACK_IMPORTED_MODULE_0__.__rest) is not a function HOT 1
- [2.5.1][Regression] imported helper named '__decorate' does not exist in 'tslib' HOT 6
- ERROR in bundle from UglifyJs Unexpected token: punc (,) HOT 8
- Regression in [email protected] when using private fields i.c.m. with ESM HOT 3
- Cannot find module '...node_modules/tslib/modules/index.js' imported from chunks/app/server.mjs HOT 2
- Generate SLSA Build L3 provenance HOT 4
- tslib >=2.5.1 regression - increases bundle size caused by noop `Object.create;` statements
- calls to tslib __setFunctionName fail on Cobalt 9 HOT 5
- Suggest an dependabot to keep GitHub Actions updated HOT 1
- Regression failure upgrading from 2.5.0 to 2.5.1+, webpack fails to transpile new export statement for ES5. HOT 1
- Performance improvement HOT 2
- The spread (...) syntax allows an string,but __spreadArray does not support string. HOT 2
- Why do I get compilation results of tslib imports containing native absolute path? HOT 2
- this appears to be a dev-dependency, but the instructions point it to be a dependency 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 tslib.