#Is there an easy 'Sane TypeScript Starter' configuration for a NodeJS application?
33 messages · Page 1 of 1 (latest)
every project is unique, there are so many use cases
front-end, back-end
so there is no single configuration that fits all
and thuse not "official" config either
I vaguely assumed that the frontend / backend would be the only two options.
As the main things I'm configuring are stuff like export format, etc.
just run tsc --init and change the options according to your needs
there aren't that many options, it should be pretty straight forward
I can give you a minimal config tho if you want
That'd be really useful if you have one lying around for NodeJS.
Greenfield project, targeting a modern (v16+) version.
the default options given by tsc --init should be good enough 🤔
The 'commonjs' default for module output surprised me.
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "dist"
"strict": true
},
"include": [
"src/**/*"
]
}
it's all you need really
Will I not run into issues with ESM only modules?
E.g. most of Sindre's https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
that's a bit more advanced that just the bare minimum
(Am not sure why I'm asking when I could just test it out, but do really appreciate your expertise.)
I don't think you can import an ESM-only module in commonjs mode
tho the opposite is possible
Are esm imports not the default / assumed strategy now?
The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
this basically
not really
lots of packages are still written for commonjs
since npm was intended for node
and not web stuff
So sad. I worked on one of the initial proposals for ESM.
and since node only supported cjs at the time
I mean, you can still use ESM just fine
just that you might have to use external tools
note this guide is intended to author libraries
not consume them