rwu823 / require-hooks

Node require hooks
https://github.com/rwu823/require-hooks
7 stars 0 forks source link

Some filenames with dots are incorrectly interpreted as being file extensions #1

Open w0rp opened 6 years ago

w0rp commented 6 years ago

I work on an AngularJS codebase with TypeScript which uses ts-node and tsconfig-paths for testing. We have filenames like app/components/whatever.component.ts, which is imported as 'app/components/whatever.component'. These filenames match recommend AngularJS standards, but break requireHooks, which interpret the filenames as being extensions.

My recommended solution is to allow the hooks to be configured with a whitelist for file extensions for passing other file extensions on to whatever other mechanisms are available.

w0rp commented 6 years ago

https://github.com/rwu823/require-hooks/blob/1ee3d2abaa5e404344be0f66d418717975c058c2/src/index.js#L21 That's the offending line.