ractivejs / ractive-load

Import templates and components using AJAX
ractivejs.github.io/ractive-load
MIT License
55 stars 10 forks source link

require - resolve relative paths #5

Closed MartinKolarik closed 10 years ago

Rich-Harris commented 10 years ago

I don't totally follow what's going on here - when wouldn't the standard require() path resolution work?

MartinKolarik commented 10 years ago

With relative paths like ./module/file.js. While ./ usually refers to process.cwd(), with require() it's relative to the file calling require() - that is useful in most cases, but in this case it means we would have to use paths relative to node_modules/ractive-load/.

Rich-Harris commented 10 years ago

ah, got you. Wouldn't you want the path to be relative to the component definition file though? (Genuine question.) Also, would this work on Windows, or would we need to use path.join() instead?

dependency = require( path.join( process.cwd(), name ) );
MartinKolarik commented 10 years ago

Wouldn't you want the path to be relative to the component definition file though?

That would make sense. The question is, how do we know the path of the component definition?

Also, would this work on Windows, or would we need to use path.join() instead?

Windows supports both / and \. path.join() is useful when you don't know if there is a trailing slash or not and/or when dealing with certain command line tools (these can have problems with using /), but in most cases simple string concentration is fine.

MartinKolarik commented 10 years ago

Btw, can you npm publish please?

Rich-Harris commented 10 years ago

done - bumped version to 0.2.3

MartinKolarik commented 10 years ago

Thanks.