Skip to content

Commit 06c19e9

Browse files
committed
add support for new output option jsonpScriptType
1 parent 1ffcd28 commit 06c19e9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/JsonpMainTemplatePlugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class JsonpMainTemplatePlugin {
2929
const chunkMaps = chunk.getChunkMaps();
3030
const crossOriginLoading = this.outputOptions.crossOriginLoading;
3131
const chunkLoadTimeout = this.outputOptions.chunkLoadTimeout;
32+
const jsonpScriptType = this.outputOptions.jsonpScriptType || 'text/javascript';
3233
const scriptSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
3334
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
3435
hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
@@ -48,7 +49,7 @@ class JsonpMainTemplatePlugin {
4849
});
4950
return this.asString([
5051
"var script = document.createElement('script');",
51-
"script.type = 'text/javascript';",
52+
`script.type = '${jsonpScriptType}';`,
5253
"script.charset = 'utf-8';",
5354
"script.async = true;",
5455
`script.timeout = ${chunkLoadTimeout};`,

schemas/webpackOptionsSchema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,13 @@
314314
"use-credentials"
315315
]
316316
},
317+
"jsonpScriptType": {
318+
"description": "This option enables loading async chunks via a custom script type, such as script type=\"module\"",
319+
"enum": [
320+
"text/javascript",
321+
"module"
322+
]
323+
},
317324
"chunkLoadTimeout": {
318325
"description": "Number of milliseconds before chunk request expires",
319326
"type": "number"

0 commit comments

Comments
 (0)