Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
e32eea96
Commit
e32eea96
authored
9 months ago
by
Marcus Eibrink-Lunzenauer
Committed by
Jan-Hendrik Willms
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Re-throw error when failing to load a chunk.
Closes #4287 Merge request
studip/studip!3103
parent
c2d1b278
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/assets/javascripts/chunk-loader.js
+79
-74
79 additions, 74 deletions
resources/assets/javascripts/chunk-loader.js
with
79 additions
and
74 deletions
resources/assets/javascripts/chunk-loader.js
+
79
−
74
View file @
e32eea96
...
...
@@ -8,95 +8,100 @@ export const loadScript = function (script_name) {
});
};
export
const
loadChunk
=
(
function
()
{
let
mathjax_promise
=
null
;
let
mathjax_promise
=
null
;
return
function
(
chunk
)
{
let
promise
=
null
;
switch
(
chunk
)
{
/** This function dynamically loads JS features organized in chunks.
*
* @param {string} chunk The name of the chunk to load.
* @param {{ silent: boolean }} options Options for loading the chunk.
* Pass `{ silent: true }` to supress
* error messages.
* @return {Promise}
*/
export
const
loadChunk
=
function
(
chunk
,
{
silent
=
false
}
=
{})
{
let
promise
=
null
;
switch
(
chunk
)
{
case
'
code-highlight
'
:
promise
=
import
(
/* webpackChunkName: "code-highlight" */
'
./chunks/code-highlight
'
).
then
(({
default
:
hljs
})
=>
{
return
hljs
;
});
break
;
case
'
code-highlight
'
:
promise
=
import
(
/* webpackChunkName: "code-highlight" */
'
./chunks/code-highlight
'
).
then
(({
default
:
hljs
})
=>
{
return
hljs
;
});
break
;
case
'
courseware
'
:
promise
=
Promise
.
all
([
STUDIP
.
loadChunk
(
'
vue
'
),
import
(
/* webpackChunkName: "courseware" */
'
./chunks/courseware
'
),
]).
then
(([
Vue
])
=>
Vue
);
break
;
case
'
courseware
'
:
promise
=
Promise
.
all
([
STUDIP
.
loadChunk
(
'
vue
'
),
import
(
/* webpackChunkName: "courseware" */
'
./chunks/courseware
'
),
]).
then
(([
Vue
])
=>
Vue
);
break
;
case
'
chartist
'
:
promise
=
import
(
/* webpackChunkName: "chartist" */
'
./chunks/chartist
'
).
then
(({
default
:
Chartist
})
=>
Chartist
);
break
;
case
'
chartist
'
:
promise
=
import
(
/* webpackChunkName: "
chartist
" */
'
./chunks/
chartist
'
).
then
(({
default
:
Chartist
})
=>
Chartist
);
break
;
case
'
fullcalendar
'
:
promise
=
import
(
/* webpackChunkName: "
fullcalendar
" */
'
./chunks/
fullcalendar
'
);
break
;
case
'
fullcalenda
r
'
:
promise
=
import
(
/* webpackChunkName: "
fullcalenda
r" */
'
./chunks/
fullcalenda
r
'
);
break
;
case
'
tablesorte
r
'
:
promise
=
import
(
/* webpackChunkName: "
tablesorte
r" */
'
./chunks/
tablesorte
r
'
);
break
;
case
'
tablesorter
'
:
promise
=
import
(
/* webpackChunkName: "tablesorter" */
'
./chunks/tablesorter
'
);
break
;
case
'
mathjax
'
:
if
(
mathjax_promise
===
null
)
{
mathjax_promise
=
STUDIP
.
loadScript
(
'
javascripts/mathjax/MathJax.js?config=TeX-AMS_HTML,default
'
).
then
(()
=>
{
case
'
mathjax
'
:
if
(
mathjax_promise
===
null
)
{
mathjax_promise
=
STUDIP
.
loadScript
(
'
javascripts/mathjax/MathJax.js?config=TeX-AMS_HTML,default
'
)
.
then
(()
=>
{
(
function
(
origPrint
)
{
window
.
print
=
function
()
{
window
.
MathJax
.
Hub
.
Queue
(
[
'
Delay
'
,
window
.
MathJax
.
Callback
,
700
],
origPrint
);
window
.
MathJax
.
Hub
.
Queue
([
'
Delay
'
,
window
.
MathJax
.
Callback
,
700
],
origPrint
);
};
})(
window
.
print
);
return
window
.
MathJax
;
}).
catch
(()
=>
{
console
.
log
(
'
Could not load mathjax
'
)
})
.
catch
(()
=>
{
throw
new
Error
(
'
Could not load mathjax
'
);
});
}
promise
=
mathjax_promise
;
break
;
}
promise
=
mathjax_promise
;
break
;
case
'
vue
'
:
promise
=
import
(
/* webpackChunkName: "vue.js" */
'
./chunks/vue
'
);
break
;
case
'
vue
'
:
promise
=
import
(
/* webpackChunkName: "vue.js" */
'
./chunks/vue
'
);
break
;
case
'
wysiwyg
'
:
promise
=
import
(
/* webpackChunkName: "wysiwyg.js" */
'
./chunks/wysiwyg
'
);
break
;
case
'
wysiwyg
'
:
promise
=
import
(
/* webpackChunkName: "wysiwyg.js" */
'
./chunks/wysiwyg
'
);
break
;
default
:
promise
=
Promise
.
reject
(
new
Error
(
`Unknown chunk:
${
chunk
}
`
));
}
default
:
promise
=
Promise
.
reject
(
new
Error
(
`Unknown chunk:
${
chunk
}
`
));
}
return
promise
.
catch
((
error
)
=>
{
return
promise
.
catch
((
error
)
=>
{
if
(
!
silent
)
{
console
.
error
(
`Could not load chunk
${
chunk
}
`
,
error
);
});
};
}());
}
throw
error
;
});
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment