All Projects → dropbox → Ts Transform Import Path Rewrite

dropbox / Ts Transform Import Path Rewrite

Licence: apache-2.0
TS AST transformer to rewrite import path

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ts Transform Import Path Rewrite

Ts Transform Css Modules
Extract css class names from required css module files for TypeScript
Stars: ✭ 75 (-27.88%)
Mutual labels:  compiler, ast, transform
Exprtk
C++ Mathematical Expression Parsing And Evaluation Library
Stars: ✭ 301 (+189.42%)
Mutual labels:  compiler, ast
unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 119 (+14.42%)
Mutual labels:  ast, import
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+444.23%)
Mutual labels:  compiler, ast
ts-transform-react-constant-elements
A TypeScript AST Transformer that can speed up reconciliation and reduce garbage collection pressure by hoisting React elements to the highest possible scope.
Stars: ✭ 44 (-57.69%)
Mutual labels:  ast, transform
ts-transform-react-jsx-source
TypeScript AST Transformer that adds source file and line number to JSX elements
Stars: ✭ 12 (-88.46%)
Mutual labels:  ast, transform
Tiny Compiler
A tiny compiler for a language featuring LL(2) with Lexer, Parser, ASM-like codegen and VM. Complex enough to give you a flavour of how the "real" thing works whilst not being a mere toy example
Stars: ✭ 425 (+308.65%)
Mutual labels:  compiler, ast
Llvm Guide Zh
User Guides For those new to the LLVM system.(LLVM系统的新用户指南,中文翻译版)
Stars: ✭ 180 (+73.08%)
Mutual labels:  compiler, ast
Modiscript
Acche din aa gaye
Stars: ✭ 888 (+753.85%)
Mutual labels:  compiler, ast
Bentools Etl
PHP ETL (Extract / Transform / Load) library with SOLID principles + almost no dependency.
Stars: ✭ 45 (-56.73%)
Mutual labels:  import, transform
Charly Vm
Fibers, Closures, C-Module System | NaN-boxing, bytecode-VM written in C++
Stars: ✭ 66 (-36.54%)
Mutual labels:  compiler, ast
ember-cli-es6-transform
Import ES6 modules from npm, bower or anywhere else in your app.
Stars: ✭ 13 (-87.5%)
Mutual labels:  import, transform
Cub
The Cub Programming Language
Stars: ✭ 198 (+90.38%)
Mutual labels:  compiler, ast
konan
find all require/import calls by walking the AST
Stars: ✭ 48 (-53.85%)
Mutual labels:  ast, import
Snapdragon
snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory.
Stars: ✭ 180 (+73.08%)
Mutual labels:  compiler, ast
Ratel Core
High performance JavaScript to JavaScript compiler with a Rust core
Stars: ✭ 367 (+252.88%)
Mutual labels:  compiler, ast
Phplrt
PHP Language Recognition Tool
Stars: ✭ 127 (+22.12%)
Mutual labels:  compiler, ast
Lioness
The Lioness Programming Language
Stars: ✭ 155 (+49.04%)
Mutual labels:  compiler, ast
Tiny Compiler
A tiny evaluator and compiler of arithmetic expressions.
Stars: ✭ 680 (+553.85%)
Mutual labels:  compiler, ast
Pyast64
Compile a subset of the Python AST to x64-64 assembler
Stars: ✭ 93 (-10.58%)
Mutual labels:  compiler, ast

ts-transform-import-path-rewrite

build status

This is a TypeScript AST Transformer that allows you to rewrite import path in output JS & d.ts files accordingly. The primary use case for this is to mitigate different build system import structure, such as relative vs absolute import and aliasing output import paths.

Usage

ttypescript

Example for ttypescript usage is in examples/ttypescript. Run npx ttsc.

Compiler Wrapper

First of all, you need some level of familiarity with the TypeScript Compiler API.

compile.ts & tests should have examples of how this works. The available options are:

projectBaseDir: string

This is the base directory of your project folder. This is primarily used to determine the correct path when rewriting relative import to absolute import.

project?: string

Project name to rewrite relative import to. For example:

import foo from './foo'
// Becomes
import foo from 'my-project-name/foo'

rewrite?(importPath: string, sourceFilePath: string): string

Custom rewrite function to rewrite any import path we encounter to any new import path.

alias?: Record<string, string>

Alias regex map to replace, e.g:

{
    "^(foo)$": "external/$1"
}

License

Copyright (c) 2018 Dropbox, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].