Generic JavaScript View - Include multiple dependencies

Hi Community,

I have another problem regarding generic javascript views and the import of a js-file :zipper_mouth_face:
I tried to do the same as with my previous question

but cannot get it to work with knime :frowning:

With just normal html files it seems to be quite easy
working with just script.txt (3.2 KB) working but not on the server.txt (5.1 KB)
but does not seem to work within KNIME:
QueryBuilder tries.knwf (319.0 KB)

Does anyone have an idea how to get this library to work within the Gernic Javascript View:

Thanks in advance!

I agree that it can be cumbersome to get this to work. Most of the time, the problem is that the Asynchronous Module Definition hijacks the module. I circumvent this by manually defining module and exports objects, then create a require function that returns exactly what the imported module needs and reset everything again after the module has loaded. Also, I usually load external dependencies via GET Request node and then insert them via flow variable. The code in the Generic JS View looks like this:

var module = {};
var exports = {};
module.exports = exports;

// Mock the require call to return jquery
var def = define;
var req = require;
define = null;
require = function() {
	return $;	
// Reset
define = def;
require = req;

I attached a workflow where the library (the version with all dependencies) is used in the Generic JS View.
Kind regards,

querybuilderjs.knwf (32.9 KB)


Hi @AlexanderFillbrunn,

thank you for your help and your explanation. :slight_smile:
This made my day! :partying_face:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.