1.3.4 • Published 4 years ago

@sprucelabs/path-resolver v1.3.4

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

@sprucelabs/path-resolver

Add runtime support for the compilerOptions.paths of your tsconfig.json.

Installation

yarn install @sprucelabs/path-resolver

or

npm install @sprucelabs/path-resolver

And include this line at the top of your app:

import "@sprucelabs/path-resolver/register";

That's all!

Options

  • cwd:string - Where to start looking for your tsconfig.json. Will look up one directory at a time until it finds one or throws an Error. NOTE: Make sure your tsconfig.json is being bundled with your project when building/deploying.
  • extensions:string[] - Extensions you want to load, defaults to Module.extensions, must have dot in them .js, .ts.

Example tsconfig.json

{
	"compilerOptions": {
		"baseUrl": "",
		"outDir": "build",
		"paths": {
			"#alias": ["new/path/relative/to/baseUrl"],
			"#aliasWithWildcard/*": ["new/path/one/*", "new/path/two/*"]
		}
	}
}

Example import

import path from "path";
import "@sprucelabs/path-resolver/register";

import MyThing from "#alias";
import { somethingElse } from "#aliasWithWildcard/path/passed/through";

Why not use tspaths-config?

This module works almost exactly the same, but when resolving modules it checks the outDir first, then falls back to checking the local directory. It also checks for all file extensions.

In other words, path-resolver works with ts-node and without and with built projects and without, all with one line of code.

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.13

5 years ago

1.0.11

5 years ago

1.0.12

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago