Giter Club home page Giter Club logo

go-tspath's Introduction

Go TSPath Build Status codecov Go Report Card GoDoc

A fast Typescript paths replacer written in Go. โšก

go-tspath replaces directly Typescript paths aliases into JS files with real paths based on tsconfig.json, no more runtime replacers.

go-tspath performing replacements in a production Typescript code base

Screenshot of go-tspath performing replacements in a Typescript code base project with more than 200 JS files and around 5857 lines of code.

Status

go-tspath was tested replacing custom path aliases in a Typescript medium size project with desired results (shown in screenshot above). But there are some features and more testing cases (community user feedback) to do. So, It can considered as Beta yet. Contributions will be very appreciated.

Installation

๐Ÿš€ Download the latest go-tspath binary for your specific platform at go-tspath/releases.

Usage

# 1. Build TS files via tsc
# 2. Replace TS paths
go-tspath -config=./tsconfig.replace.json
# 3. Just run your app
# node main.js

Known limitations

  • No support for JSON5 format of tsconfig.json. But works using a dedicated tsconfig.json file with your custom path aliases. See sample/tsconfig.replace.json
  • Limited compilerOptions settings. Only baseUrl, paths and outDir are supported. See CompilerOptions struct.
  • No support for tsconfig.json features like extends, exclude or similar.

Typescript code example

See an example at sample directory.

API

~> go-tspath --help
Usage of go-tspath:
  -config string
    	Specifies the Typescript configuration file. (default "./tsconfig.json")

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in current work by you, as defined in the Apache-2.0 license, shall be dual licensed as described below, without any additional terms or conditions.

Feel free to send some Pull request or issue.

License

This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

ยฉ 2019 Jose Quintana

go-tspath's People

Contributors

joseluisq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-tspath's Issues

Does config=tsconfig.replace.json work?

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "allowSyntheticDefaultImports": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es6",
    "sourceMap": true,
    "allowJs": true,
    "outDir": "./dist",
    "skipLibCheck": true,
    "baseUrl":"./src",
    "paths": {
      "common/*": ["../../common/src/*"]
    }
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "src/**/*"
  ]
}
const logger_1 = require("common/logger");

becomes

const logger_1 = require("./../../logger");

Actual code layout is

dist
โ”œโ”€โ”€ common
โ”‚ย ย  โ””โ”€โ”€ src
โ”‚ย ย      โ”œโ”€โ”€ logger.js
โ”œโ”€โ”€ server
โ”‚ย ย  โ””โ”€โ”€ src
โ”‚ย ย      โ”œโ”€โ”€ csp.js

lastly config seems always ignored

go-tspath -config=./tsconfig.replace.json

will produce the same output regardless of the config

Add json flag command

Proposal: Add json flag command to output results in JSON format. Which should be useful for easy integration with other scripting languages like Javascript. This PR depends on #1

Flag: -json

~> go-tspath -config=./tsconfig.json -json
# {"json data with information about the performed job"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.