Skip to content

Commit

Permalink
feat: add extension option to support ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
c-eberling committed Oct 12, 2021
1 parent 6ba1db5 commit fee9c7c
Show file tree
Hide file tree
Showing 42 changed files with 256 additions and 68 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ than recursively searching child directories.

### `-n [name]` or `--name [name]`

Specifies the name to use for creating new barrels (and identifying old ones). `.ts` wil be
Specifies the name to use for creating new barrels (and identifying old ones). `.ts` will be
appended if not included in the name. Barrels names will be defaulted to `index.ts`.

### `-s [mode]` or `--structure [mode]`
Expand Down Expand Up @@ -212,6 +212,16 @@ Display the barrelsby version number.

Display additional debug information.

### `-x [extension]`or `--extension [extension]`
Add extension suffix to exports (e.g. '.js'). Useful for ESM modules.

```TypeScript
// Without --extension .js
export * from "./Slider";
// With --extension .js
export * from "./Slider.js";
```

## Requirements

Requires node v6.0.0 or greater for ES6 syntax.
Expand Down
1 change: 1 addition & 0 deletions barrelsby
Submodule barrelsby added at f29f01
3 changes: 2 additions & 1 deletion barrelsby.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"structure": "filesystem",
"verbose": true,
"include": [".ts$"],
"exclude": ["zeta.ts$"]
"exclude": ["zeta.ts$"],
"extension": ""
}
6 changes: 3 additions & 3 deletions bin/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { SemicolonCharacter } from "./options/noSemicolon";
import { StructureOption } from "./options/options";
import { QuoteCharacter } from "./options/quoteCharacter";
import { Directory, Location } from "./utilities";
export declare function buildBarrels(destinations: Directory[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, barrelName: string, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, structure: StructureOption | undefined, local: boolean, include: string[], exclude: string[]): void;
export declare type BarrelBuilder = (directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean) => string;
export declare function buildBarrels(destinations: Directory[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, barrelName: string, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, structure: StructureOption | undefined, local: boolean, include: string[], exclude: string[], extension: string): void;
export declare type BarrelBuilder = (directory: Directory, modules: Location[], quoteCharacter: QuoteCharacter, semicolonCharacter: SemicolonCharacter, logger: Logger, baseUrl: BaseUrl, exportDefault: boolean, extension: string) => string;
/** Builds the TypeScript */
export declare function buildImportPath(directory: Directory, target: Location, baseUrl: BaseUrl): string;
export declare function buildImportPath(directory: Directory, target: Location, baseUrl: BaseUrl, extension: string): string;
/** Strips the .ts or .tsx file extension from a path and returns the base filename. */
export declare function getBasename(relativePath: string): string;
16 changes: 9 additions & 7 deletions bin/builder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/builder.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions bin/builder.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fee9c7c

Please sign in to comment.