Created by @DaroshCZ in Q&As
@DaroshCZ
@DaroshCZ

Hello, I tried integrate Nittro over webpack. But I have problem with create custom ajax request. Nitrro is imported over script-loader. Script-loader imported of module with global kontext.

_context is global variable. After called function page.open is result of error.

VM2291:1962 Uncaught (in promise) TypeError: Cannot read property 'slice' of undefined at eval (eval at push../node_modules/script-loader/addScript.js.module.exports (addScript.js:20), <anonymous>:1962:37) at tmp.trigger (eval at push../node_modules/script-loader/addScript.js.module.exports (addScript.js:20), <anonymous>:1975:8) at tmp._handleError (eval at push../node_modules/script-loader/addScript.js.module.exports (addScript.js:20), <anonymous>:4430:159)

Example code in webpack:

import 'script-loader!./../../../../../bower_components/nittro-essentials/dist/nittro.min.js'; // eslint-disable-line global._context.invoke(function (di) { console.log(di); let page = di.getService('page'); console.log(page); page.open('http://localhost:88/dev.styleguide.index'); });

// Result in console

// console.log(di) context.extend.hasParam {: {…}}_: {params: {…}, serviceDefs: {…}, services: {…}, factories: {…}}proto: Object nitro.js:21

// console.log(page) tmp {: {…}}: {snippetManager: tmp, history: tmp, options: {…}, setup: true, currentTransaction: null, …}proto: Object

// page.open('http://localhost:88/dev.styleguide.index') VM2291:1962 Uncaught (in promise) TypeError: Cannot read property 'slice' of undefined at eval (eval at push../node_modules/script-loader/addScript.js.module.exports (addScript.js:20), <anonymous>:1962:37) at tmp.trigger (eval at push../node_modules/script-loader/addScript.js.module.exports (addScript.js:20), <anonymous>:1975:8) at tmp._handleError (eval at push../node_modules/script-loader/addScript.js.module.exports (addScript.js:20), <anonymous>:4430:159)

@jahudka
@jahudka

Hi, I'm sorry about that, but I have no experience integrating Nittro with Webpack - I have no idea what might be wrong. One thing I'd recommend is that you ditch Bower, install the Nittro packages via NPM and do a custom build - the Bower packages are mostly unmaintained now, using NPM you'll always get the latest versions of everything. Your issue might be (and probably is) unrelated though..

Sign in to post a reply