esperantojs / esperanto

DEPRECATED: An easier way to convert ES6 modules to AMD and CommonJS
http://esperantojs.org
234 stars 21 forks source link

preserve .js extension in external modules #155

Closed Rich-Harris closed 9 years ago

Rich-Harris commented 9 years ago

Previously, esperanto would always strip .js from module import paths, because these...

var foo = require( './foo' );
var foo = require( './foo.js' );

...are equivalent in CommonJS-land. (Does the ES6 module spec have an opinion about this? I couldn't find a reference.)

However that's not the case for external modules, which causes problems when creating bundles that import packages like highlight.js. This PR keeps the existing behaviour for relative module paths, but preserves the .js for external modules. Any opinions to the contrary before I merge it?