Page 1 of 1
Requirejs and stimul
Posted: Tue Feb 05, 2019 9:50 pm
by alireza_s_84
Hi
If we load Requirejs before Stimul then get error. are there any way to use stimul in a requirejs module?
The error is:
Code: Select all
Uncaught ReferenceError: moment_mod is not defined
Re: Requirejs and stimul
Posted: Wed Feb 06, 2019 3:14 am
by Barnaby
Hi, I ran into the same problem, and found a way to get it working.
You need to add and load
momentjs before you load stimulsoft.reports.
I moved it all into requirejs, then made my requirejs config load it in this order: momentjs -> reports -> viewer -> designer
For example
Code: Select all
requirejs.config({
paths: {
"momentjs": '/Stimulsoft/scripts/moment',
"StimulsoftReports": '/Stimulsoft/scripts/stimulsoft.reports',
"StimulsoftViewer": '/Stimulsoft/scripts/stimulsoft.viewer',
"StimulsoftDesigner": '/Stimulsoft/scripts/stimulsoft.designer'
},
shim: {
'StimulsoftDesigner': ['StimulsoftViewer'],
'StimulsoftViewer': ['StimulsoftReports'],
'StimulsoftReports': ['momentjs']
}
});
Then you would just need to define StimulsoftDesigner or StimulsoftViewer.
Code: Select all
require(['StimulsoftDesigner'], function()
{
// use Stimulsoft here
});
Re: Requirejs and stimul
Posted: Wed Feb 06, 2019 9:57 am
by alireza_s_84
Barnaby wrote: ↑Wed Feb 06, 2019 3:14 am
Hi, I ran into the same problem, and found a way to get it working.
You need to add and load
momentjs before you load stimulsoft.reports.
I moved it all into requirejs, then made my requirejs config load it in this order: momentjs -> reports -> viewer -> designer
For example
Code: Select all
requirejs.config({
paths: {
"momentjs": '/Stimulsoft/scripts/moment',
"StimulsoftReports": '/Stimulsoft/scripts/stimulsoft.reports',
"StimulsoftViewer": '/Stimulsoft/scripts/stimulsoft.viewer',
"StimulsoftDesigner": '/Stimulsoft/scripts/stimulsoft.designer'
},
shim: {
'StimulsoftDesigner': ['StimulsoftViewer'],
'StimulsoftViewer': ['StimulsoftReports'],
'StimulsoftReports': ['momentjs']
}
});
Then you would just need to define StimulsoftDesigner or StimulsoftViewer.
Code: Select all
require(['StimulsoftDesigner'], function()
{
// use Stimulsoft here
});
Thanks, but not work for me:
Code: Select all
require.config({
baseUrl: "@Url.Content("~/scripts/")",
urlArgs: function (id, url) {
var d = new Date().getTime();
return (url.indexOf('?') === -1 ? '?' : '&') + "vr=" + d;
},
paths: {
momentjs: "stimul/moment",
StimulsoftReports: "stimul/stimulsoft.reports",
StimulsoftViewer: "stimul/stimulsoft.viewer"
},
shim: {
StimulsoftViewer: ["StimulsoftReports"],
StimulsoftReports: ["momentjs"],
bootstrap: ["jquery"]
},
waitSeconds: 60
});
Re: Requirejs and stimul
Posted: Wed Feb 06, 2019 1:21 pm
by Lech Kulikowski
Hello,
Please send us a sample project which reproduces the issue for analysis on
support@stimulsoft.com
Thank you.
Re: Requirejs and stimul
Posted: Mon Mar 04, 2019 2:11 pm
by gilgil
try this
after load momentjs add this code (momentAdaptor)
require Config
Code: Select all
'momentAdapter': {
deps: ['momentjs']
},
'StimulsoftReports': {
deps: ['momentAdapter']
},
'StimulsoftViewer': {
deps: ['StimulsoftReports']
},
'StimulsoftDesigner': {
deps: ['StimulsoftViewer']
},
Re: Requirejs and stimul
Posted: Tue Mar 05, 2019 12:34 am
by Barnaby
You need more than momentjs for everything to work, things such as jszip, and xxhash.
So now rather than trying to find out what is required and load them in manually, I now take a more hacky approach, which is to make it think there is no amd, so it loads the normal javascript version with all of it built in.
So still having Report, Designer and Viewer in the config, I do this
Code: Select all
// require my normal stuff
require(['Example'], function(Example)
{
// Temporarly remove the define.amd
var _amd = define.amd;
delete define.amd;
// Load the designer
require(['StimulsoftDesigner'], function()
{
// re-add the amd
define.amd = _amd;
// run designer code
});
});
StimulsoftDesigner is required in its own bit, so that other modules don't try load without the amd set.
Re: Requirejs and stimul
Posted: Tue Mar 05, 2019 9:22 am
by Lech Kulikowski
Hello,
Thank you for the information.