express
express copied to clipboard
TypeScript Example (CJS)
The following PR relates to a simple TypeScript implementation using [email protected]
.
Additionally, example (found in examples/typescript
) includes a tsconfig.json
that compiles down to ES5
JavaScript. A merge request I made previously had failed some tests relating to version limitations (node), so this should handle that case.
However, the compiled JavaScript and other generated assets are set to be tracked via VCS (git
). It's of normal operation to usually untrack them via including *.js
in the .gitignore
.
We can later add a .gitignore
in the example folder itself. But I do want to see what the GitHub actions returns with. If appropriate, I'll update/discuss changes to these tests to account for the typescript example.
Discussion
Looking at the other example folders, often they are without README.md
s, package.json
s, etc. etc.
While totally fine, the example this PR relates to, as well as another I have outstanding, perhaps could be exceptions. I know the package maintainers and other contributors see, almost daily, issues & questions relating to ESM, TypeScript, and even both.
Providing examples, like this one, hopefully will make everyone's life a bit easier :D
.
Nice, seems to have passed
@bozzelliandrea, thank you for the feedback; I've since updated with your recommended changes, and point of replacing require
with import
.
Sorry my response took so long, I'll try and get back sooner next time around :D
.
P.S. I updated the tsconfig.json
and package.json
to align much closer to what a standard, default configuration would look like. Notice, too, the latest
package version reference(s).
Using latest
is to avoid (haha hopefully) any technical debt down the road with issues coming through asking to update the typescript
example.
@Segmentational everything looks ok and clean, nice work! 😃
Just my curiosity, what does CJS mean?
@bozzelliandrea, sorry for the delayed response... I just moved halfway across the united states, so that took a little time haha.
Yeah, "CJS
" can be seen in a few odd places in the node
official documentation. The first example, although referenced as a file extension, can be seen here:
- https://nodejs.org/api/modules.html#enabling
I'm unsure of the exact other places, but essentially it's a shorthand sometimes used to describe the commonjs
javascript module type.