0

I am wondering if there is a Node.js equivalent to importing client side code without them having to be a module, an equivalent to Rhino's load():

  load('to-title-case.min.js');
  load('to-title-case-tests.js');
  print(titleCase); // A string from to-title-case-tests.js

Is there a simple way of doing this with Node (either build-in or a available module) or do I have to do it with node-jsdom?

Thanks.

  • 1
    I would use a module.... but as an exercise only (!): `require('fs').readFile('file.js', 'utf-8', function(err, data) { eval(data); });` – Xeon Jul 16 '15 at 22:58
  • Thanks, will try. Its only really for a trivial test for a TypeScript definition, so I can probably get away with that. – Sam Saint-Pettersen Jul 16 '15 at 23:04

0 Answers0