add support for new output option jsonpScriptType

This commit is contained in:
Neehar Venugopal 2017-12-31 17:13:59 +05:30
parent 1ffcd28c0e
commit 06c19e9565
2 changed files with 9 additions and 1 deletions

View File

@ -29,6 +29,7 @@ class JsonpMainTemplatePlugin {
const chunkMaps = chunk.getChunkMaps();
const crossOriginLoading = this.outputOptions.crossOriginLoading;
const chunkLoadTimeout = this.outputOptions.chunkLoadTimeout;
const jsonpScriptType = this.outputOptions.jsonpScriptType || 'text/javascript';
const scriptSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
@ -48,7 +49,7 @@ class JsonpMainTemplatePlugin {
});
return this.asString([
"var script = document.createElement('script');",
"script.type = 'text/javascript';",
`script.type = '${jsonpScriptType}';`,
"script.charset = 'utf-8';",
"script.async = true;",
`script.timeout = ${chunkLoadTimeout};`,

View File

@ -314,6 +314,13 @@
"use-credentials"
]
},
"jsonpScriptType": {
"description": "This option enables loading async chunks via a custom script type, such as script type=\"module\"",
"enum": [
"text/javascript",
"module"
]
},
"chunkLoadTimeout": {
"description": "Number of milliseconds before chunk request expires",
"type": "number"