Skip to content

Commit

Permalink
fix: filter .d.ts files from default loader strategy (#128)
Browse files Browse the repository at this point in the history
* fix: filter `.d.ts` files from default loader strategy

* chore: committing fixes in the dark, seriously, who killed my power!?

permalink: http://whatthecommit.com/8684111065712cdc2d7894945c201e4b

* chore: asd
  • Loading branch information
favna committed Oct 17, 2021
1 parent 9f59919 commit 0a7c4ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/strategies/LoaderStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { classExtends, isClass } from './Shared';
export class LoaderStrategy<T extends Piece> implements ILoaderStrategy<T> {
public clientUsesESModules = getRootData().type === 'ESM';
public supportedExtensions = ['.js', '.cjs', '.mjs'];
private readonly filterDtsFiles: boolean = false;

public constructor() {
/**
Expand All @@ -28,6 +29,7 @@ export class LoaderStrategy<T extends Piece> implements ILoaderStrategy<T> {
*/
if (Reflect.has(process, Symbol.for('ts-node.register.instance')) || !isNullish(process.env.TS_NODE_DEV)) {
this.supportedExtensions.push('.ts');
this.filterDtsFiles = true;
}
}

Expand All @@ -36,6 +38,8 @@ export class LoaderStrategy<T extends Piece> implements ILoaderStrategy<T> {
const extension = extname(path);
if (!this.supportedExtensions.includes(extension)) return null;

if (this.filterDtsFiles && path.endsWith('.d.ts')) return null;

// Retrieve the name of the file, return null if empty.
const name = basename(path, extension);
if (name === '') return null;
Expand Down

0 comments on commit 0a7c4ac

Please sign in to comment.