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

parcel-resolver-tspaths

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-resolver-tspaths

Supports tsconfig paths in Parcelv2.

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

parcel-resolver-tspaths

Parcel does not make use of tsconfig.json to resolve path aliases, and instead uses package.json (reference). This Parcel v2 plugin enables typescript path alias resolution as you would normally expect with webpack or otherwise. As a bonus, intellisense will continue to provide suggestions from your tsconfig.

Installation (~3.1kB minified, 0 dependencies)

  • yarn add -D parcel-resolver-tspaths

    or

    npm install --save-dev parcel-resolver-tspaths

  • Ensure all parcel packages are set to minimum version ^2.0.0 and that Parcel is configured for Typescript.

  • In your .parcelrc, be sure to properly extend the default config and add the plugin to your resolvers like so:

    "extends": "@parcel/config-default",
    "resolvers": ["...", "parcel-resolver-tspaths"],
    "transformers": {
      "*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
    },
    "validators": {
      "*.{ts,tsx}": ["@parcel/validator-typescript"]
    },
    

And that's it. Note: the order of resolvers is sequential, and I highly recommend keeping this resolver after the base resolvers due to parcel bugs.

If you're lazy like me, you might be interested in my package that auto-generates your tsconfig paths as you code. You can read more about tsconfig-paths-autogen here.

Caveats

  • This plugin does not support Typescript aliases while importing non-code assets, but this is being considered for future development.

    For example:

    import logo from 'url:@myassets/image/logo.svg';
    
  • Please file an issue if you notice any bugs. Thanks!

Development

Clone this repo anywhere, then run yarn && yarn link in the project root.

In any parcel app, run yarn && yarn link parcel-resolver-tspaths. Then follow normal build procedures. Real tests coming soon.

If you run into issues viewing verbose output, you can see all raw output by running yarn test |& cat (Mac/Linux users only).

Keywords

FAQs

Package last updated on 02 May 2022

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