New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sprucelabs/path-resolver

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sprucelabs/path-resolver

Enables support for paths in the compiler options of your tsconfig file.

  • 1.3.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

@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.

Keywords

FAQs

Package last updated on 03 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc