I am trying to use requirejs-rails in my rails project and I am running into problems with it. I have added the gem and ran bundle install, but I am unable to actually require a file. My relevant files are:
application.js
// = require require
require(['jquery'], function($) {
'use strict';
// Your awesome javascript goes here!
// **********************************
// This is just some guff to help you prove that everything works.
// You can and should delete this once everything works.
console.log('Successfully loaded jQuery version: ' + $('body').jquery);
if (typeof $.rails === 'object') {
console.log('The $ object seems to have been decorated by Rails UJS successfully.');
}
else {
console.log('Uh-oh, it seems that $ has not been decorated by Rails UJS. You might want to check this.');
}
// **********************************
});
and it gives me ReferenceError: Can't find variable: exports and TypeError: undefined is not a constructor (evaluating 'new antlr4.InputStream(input)')
If I change the head of application.html.erb, to the following:
I am trying to use requirejs-rails in my rails project and I am running into problems with it. I have added the gem and ran
bundle install
, but I am unable to actually require a file. My relevant files are:application.js
head of application.html.erb
Then where I am trying to use it:
My app/assets/javascripts/foo/antlr4/index.js looks like the following
and it gives me
ReferenceError: Can't find variable: exports
andTypeError: undefined is not a constructor (evaluating 'new antlr4.InputStream(input)')
If I change the head of application.html.erb, to the following:
It just gives me
ReferenceError: Can't find variable: exports
. Can anybody help with this issue? I might of included things incorrectly