Open chiubaka opened 2 years ago
Since a lot of the difference between these library packages is likely to be in tsconfig.json
, I'm doing a quick comparison of typical working configurations for each project type.
Microsoft actually has a few starter project examples. Though they're archived and a few years old, I think they're probably still helpful here:
Some options that seem to be common across all projects:
module
is always set to commonjs
moduleResolution
is always set to node
Here are some notable differences:
"lib": ["dom"]
, since browser APIs should be present"jsx": "react"
Honestly, that's kind of it. I'm a bit surprised TBH.
Ah, this is a better and more up-to-date resource for common TS configurations: https://github.com/tsconfig/bases#centralized-recommendations-for-tsconfig-bases
Ok, target
should potentially be changed based on the runtime environment, since this option changes how much of the code is down-leveled for compatibility. ES2015
(aka ES6
) seems like the safest target for compatibility if building for the web. Otherwise, for environments like Node.js and React Native, compatibility is really more a function of the platform version than it is of the user's device or browser configuration, so matters less there.
Can potentially use the jsx: "react-native"
option for React Native, as presumably FB's React Native compilers understand JSX and can do some of their own optimizations if this isn't down-leveled to something else.
Actually the differences between a backend, Node-compatible library, and a general, shareable library, are pretty minute. A Node-compatible library likely needs to list a node
version as a peerDependency
, and then set the TS target to something sensible for the version of Node I generate for (I think we're going to target Node v18).
Bumping this so that it doesn't appear stale for import into Linear.
(Copying from a comment on #39.)
Excitingly, starting work on this today. Types of libraries I expect to have:
Mostly the difference between these will be the base:
tsconfig.json
)react
)tsconfig.json
options)