Comments (6)
I just noted that you listed typescript as part of the deps
from cjstoesm.
Yes, typescript is a peer dependency and usage is documented here
from cjstoesm.
Hello,
require
d dependencies should be listed as dependencies
and not as peerDependencies
(source).
Please fix it accordingly.
Thanks
from cjstoesm.
@KaKi87,
Hi there.
I'm afraid you're misunderstanding or misinterpreting peer dependencies, how and when they're used, and why, including from the source you linked to.
The reason why libraries may declare a non-optional dependency as a peer dependency and not as a hard dependency is to allow consumers to use whatever version of the related package they want.
For optional peer dependencies, you can use peerDependenciesMeta
and declare them as optional.
For example, if a library such as cjstoesm
depended on something like typescript: ^4.6.3
, that would force consumers of the library to depend on at least v.4.6.3 of TypeScript, even though they may be using another TypeScript version internally. Instead, cjstoesm
supports any TypeScript version from v3.2 and up, and that makes it possible for you to use whatever TypeScript version you're targeting internally without being forced to update to the latest build.
from cjstoesm.
The reason why libraries may declare a non-optional dependency as a peer dependency and not as a hard dependency is to allow consumers to use whatever version of the related package they want.
Actually, the fact that your project would depend on a specific version of a package doesn't prevent the user from adding a different version of that package as a direct dependency.
EDIT: you could also use *
if you wanted to make sure of it.
from cjstoesm.
Hi again.
Again, I want to reiterate that peer dependencies are not optional dependencies, as your comment seems to imply. You can, however, annotate them as such with peerDependenciesMeta
as a library author if your package declares dependencies that the consuming user may only optionally install. TypeScript, however, is a required peer dependency of cjstoesm
.
Please consult the official documentation or any of the existing great articles you can find online explaining when you may want to use peer dependencies, and when not to.
from cjstoesm.
Related Issues (20)
- Cannot run with npx HOT 2
- Preserve white-space HOT 3
- Preserve Comments HOT 5
- Doesn't work: missing outdir HOT 2
- Programmatic usage produces empty output HOT 3
- Does cjstoesm get dependent sources from node_modules (am I using it correctly)?
- Provide API method to transform a source code string HOT 3
- Improper transform on module.exports = { a: require('./b') }
- Option to convert exported objects into individual exports
- Support for direct in-place replacement? HOT 2
- Cannot read property 'text' of undefined HOT 10
- Support import assertions HOT 1
- Usage documentation is unclear HOT 2
- Issue when trying to transform module.exports with object
- package creates variable names starting with numbers
- Hi HOT 1
- feature request: move requires at bottom of file to top
- CategoryInfo : ObjectNotFound: (cjstoesm:String) [], CommandNotFoundException
- Error: Debug Failure. Unhandled SyntaxKind: ImportClause. HOT 4
- Doesn't work with newer TypeScript versions HOT 3
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 cjstoesm.