rename jsonScriptType to scriptType
This commit is contained in:
parent
854c67b6b9
commit
139da61b5f
|
@ -407,10 +407,6 @@ export type ImportFunctionName = string;
|
|||
* The JSONP function used by webpack for async loading of chunks.
|
||||
*/
|
||||
export type JsonpFunction = string;
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
export type JsonpScriptType = false | "text/javascript" | "module";
|
||||
/**
|
||||
* Make the output files a library, exporting the exports of the entry point.
|
||||
*/
|
||||
|
@ -436,6 +432,10 @@ export type PublicPath =
|
|||
pathData: import("../lib/Compilation").PathData,
|
||||
assetInfo?: import("../lib/Compilation").AssetInfo
|
||||
) => string);
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
export type ScriptType = false | "text/javascript" | "module";
|
||||
/**
|
||||
* The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
|
||||
*/
|
||||
|
@ -1623,10 +1623,6 @@ export interface Output {
|
|||
* The JSONP function used by webpack for async loading of chunks.
|
||||
*/
|
||||
jsonpFunction?: JsonpFunction;
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
jsonpScriptType?: JsonpScriptType;
|
||||
/**
|
||||
* Make the output files a library, exporting the exports of the entry point.
|
||||
*/
|
||||
|
@ -1655,6 +1651,10 @@ export interface Output {
|
|||
* The `publicPath` specifies the public URL address of the output files when referenced in a browser.
|
||||
*/
|
||||
publicPath?: PublicPath;
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
scriptType?: ScriptType;
|
||||
/**
|
||||
* The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
|
||||
*/
|
||||
|
@ -2084,10 +2084,6 @@ export interface OutputNormalized {
|
|||
* The JSONP function used by webpack for async loading of chunks.
|
||||
*/
|
||||
jsonpFunction?: JsonpFunction;
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
jsonpScriptType?: JsonpScriptType;
|
||||
/**
|
||||
* Options for library.
|
||||
*/
|
||||
|
@ -2108,6 +2104,10 @@ export interface OutputNormalized {
|
|||
* The `publicPath` specifies the public URL address of the output files when referenced in a browser.
|
||||
*/
|
||||
publicPath?: PublicPath;
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
scriptType?: ScriptType;
|
||||
/**
|
||||
* The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
|
||||
*/
|
||||
|
|
|
@ -461,7 +461,7 @@ const applyOutputDefaults = (
|
|||
D(output, "hotUpdateChunkFilename", "[id].[fullhash].hot-update.js");
|
||||
D(output, "hotUpdateMainFilename", "[fullhash].hot-update.json");
|
||||
D(output, "crossOriginLoading", false);
|
||||
F(output, "jsonpScriptType", () => (output.module ? "module" : false));
|
||||
F(output, "scriptType", () => (output.module ? "module" : false));
|
||||
D(output, "chunkLoadTimeout", 120000);
|
||||
D(output, "hashFunction", "md4");
|
||||
D(output, "hashDigest", "hex");
|
||||
|
|
|
@ -221,7 +221,7 @@ const getNormalizedWebpackOptions = config => {
|
|||
iife: output.iife,
|
||||
importFunctionName: output.importFunctionName,
|
||||
jsonpFunction: output.jsonpFunction,
|
||||
jsonpScriptType: output.jsonpScriptType,
|
||||
scriptType: output.scriptType,
|
||||
library: libraryBase && {
|
||||
type:
|
||||
output.libraryTarget !== undefined
|
||||
|
|
|
@ -54,7 +54,7 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|||
const { compilation } = this;
|
||||
const { runtimeTemplate, outputOptions } = compilation;
|
||||
const {
|
||||
jsonpScriptType: scriptType,
|
||||
scriptType,
|
||||
chunkLoadTimeout: loadTimeout,
|
||||
crossOriginLoading,
|
||||
uniqueName
|
||||
|
|
|
@ -128,15 +128,13 @@ class JsonpTemplatePlugin {
|
|||
const {
|
||||
crossOriginLoading,
|
||||
chunkLoadTimeout,
|
||||
jsonpScriptType
|
||||
scriptType
|
||||
} = compilation.outputOptions;
|
||||
|
||||
return Template.asString([
|
||||
"var script = document.createElement('script');",
|
||||
"var onScriptComplete;",
|
||||
jsonpScriptType
|
||||
? `script.type = ${JSON.stringify(jsonpScriptType)};`
|
||||
: "",
|
||||
scriptType ? `script.type = ${JSON.stringify(scriptType)};` : "",
|
||||
"script.charset = 'utf-8';",
|
||||
`script.timeout = ${chunkLoadTimeout / 1000};`,
|
||||
`if (${RuntimeGlobals.scriptNonce}) {`,
|
||||
|
@ -187,16 +185,11 @@ class JsonpTemplatePlugin {
|
|||
]);
|
||||
});
|
||||
linkPreload.tap("JsonpTemplatePlugin", (_, chunk, hash) => {
|
||||
const {
|
||||
crossOriginLoading,
|
||||
jsonpScriptType
|
||||
} = compilation.outputOptions;
|
||||
const { crossOriginLoading, scriptType } = compilation.outputOptions;
|
||||
|
||||
return Template.asString([
|
||||
"var link = document.createElement('link');",
|
||||
jsonpScriptType
|
||||
? `link.type = ${JSON.stringify(jsonpScriptType)};`
|
||||
: "",
|
||||
scriptType ? `link.type = ${JSON.stringify(scriptType)};` : "",
|
||||
"link.charset = 'utf-8';",
|
||||
`if (${RuntimeGlobals.scriptNonce}) {`,
|
||||
Template.indent(
|
||||
|
|
|
@ -689,10 +689,6 @@
|
|||
"description": "The JSONP function used by webpack for async loading of chunks.",
|
||||
"type": "string"
|
||||
},
|
||||
"JsonpScriptType": {
|
||||
"description": "This option enables loading async chunks via a custom script type, such as script type=\"module\".",
|
||||
"enum": [false, "text/javascript", "module"]
|
||||
},
|
||||
"Library": {
|
||||
"description": "Make the output files a library, exporting the exports of the entry point.",
|
||||
"anyOf": [
|
||||
|
@ -1704,9 +1700,6 @@
|
|||
"jsonpFunction": {
|
||||
"$ref": "#/definitions/JsonpFunction"
|
||||
},
|
||||
"jsonpScriptType": {
|
||||
"$ref": "#/definitions/JsonpScriptType"
|
||||
},
|
||||
"library": {
|
||||
"$ref": "#/definitions/Library"
|
||||
},
|
||||
|
@ -1742,6 +1735,9 @@
|
|||
"publicPath": {
|
||||
"$ref": "#/definitions/PublicPath"
|
||||
},
|
||||
"scriptType": {
|
||||
"$ref": "#/definitions/ScriptType"
|
||||
},
|
||||
"sourceMapFilename": {
|
||||
"$ref": "#/definitions/SourceMapFilename"
|
||||
},
|
||||
|
@ -1847,9 +1843,6 @@
|
|||
"jsonpFunction": {
|
||||
"$ref": "#/definitions/JsonpFunction"
|
||||
},
|
||||
"jsonpScriptType": {
|
||||
"$ref": "#/definitions/JsonpScriptType"
|
||||
},
|
||||
"library": {
|
||||
"$ref": "#/definitions/LibraryOptions"
|
||||
},
|
||||
|
@ -1865,6 +1858,9 @@
|
|||
"publicPath": {
|
||||
"$ref": "#/definitions/PublicPath"
|
||||
},
|
||||
"scriptType": {
|
||||
"$ref": "#/definitions/ScriptType"
|
||||
},
|
||||
"sourceMapFilename": {
|
||||
"$ref": "#/definitions/SourceMapFilename"
|
||||
},
|
||||
|
@ -2682,6 +2678,10 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"ScriptType": {
|
||||
"description": "This option enables loading async chunks via a custom script type, such as script type=\"module\".",
|
||||
"enum": [false, "text/javascript", "module"]
|
||||
},
|
||||
"SourceMapFilename": {
|
||||
"description": "The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.",
|
||||
"type": "string",
|
||||
|
|
|
@ -217,13 +217,13 @@ describe("Defaults", () => {
|
|||
"iife": true,
|
||||
"importFunctionName": "import",
|
||||
"jsonpFunction": "webpackJsonpwebpack",
|
||||
"jsonpScriptType": false,
|
||||
"library": undefined,
|
||||
"libraryTarget": "var",
|
||||
"module": false,
|
||||
"path": "<cwd>/dist",
|
||||
"pathinfo": false,
|
||||
"publicPath": "",
|
||||
"scriptType": false,
|
||||
"sourceMapFilename": "[file].map[query]",
|
||||
"sourcePrefix": undefined,
|
||||
"strictModuleExceptionHandling": false,
|
||||
|
@ -559,13 +559,13 @@ describe("Defaults", () => {
|
|||
- "iife": true,
|
||||
+ "iife": false,
|
||||
@@ ... @@
|
||||
- "jsonpScriptType": false,
|
||||
+ "jsonpScriptType": "module",
|
||||
@@ ... @@
|
||||
- "libraryTarget": "var",
|
||||
- "module": false,
|
||||
+ "libraryTarget": "module",
|
||||
+ "module": true,
|
||||
@@ ... @@
|
||||
- "scriptType": false,
|
||||
+ "scriptType": "module",
|
||||
`)
|
||||
);
|
||||
test("async wasm", { experiments: { asyncWebAssembly: true } }, e =>
|
||||
|
@ -659,9 +659,8 @@ describe("Defaults", () => {
|
|||
+ "hotUpdateFunction": "webpackHotUpdatemyLib_awesome",
|
||||
@@ ... @@
|
||||
- "jsonpFunction": "webpackJsonpwebpack",
|
||||
+ "jsonpFunction": "webpackJsonpmyLib_awesome",
|
||||
@@ ... @@
|
||||
- "library": undefined,
|
||||
+ "jsonpFunction": "webpackJsonpmyLib_awesome",
|
||||
+ "library": Object {
|
||||
+ "auxiliaryComment": undefined,
|
||||
+ "export": undefined,
|
||||
|
|
|
@ -2087,24 +2087,6 @@ Object {
|
|||
"multiple": false,
|
||||
"simpleType": "string",
|
||||
},
|
||||
"output-jsonp-script-type": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "This option enables loading async chunks via a custom script type, such as script type=\\"module\\".",
|
||||
"multiple": false,
|
||||
"path": "output.jsonpScriptType",
|
||||
"type": "enum",
|
||||
"values": Array [
|
||||
false,
|
||||
"text/javascript",
|
||||
"module",
|
||||
],
|
||||
},
|
||||
],
|
||||
"description": "This option enables loading async chunks via a custom script type, such as script type=\\"module\\".",
|
||||
"multiple": false,
|
||||
"simpleType": "string",
|
||||
},
|
||||
"output-library": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
|
@ -2448,6 +2430,24 @@ Object {
|
|||
"multiple": false,
|
||||
"simpleType": "string",
|
||||
},
|
||||
"output-script-type": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "This option enables loading async chunks via a custom script type, such as script type=\\"module\\".",
|
||||
"multiple": false,
|
||||
"path": "output.scriptType",
|
||||
"type": "enum",
|
||||
"values": Array [
|
||||
false,
|
||||
"text/javascript",
|
||||
"module",
|
||||
],
|
||||
},
|
||||
],
|
||||
"description": "This option enables loading async chunks via a custom script type, such as script type=\\"module\\".",
|
||||
"multiple": false,
|
||||
"simpleType": "string",
|
||||
},
|
||||
"output-source-map-filename": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
|
|
|
@ -3424,7 +3424,6 @@ declare interface JsonpCompilationPluginHooks {
|
|||
linkPreload: SyncWaterfallHook<[string, Chunk, string]>;
|
||||
linkPrefetch: SyncWaterfallHook<[string, Chunk, string]>;
|
||||
}
|
||||
type JsonpScriptType = false | "module" | "text/javascript";
|
||||
declare class JsonpTemplatePlugin {
|
||||
constructor();
|
||||
|
||||
|
@ -5045,11 +5044,6 @@ declare interface Output {
|
|||
*/
|
||||
jsonpFunction?: string;
|
||||
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
jsonpScriptType?: JsonpScriptType;
|
||||
|
||||
/**
|
||||
* Make the output files a library, exporting the exports of the entry point.
|
||||
*/
|
||||
|
@ -5085,6 +5079,11 @@ declare interface Output {
|
|||
*/
|
||||
publicPath?: PublicPath;
|
||||
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
scriptType?: ScriptType;
|
||||
|
||||
/**
|
||||
* The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
|
||||
*/
|
||||
|
@ -5254,11 +5253,6 @@ declare interface OutputNormalized {
|
|||
*/
|
||||
jsonpFunction?: string;
|
||||
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
jsonpScriptType?: JsonpScriptType;
|
||||
|
||||
/**
|
||||
* Options for library.
|
||||
*/
|
||||
|
@ -5284,6 +5278,11 @@ declare interface OutputNormalized {
|
|||
*/
|
||||
publicPath?: PublicPath;
|
||||
|
||||
/**
|
||||
* This option enables loading async chunks via a custom script type, such as script type="module".
|
||||
*/
|
||||
scriptType?: ScriptType;
|
||||
|
||||
/**
|
||||
* The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
|
||||
*/
|
||||
|
@ -7020,6 +7019,7 @@ declare interface ScopeInfo {
|
|||
isAsmJs: boolean;
|
||||
inTry: boolean;
|
||||
}
|
||||
type ScriptType = false | "module" | "text/javascript";
|
||||
declare abstract class Serializer {
|
||||
serializeMiddlewares: any;
|
||||
deserializeMiddlewares: any;
|
||||
|
|
Loading…
Reference in New Issue