reexport
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

reexport

Experimental utility to automate reexporting TypeScript in index.ts files. Primary target is TypeScript but it should work for any language with // comments.

Insert comment instructions // @reexport glob/pattern/*.tsx in place where you want to reexport such files and this utility will reexport all matching files.

https://user-images.githubusercontent.com/316435/204151619-0606e4d0-df19-4000-b475-dcdc72e3b101.mov

Usage

Your index.ts looking like this:

// @reexport ./*.{ts,tsx}

With directory like this:

./index.ts
./Alice.tsx
./Bob.ts

Running this:

npx reexport ./index.ts

Will generate this:

// @reexport ./*.{ts,tsx}
export * from './Alice'
export * from './Bob'
// @end-reexport

Installation

npm install reexport

CLI usage

npm i -g reexport

reexport "./src/**/index.{ts,tsx}"

NPX usage

npx reexport "./src/**/index.{ts,tsx}"

Node.js usage

import { reexport } from 'reexport'

reexport({ files: ['./index.ts'], watch: true })

Features

  • watch mode --watch
  • glob matching reexport "**/index.{ts,tsx},something.js"
  • verbose mode -v | more verbose -vv | even more verbose -vvv

Custom reexport outputs

Define outptu pattern after colon (:) symbol.

Available variables

path/to/File.suffix.tsx
$BASENAME $PATH $TS_PATH $NAME $SAFE_NAME $EXT
File.module.tsx path/to/File.module.tsx path/to/File.module File.module d .tsx

Examples

// @reexport ./*.{ts,tsx}:export * from './$TS_PATH'
export * from './Alice'
export * from './Bob'
// @end-reexport

const things = {
	// @reexport ./*.{ts,tsx}:	$SAFE_NAME: () => import('./$TS_PATH'),
	Alice: () => import('./Alice'),
	Bob: () => import('./Bob'),
	// @end-reexport
}

Readme

Keywords

none

Package Sidebar

Install

npm i reexport

Weekly Downloads

2

Version

1.4.1

License

Apache-2.0

Unpacked Size

42.6 kB

Total Files

55

Last publish

Collaborators

  • viliamkopecky