zaach / jison

Bison in JavaScript.
http://jison.org
4.36k stars 450 forks source link

Check for Node’s fs and path before trying to use them #339

Open GeoffreyBooth opened 7 years ago

GeoffreyBooth commented 7 years ago

lrGeneratorMixin.generateCommonJSModule generates some code that is intended to run in a CommonJS environment, within which it takes for granted that Node’s fs and path will be available. This may not necessarily be the case, as is demonstrated in https://github.com/jashkenas/coffeescript/issues/4391. We should simply check that require('fs') and require('path') are defined before we try to use them.

GerHobbelt commented 7 years ago

related: #320

GeoffreyBooth commented 7 years ago

There’s a workaround, per https://github.com/jashkenas/coffeescript/pull/4546:

var parser = require('./lib/coffeescript/grammar').parser.generate({
  moduleMain: function() {}
});