2

I am doing a code reorganization and am rewriting some of my TypeScript modules that will likely be used by several microservices as packages.

Unfortunately, it seems that using absolute imports enabled by baseUrl does not play nicely with this package conversion. For example, I used to import { Thing } from "Place/That/I/Know"; where "Place/That/I/Know/" was really "src/Place/That/I/Know/" Now, this results in a Module not found error.

I would like to use Rollup.js to convert absolute imports, "Place/That/I/Know/", to relative imports "./Place/That/I/Know/". I've found this answer. But, it seems inconclusive. Any suggestions?

lmonninger
  • 831
  • 3
  • 13
  • Make them npm packages. Then install them with npm install and import them by name. Don't waste your time fooling around with paths. If you don't have a private registry and don't want to publish them to the public registry, npm can install from a git url. – Jared Smith Aug 15 '21 at 01:26
  • @JaredSmith npm installing from GitHub is exactly how I've been doing it. That's where I've encountered the error. – lmonninger Aug 15 '21 at 02:07
  • Then fix your package.json – Jared Smith Aug 15 '21 at 02:50
  • @JaredSmith How? What do I need to set to enable absolute imports when this is a package installed in node_modules? – lmonninger Aug 15 '21 at 03:31
  • https://bytearcher.com/articles/main-property-in-package.json-defines-entry-point/ – Jared Smith Aug 15 '21 at 11:03

0 Answers0