Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.
/ esm-nx-example Public archive

An example repo showing a basic use case of NX + ESM being used, with multiple libraries referencing each other, and tests

License

Notifications You must be signed in to change notification settings

zoe-codez/esm-nx-example

Repository files navigation

Zoe-Codez NX+ESM+Node20+Kitchen Sink Example Repo

Description

This is a highly tweaked take on the a fresh nodejs project built on top of nx. Generated on 2024-01-01.

It is intended to target node 20, and install the latest versions of dependencies. TSConfig & linting has been set up very aggressively, feel free to relax to your preferences.

Things that have been validated working

  • proper library inheritance
  • unit tests
  • linting
  • spell checking
  • prettier
  • vscode features & extensions

Haven't tested

  • running applications + related vscode debugging features

Running the applications probably shouldn't be too difficult, based off the notes below. I have a POC nx + vscode node debugging in another repo, will integrate here when I get it tested.

Repo Root: Landmarks

  • lots of options making things more strict
  • set up @library/path mappings to a base index file inside your library
  • add references to all the root tsconfig files in your own projects
  • spellchecking, integrated through eslint
  • keep an eye on the various parser, parserOptions, and env through the file
  • files needs to be correctly targeted
  • barrel files cannot export from other barrel files. be careful about creating nested definitions

Example Libraries

Libraries have been set up with an inheritance of

  • utilities (bottom)
  • data-processing (middle)
  • thing (inherits both)

Utilities

Bottom level library, no imports

TSConfig

Support Files

  • package.json: note the type: module, and the name matching the import path
  • jest.config.ts: added transforms, ignorePatterns (you may have to adjust further based on your needs), and file extensions
  • project.json: updates to extensions & file paths, nothing dramatic
  • .eslintrc.json: note the parser & parser options, each has a different tsconfig to support the linting

utilities/src/

  • index.mts: This file is the root exports for the repo

Data Processing

Intermediate library, imports from utilities

  • tsconfig.json: additional references to external tsconfig lib files. don't care about external specs
  • tsconfig.lib.json: additional references
  • tsconfig.spec.json: references! also, this shows some library specific loosening of restrictions for typescript for tests

API Utils

Top level library, imports from both other libraries. Important files are the same, but just more references to deal with for tsconfig

About

An example repo showing a basic use case of NX + ESM being used, with multiple libraries referencing each other, and tests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published