npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mycrypto-path-alias-resolver

v1.0.5-alpha

Published

Resolve aliases in ts files

Downloads

4

Readme

mycrypto-path-alias-resolver

Resolve aliases in ts files. Useful for when you want to publish a package with the typings file in package.json, as a project consuming your package will not respect your package's baseurl and path mappings. This will convert all path mappings to relative paths.

Installation

npm i -D mycrypto-path-alias-resolver

Caveats

Due to the nature of the regex used to resolve multi-line imports, it currently has the limitation of only working with prettier and the follow configuration file:

{
  "printWidth": 80,
  "singleQuote": true,
  "useTabs": false,
  "semi": true,
  "tabWidth": 2,
  "trailingComma": "all"
}

Also, support for resolving aliased exports such as export * from '@src/ethUnits'; is not implemented

How to use

Let's say you have a project that has its source files in <rootDir>/src, and you want to ignore any *.spec.ts or *.test.ts files.

Example tsconfig.json

{
  "compilerOptions": {
    "outDir": "dist",
    "target": "es2017",
    "sourceMap": true,
    "module": "es2015",
    "baseUrl": "./",
    "lib": ["es2017", "dom"],
    "allowSyntheticDefaultImports": true,
    "paths": {
      "@src*": ["src*"],
      "@test*": ["__test__*"]
    },
    "moduleResolution": "node",
    "noEmitOnError": false,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitThis": true,
    "pretty": true
  },
  "include": ["./src/", "./__test__/"]
}

Example File Tree

├── coverage
├── dist
├── docs
├── gulpfile.js
├── node_modules
├── package.json
├── package-lock.json
├── readme.md
├── rollup.config.ts
├── src
├── __test__
├── tsconfig-build.json
├── tsconfig.json
└── tslint.json

Corresponding script gulpfile.js to use with above setup

const gulp = require('gulp');
const alias = require('path-alias-resolver/gulp');

gulp.task('default', () => {
  return gulp
    .src(['./src/**/*.ts', '!./src/**/*.spec.ts', '!./src/**/*.test.ts'])
    .pipe(alias('.', { '@src': './src' }))
    .pipe(gulp.dest('./dist/lib'));
});

Breaking gulpfile.js down

['./src/**/*.ts', '!./src/**/*.spec.ts', '!./src/**/*.test.ts']

Ignore any *.spec.ts or *.test.ts files while including all other .ts files in src

alias('.', { '@src': './src' })

The first parameter corresponds to your baseUrl setting in tsconfig.json.

The second parameter is an object of mappings from the paths key in tsconfig.json to its value.

gulp.dest('./dist/lib')

Pass the resulting transformed files to ./dist/list