Method: NodeJS::Module#require_function
- Defined in:
- lib/nodejs/module.rb
#require_function ⇒ Object
Used to require both script files and modules Script path is relative from base path and defines where the require function will begin looking for require()‘d js-files script_path is ignored when requiring modules, i.e. require(“jade”)
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nodejs/module.rb', line 14 def require_function lambda do |*args| this, module_id = *args module_id ||= this #backwards compatibility with TRR < 0.10 return @environment.require(module_id) if NodeJS.builtins.keys.include?(module_id) #puts "requiring #{module_id} from #{CommonJS.resolve(@file.dirname, module_id).to_s}" @environment.require(NodeJS.resolve(@file.dirname, module_id).to_s) end end |