Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to look up loader when an extension is single character. #38

Closed
sttk opened this issue Feb 28, 2021 · 0 comments
Closed

Fails to look up loader when an extension is single character. #38

sttk opened this issue Feb 28, 2021 · 0 comments

Comments

@sttk
Copy link
Contributor

sttk commented Feb 28, 2021

What were you expecting to happen?

Looks up loader successfully when an extension is single character.

What actually happened?

rechoir throws an error of which message is "No module loader found for "undefined". when an extension is single character.

Please give us a sample of your gulpfile for reproduction

// test.js
const config = {                                                                                                                         
  '.coffee': 'coffeescript/register',
  '.co': 'coffeescript/register',
  '.c': 'coffeescript/register',
};
const rechoir = require('rechoir');

console.log(rechoir.prepare(config, './aaa.coffee'));
console.log(require('./aaa.coffee'));

console.log(rechoir.prepare(config, './aaa.co'));
console.log(require('./aaa.co'));

console.log(rechoir.prepare(config, './aaa.c'));
console.log(require('./aaa.c'));

Terminal output / screenshots

$ npm i rechoir coffeescript
$ touch aaa.coffee aaa.co aaa.c
$ node test.js
[ { moduleName: 'coffeescript/register', module: {}, error: null } ]
{}
[ { moduleName: 'coffeescript/register', module: {}, error: null } ]
{}
/path/to/rechoir/bug/node_modules/rechoir/index.js:30                                                                                    
    throw new Error('No module loader found for "' + usedExtension + '".');
    ^

Error: No module loader found for "undefined".
    at Object.exports.prepare (/path/to/rechoir/bug/node_modules/rechoir/index.js:30:11)
    at Object.<anonymous> (/path/to/rechoir/bug/test.js:14:21)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: macOS Big Sur 11.2.1
  • node version (run node -v): v15.5.0
  • npm version (run npm -v): 7.3.0
  • gulp version (run gulp -v): rechoir version: 0.7.0

Additional information

Nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant