Use import statements without ECMAscript module?

Hi,

can I use import statements without using the ECMAscript module? the reason is that I want to integrate Qlik Sense in meteor. But Qlik Sense already uses a custom enhanced version of require.js to load its files. Note that it is a custom version of require. So I now put this qlik require.js file in my client/lib/compatibility folder and that works. please note that I NEED TO USE THIS REQUIRE,JS file, otherwise I can’t integrate Qlik sense. and the problem is that both Qik sense and common js use the require key word.

`myQlik = function myQlik(callback) {  
    require.config({
        baseUrl: (qConfig.isSecure ? "https://" : "http://") + qConfig.host + (qConfig.port ? ":" + qConfig.port : "") + qConfig.prefix + "resources"
    });

require(["js/qlik"], function(qlik) {
    qlik.setOnError(function(error) {
        sAlert.error(error.message);
    });


    callback(qlik, qConfig);
    

});

`

Except that I can’t use NPM and the import statement?

I would love to use NPM packages too to do Single Sign on for example using the Qlik-auth package

I now get the error that import is a reserved keyword. if I use import qlikauth from ‘qlik-auth’; in line 1 of the file.

Did you try using the modules package?

Yes I did, the problem is that require is a key word of COMMON JS,

and the module I try to reload is being called require too. So how can I load this?

The code below did not work for some reason…

I thought I could just rename var QRequire = require(require.js) But this does not do the trick

//const Promise = require('bluebird');
module.exports = (function() {
    return new Promise(function(resolve, reject) {
        
        /**
         * Using the script loader to execute requirejs in global scope.
         */
        require(['./require'], function(r) {
        	console.log(r);
            r.config({
                baseUrl: 'https://branch.qlik.com/resources'
            });
            
            /**
             * This will load the js/qlik module using requirejs
             * In this case we aren't bundeling it but instead loading it straight from the Qlik Server.
             */
            r(['js/qlik'], function(qlik) {
                /**
                 * The Qlik module has been loaded and we resolve the promise with it.
                 */
                resolve(qlik);
            })
            
        });
        
    })
})();

Anyone please?

How can you import a lib that already uses the key word require?

Thanks!

https://requirejs.org/docs/faq-advanced.html#rename

1 Like