mirror of https://github.com/webpack/webpack.git
Compare commits
3 Commits
ac282a4988
...
77df87468b
Author | SHA1 | Date |
---|---|---|
|
77df87468b | |
|
e1afcd4cc2 | |
|
d45073a2b3 |
|
@ -314,7 +314,8 @@
|
|||
"Kumar",
|
||||
"spacek",
|
||||
"thelarkinn",
|
||||
"behaviour"
|
||||
"behaviour",
|
||||
"WHATWG"
|
||||
],
|
||||
"ignoreRegExpList": [
|
||||
"/Author.+/",
|
||||
|
|
|
@ -91,28 +91,6 @@ const resolve = (browsers) => {
|
|||
const anyBrowser = browsers.some((b) => /^(?!node)/.test(b));
|
||||
const browserProperty = !anyBrowser ? false : anyNode ? null : true;
|
||||
const nodeProperty = !anyNode ? false : anyBrowser ? null : true;
|
||||
// Internet Explorer Mobile, Blackberry browser and Opera Mini are very old browsers, they do not support new features
|
||||
const es6DynamicImport = rawChecker({
|
||||
/* eslint-disable camelcase */
|
||||
chrome: 63,
|
||||
and_chr: 63,
|
||||
edge: 79,
|
||||
firefox: 67,
|
||||
and_ff: 67,
|
||||
// ie: Not supported
|
||||
opera: 50,
|
||||
op_mob: 46,
|
||||
safari: [11, 1],
|
||||
ios_saf: [11, 3],
|
||||
samsung: [8, 2],
|
||||
android: 63,
|
||||
and_qq: [10, 4],
|
||||
baidu: [13, 18],
|
||||
and_uc: [15, 5],
|
||||
kaios: [3, 0],
|
||||
node: [12, 17]
|
||||
/* eslint-enable camelcase */
|
||||
});
|
||||
|
||||
return {
|
||||
/* eslint-disable camelcase */
|
||||
|
@ -175,9 +153,9 @@ const resolve = (browsers) => {
|
|||
ios_saf: 7,
|
||||
samsung: [3, 0],
|
||||
android: 38,
|
||||
// and_qq: Unknown support
|
||||
and_qq: [10, 4],
|
||||
// baidu: Unknown support
|
||||
// and_uc: Unknown support
|
||||
and_uc: [12, 12],
|
||||
kaios: [3, 0],
|
||||
node: [0, 12]
|
||||
}),
|
||||
|
@ -194,9 +172,9 @@ const resolve = (browsers) => {
|
|||
ios_saf: 8,
|
||||
samsung: [5, 0],
|
||||
android: 49,
|
||||
// and_qq: Unknown support
|
||||
and_qq: [10, 4],
|
||||
// baidu: Unknown support
|
||||
// and_uc: Unknown support
|
||||
and_uc: [12, 12],
|
||||
kaios: [2, 5],
|
||||
node: [6, 0]
|
||||
}),
|
||||
|
@ -240,8 +218,44 @@ const resolve = (browsers) => {
|
|||
kaios: [3, 0],
|
||||
node: [12, 17]
|
||||
}),
|
||||
dynamicImport: es6DynamicImport,
|
||||
dynamicImportInWorker: es6DynamicImport && !anyNode,
|
||||
dynamicImport: rawChecker({
|
||||
chrome: 63,
|
||||
and_chr: 63,
|
||||
edge: 79,
|
||||
firefox: 67,
|
||||
and_ff: 67,
|
||||
// ie: Not supported
|
||||
opera: 50,
|
||||
op_mob: 46,
|
||||
safari: [11, 1],
|
||||
ios_saf: [11, 3],
|
||||
samsung: [8, 2],
|
||||
android: 63,
|
||||
and_qq: [10, 4],
|
||||
baidu: [13, 18],
|
||||
and_uc: [15, 5],
|
||||
kaios: [3, 0],
|
||||
node: [12, 17]
|
||||
}),
|
||||
dynamicImportInWorker: rawChecker({
|
||||
chrome: 80,
|
||||
and_chr: 80,
|
||||
edge: 80,
|
||||
firefox: 114,
|
||||
and_ff: 114,
|
||||
// ie: Not supported
|
||||
opera: 67,
|
||||
op_mob: 57,
|
||||
safari: [15, 0],
|
||||
ios_saf: [15, 0],
|
||||
samsung: [13, 0],
|
||||
android: 80,
|
||||
and_qq: [10, 4],
|
||||
baidu: [13, 18],
|
||||
and_uc: [15, 5],
|
||||
kaios: [3, 0],
|
||||
node: [12, 17]
|
||||
}),
|
||||
// browserslist does not have info about globalThis
|
||||
// so this is based on mdn-browser-compat-data
|
||||
globalThis: rawChecker({
|
||||
|
@ -257,9 +271,9 @@ const resolve = (browsers) => {
|
|||
ios_saf: [12, 2],
|
||||
samsung: [10, 1],
|
||||
android: 71,
|
||||
// and_qq: Unknown support
|
||||
and_qq: [13, 1],
|
||||
// baidu: Unknown support
|
||||
// and_uc: Unknown support
|
||||
and_uc: [15, 5],
|
||||
kaios: [3, 0],
|
||||
node: 12
|
||||
}),
|
||||
|
@ -276,9 +290,9 @@ const resolve = (browsers) => {
|
|||
ios_saf: [13, 4],
|
||||
samsung: 13,
|
||||
android: 80,
|
||||
// and_qq: Not supported
|
||||
and_qq: [13, 1],
|
||||
// baidu: Not supported
|
||||
// and_uc: Not supported
|
||||
and_uc: [15, 5],
|
||||
kaios: [3, 0],
|
||||
node: 14
|
||||
}),
|
||||
|
@ -314,9 +328,9 @@ const resolve = (browsers) => {
|
|||
ios_saf: 11,
|
||||
samsung: [6, 2],
|
||||
android: 55,
|
||||
and_qq: [13, 1],
|
||||
and_qq: [10, 4],
|
||||
baidu: [13, 18],
|
||||
and_uc: [15, 5],
|
||||
and_uc: [12, 12],
|
||||
kaios: 3,
|
||||
node: [7, 6]
|
||||
}),
|
||||
|
@ -332,7 +346,7 @@ const resolve = (browsers) => {
|
|||
fetchWasm: browserProperty,
|
||||
global: nodeProperty,
|
||||
importScripts: false,
|
||||
importScriptsInWorker: true,
|
||||
importScriptsInWorker: Boolean(browserProperty),
|
||||
nodeBuiltins: nodeProperty,
|
||||
nodePrefixForCoreModules:
|
||||
nodeProperty &&
|
||||
|
|
|
@ -2909,12 +2909,6 @@ describe("Targets", () => {
|
|||
- Expected
|
||||
+ Received
|
||||
|
||||
@@ ... @@
|
||||
- "dynamicImportInWorker": true,
|
||||
+ "dynamicImportInWorker": false,
|
||||
@@ ... @@
|
||||
- "dynamicImportInWorker": true,
|
||||
+ "dynamicImportInWorker": false,
|
||||
@@ ... @@
|
||||
- "target": "node12.17",
|
||||
+ "target": "browserslist: node 12.17",
|
||||
|
|
|
@ -31,6 +31,37 @@ Object {
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`browserslist target ["and_chr 140","and_ff 142","and_qq 14.9","and_uc 15.5","android 140","chrome 140","chrome 139","chrome 138","chrome 137","chrome 112","chrome 109","chrome 105","edge 140","edge 139","edge 138","firefox 143","firefox 142","firefox 141","firefox 140","ios_saf 26.0","ios_saf 18.5-18.6","kaios 3.0-3.1","node 24.8.0","node 22.19.0","node 20.19.0","op_mob 80","opera 122","opera 121","opera 120","safari 26.0","safari 18.5-18.6","samsung 28","samsung 27"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": true,
|
||||
"asyncFunction": true,
|
||||
"bigIntLiteral": true,
|
||||
"browser": null,
|
||||
"const": true,
|
||||
"destructuring": true,
|
||||
"document": null,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"electron": false,
|
||||
"fetchWasm": null,
|
||||
"forOf": true,
|
||||
"global": null,
|
||||
"globalThis": true,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": false,
|
||||
"module": true,
|
||||
"node": null,
|
||||
"nodeBuiltins": null,
|
||||
"nodePrefixForCoreModules": null,
|
||||
"nwjs": false,
|
||||
"optionalChaining": true,
|
||||
"require": null,
|
||||
"templateLiteral": true,
|
||||
"web": null,
|
||||
"webworker": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`browserslist target ["and_ff 68"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": true,
|
||||
|
@ -41,7 +72,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -65,17 +96,17 @@ Object {
|
|||
exports[`browserslist target ["and_qq 10.4"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": true,
|
||||
"asyncFunction": false,
|
||||
"asyncFunction": true,
|
||||
"bigIntLiteral": false,
|
||||
"browser": true,
|
||||
"const": true,
|
||||
"destructuring": false,
|
||||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": false,
|
||||
"forOf": true,
|
||||
"global": false,
|
||||
"globalThis": false,
|
||||
"importScripts": false,
|
||||
|
@ -93,37 +124,6 @@ Object {
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`browserslist target ["and_uc 12.12"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": true,
|
||||
"asyncFunction": false,
|
||||
"bigIntLiteral": false,
|
||||
"browser": true,
|
||||
"const": true,
|
||||
"destructuring": false,
|
||||
"document": true,
|
||||
"dynamicImport": false,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": false,
|
||||
"global": false,
|
||||
"globalThis": false,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"module": false,
|
||||
"node": false,
|
||||
"nodeBuiltins": false,
|
||||
"nodePrefixForCoreModules": false,
|
||||
"nwjs": false,
|
||||
"optionalChaining": false,
|
||||
"require": false,
|
||||
"templateLiteral": true,
|
||||
"web": true,
|
||||
"webworker": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`browserslist target ["android 4"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": false,
|
||||
|
@ -320,14 +320,45 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": null,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"dynamicImportInWorker": true,
|
||||
"electron": false,
|
||||
"fetchWasm": null,
|
||||
"forOf": true,
|
||||
"global": null,
|
||||
"globalThis": true,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"importScriptsInWorker": false,
|
||||
"module": true,
|
||||
"node": null,
|
||||
"nodeBuiltins": null,
|
||||
"nodePrefixForCoreModules": null,
|
||||
"nwjs": false,
|
||||
"optionalChaining": false,
|
||||
"require": null,
|
||||
"templateLiteral": true,
|
||||
"web": null,
|
||||
"webworker": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`browserslist target ["chrome 80","node 13.12.0"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": true,
|
||||
"asyncFunction": true,
|
||||
"bigIntLiteral": true,
|
||||
"browser": null,
|
||||
"const": true,
|
||||
"destructuring": true,
|
||||
"document": null,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"electron": false,
|
||||
"fetchWasm": null,
|
||||
"forOf": true,
|
||||
"global": null,
|
||||
"globalThis": true,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": false,
|
||||
"module": true,
|
||||
"node": null,
|
||||
"nodeBuiltins": null,
|
||||
|
@ -382,7 +413,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -413,7 +444,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -444,7 +475,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -537,7 +568,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -606,7 +637,7 @@ Object {
|
|||
"global": true,
|
||||
"globalThis": false,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"importScriptsInWorker": false,
|
||||
"module": false,
|
||||
"node": true,
|
||||
"nodeBuiltins": true,
|
||||
|
@ -637,7 +668,7 @@ Object {
|
|||
"global": true,
|
||||
"globalThis": false,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"importScriptsInWorker": false,
|
||||
"module": false,
|
||||
"node": true,
|
||||
"nodeBuiltins": true,
|
||||
|
@ -668,7 +699,7 @@ Object {
|
|||
"global": true,
|
||||
"globalThis": false,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"importScriptsInWorker": false,
|
||||
"module": false,
|
||||
"node": true,
|
||||
"nodeBuiltins": true,
|
||||
|
@ -699,7 +730,7 @@ Object {
|
|||
"global": true,
|
||||
"globalThis": false,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"importScriptsInWorker": false,
|
||||
"module": false,
|
||||
"node": true,
|
||||
"nodeBuiltins": true,
|
||||
|
@ -723,14 +754,45 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": false,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"dynamicImportInWorker": true,
|
||||
"electron": false,
|
||||
"fetchWasm": false,
|
||||
"forOf": true,
|
||||
"global": true,
|
||||
"globalThis": true,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": true,
|
||||
"importScriptsInWorker": false,
|
||||
"module": true,
|
||||
"node": true,
|
||||
"nodeBuiltins": true,
|
||||
"nodePrefixForCoreModules": false,
|
||||
"nwjs": false,
|
||||
"optionalChaining": false,
|
||||
"require": true,
|
||||
"templateLiteral": true,
|
||||
"web": false,
|
||||
"webworker": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`browserslist target ["node 13.12.0"] 1`] = `
|
||||
Object {
|
||||
"arrowFunction": true,
|
||||
"asyncFunction": true,
|
||||
"bigIntLiteral": true,
|
||||
"browser": false,
|
||||
"const": true,
|
||||
"destructuring": true,
|
||||
"document": false,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"electron": false,
|
||||
"fetchWasm": false,
|
||||
"forOf": true,
|
||||
"global": true,
|
||||
"globalThis": true,
|
||||
"importScripts": false,
|
||||
"importScriptsInWorker": false,
|
||||
"module": true,
|
||||
"node": true,
|
||||
"nodeBuiltins": true,
|
||||
|
@ -785,7 +847,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -816,7 +878,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -909,7 +971,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -940,7 +1002,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -971,7 +1033,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -1064,7 +1126,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
@ -1095,7 +1157,7 @@ Object {
|
|||
"destructuring": true,
|
||||
"document": true,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"electron": false,
|
||||
"fetchWasm": true,
|
||||
"forOf": true,
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
"destructuring": true,
|
||||
"document": false,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"dynamicImportInWorker": true,
|
||||
"forOf": true,
|
||||
"globalThis": true,
|
||||
"module": true,
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
"destructuring": true,
|
||||
"document": false,
|
||||
"dynamicImport": true,
|
||||
"dynamicImportInWorker": false,
|
||||
"dynamicImportInWorker": true,
|
||||
"forOf": true,
|
||||
"globalThis": true,
|
||||
"module": true,
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as style from "./style.css";
|
|||
import * as text1 from "./text-with-bom.txt";
|
||||
import * as text2 from "./test-without-bom.text";
|
||||
|
||||
it("should remove BOM", function() {
|
||||
it("should remove BOM", async function() {
|
||||
const url = new URL("./resource-with-bom.ext", import.meta.url);
|
||||
|
||||
expect(mod).toBeDefined();
|
||||
|
@ -13,7 +13,7 @@ it("should remove BOM", function() {
|
|||
expect(url).toBeDefined();
|
||||
|
||||
const module = "module.js"
|
||||
const modules = import("./dir/" + module);
|
||||
const modules = await import("./dir/" + module);
|
||||
|
||||
expect(modules).toBeDefined();
|
||||
});
|
||||
|
|
|
@ -4,6 +4,9 @@ const fs = require("fs");
|
|||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
findBundle() {
|
||||
return ["dir_module_js.bundle0.js", "bundle0.js"];
|
||||
},
|
||||
afterExecute(options) {
|
||||
const outputPath = options.output.path;
|
||||
const files = fs.readdirSync(outputPath);
|
||||
|
|
|
@ -6,6 +6,9 @@ module.exports = {
|
|||
output: {
|
||||
assetModuleFilename: "[name][ext]"
|
||||
},
|
||||
optimization: {
|
||||
chunkIds: "named"
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
|
|
|
@ -1,27 +1,39 @@
|
|||
it("should set fetchPriority", () => {
|
||||
import(/* webpackFetchPriority: "high" */ "./a");
|
||||
function abortable(fn) {
|
||||
return new Promise((resolve) => {
|
||||
const timeoutId = setTimeout(() => {
|
||||
fn = undefined;
|
||||
resolve('Promise resolved after delay');
|
||||
clearTimeout(timeoutId);
|
||||
}, 1000);
|
||||
|
||||
return fn();
|
||||
});
|
||||
}
|
||||
|
||||
it("should set fetchPriority", async () => {
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./a"));
|
||||
expect(document.head._children).toHaveLength(4);
|
||||
const script1 = document.head._children[2];
|
||||
expect(script1._attributes.fetchpriority).toBe("high");
|
||||
|
||||
import(/* webpackFetchPriority: "low" */ "./b");
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./b"));
|
||||
expect(document.head._children).toHaveLength(5);
|
||||
const script2 = document.head._children[4];
|
||||
expect(script2._attributes.fetchpriority).toBe("low");
|
||||
|
||||
import(/* webpackFetchPriority: "low" */ "./c");
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./c"));
|
||||
expect(document.head._children).toHaveLength(6);
|
||||
const script3 = document.head._children[5];
|
||||
expect(script3._attributes.fetchpriority).toBe("low");
|
||||
|
||||
import(/* webpackPrefetch: 20, webpackFetchPriority: "auto" */ "./c");
|
||||
abortable(() => import(/* webpackPrefetch: 20, webpackFetchPriority: "auto" */ "./c"));
|
||||
|
||||
import("./d")
|
||||
abortable(() => import("./d"))
|
||||
expect(document.head._children).toHaveLength(7);
|
||||
const script4 = document.head._children[6];
|
||||
expect(script4._attributes.fetchpriority).toBeUndefined();
|
||||
|
||||
import(/* webpackPrefetch: -20 */ "./d3");
|
||||
abortable(() => import(/* webpackPrefetch: -20 */ "./d3"));
|
||||
expect(document.head._children).toHaveLength(8);
|
||||
const script5 = document.head._children[7];
|
||||
expect(script5._attributes.fetchpriority).toBeUndefined();
|
||||
|
@ -29,12 +41,12 @@ it("should set fetchPriority", () => {
|
|||
const condition = true;
|
||||
|
||||
if (!condition) {
|
||||
import(/* webpackFetchPriority: "high", webpackChunkName: "one" */ "./e");
|
||||
abortable( () => import(/* webpackFetchPriority: "high", webpackChunkName: "one" */ "./e"));
|
||||
expect(document.head._children).toHaveLength(9);
|
||||
const script6 = document.head._children[8];
|
||||
expect(script6._attributes.fetchpriority).toBe("high");
|
||||
} else {
|
||||
import(/* webpackFetchPriority: "low", webpackChunkName: "two" */ "./e");
|
||||
abortable(() => import(/* webpackFetchPriority: "low", webpackChunkName: "two" */ "./e"));
|
||||
expect(document.head._children).toHaveLength(9);
|
||||
const script6 = document.head._children[8];
|
||||
expect(script6._attributes.fetchpriority).toBe("low");
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
function abortable(fn) {
|
||||
return new Promise((resolve) => {
|
||||
const timeoutId = setTimeout(() => {
|
||||
fn = undefined;
|
||||
resolve('Promise resolved after delay');
|
||||
clearTimeout(timeoutId);
|
||||
}, 1000);
|
||||
|
||||
return fn();
|
||||
});
|
||||
}
|
||||
|
||||
it("should set fetchPriority", () => {
|
||||
// Single Chunk
|
||||
import(/* webpackFetchPriority: "high" */ "./a");
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./a"));
|
||||
expect(document.head._children).toHaveLength(1);
|
||||
const script1 = document.head._children[0];
|
||||
expect(script1._attributes.fetchpriority).toBe("high");
|
||||
|
||||
// Multiple Chunks
|
||||
import(/* webpackFetchPriority: "high" */ "./b");
|
||||
import(/* webpackFetchPriority: "high" */ "./b2");
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./b"));
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./b2"));
|
||||
expect(document.head._children).toHaveLength(4);
|
||||
const script2 = document.head._children[1];
|
||||
const script3 = document.head._children[2];
|
||||
|
@ -17,19 +29,19 @@ it("should set fetchPriority", () => {
|
|||
expect(script4._attributes.fetchpriority).toBe("high");
|
||||
|
||||
// Single Chunk, low
|
||||
import(/* webpackFetchPriority: "low" */ "./c");
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./c"));
|
||||
expect(document.head._children).toHaveLength(5);
|
||||
const script5 = document.head._children[4];
|
||||
expect(script5._attributes.fetchpriority).toBe("low");
|
||||
|
||||
// Single Chunk, auto
|
||||
import(/* webpackFetchPriority: "auto" */ "./d");
|
||||
abortable(() => import(/* webpackFetchPriority: "auto" */ "./d"));
|
||||
expect(document.head._children).toHaveLength(6);
|
||||
const script6 = document.head._children[5];
|
||||
expect(script6._attributes.fetchpriority).toBe("auto");
|
||||
|
||||
// No fetch priority
|
||||
import("./e");
|
||||
abortable(() => import("./e"));
|
||||
expect(document.head._children).toHaveLength(7);
|
||||
const script7 = document.head._children[6];
|
||||
expect(script7._attributes.fetchpriority).toBeUndefined();
|
||||
|
@ -44,49 +56,49 @@ it("should set fetchPriority", () => {
|
|||
const script8 = document.head._children[7];
|
||||
expect(script8._attributes.fetchpriority).toBeUndefined();
|
||||
|
||||
import(/* webpackFetchPriority: "auto" */ "./g");
|
||||
abortable(() => import(/* webpackFetchPriority: "auto" */ "./g"));
|
||||
expect(document.head._children).toHaveLength(9);
|
||||
const script9 = document.head._children[8];
|
||||
expect(script9._attributes.fetchpriority).toBe("auto");
|
||||
|
||||
import(/* webpackFetchPriority: "unknown" */ "./h.js");
|
||||
abortable(() => import(/* webpackFetchPriority: "unknown" */ "./h.js"));
|
||||
expect(document.head._children).toHaveLength(10);
|
||||
const script10 = document.head._children[9];
|
||||
expect(script10._attributes.fetchpriority).toBeUndefined();
|
||||
|
||||
import(/* webpackFetchPriority: "high" */ "./i");
|
||||
import(/* webpackFetchPriority: "low" */ "./i");
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./i"));
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./i"));
|
||||
expect(document.head._children).toHaveLength(11);
|
||||
const script11 = document.head._children[10];
|
||||
expect(script11._attributes.fetchpriority).toBe("high");
|
||||
|
||||
import(/* webpackFetchPriority: "low" */ "./j");
|
||||
import(/* webpackFetchPriority: "high" */ "./j");
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./j"));
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./j"));
|
||||
expect(document.head._children).toHaveLength(12);
|
||||
const script12 = document.head._children[11];
|
||||
|
||||
expect(script12._attributes.fetchpriority).toBe("low");
|
||||
import(/* webpackFetchPriority: "low" */ "./k");
|
||||
import("./e");
|
||||
import(/* webpackFetchPriority: "high" */ "./k");
|
||||
expect(document.head._children).toHaveLength(13);
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./k"));
|
||||
abortable(() => import("./e"));
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./k"));
|
||||
abortable(() => expect(document.head._children).toHaveLength(13));
|
||||
const script13 = document.head._children[12];
|
||||
expect(script13._attributes.fetchpriority).toBe("low");
|
||||
|
||||
__non_webpack_require__("./125.js");
|
||||
import(/* webpackFetchPriority: "high" */ "./style.css");
|
||||
abortable(() => import(/* webpackFetchPriority: "high" */ "./style.css"));
|
||||
expect(document.head._children).toHaveLength(14);
|
||||
const link1 = document.head._children[13];
|
||||
expect(link1._attributes.fetchpriority).toBe("high");
|
||||
|
||||
__non_webpack_require__("./499.js");
|
||||
import("./style-1.css");
|
||||
abortable(() => import("./style-1.css"));
|
||||
expect(document.head._children).toHaveLength(15);
|
||||
const link2 = document.head._children[14];
|
||||
expect(link2._attributes.fetchpriority).toBeUndefined();
|
||||
|
||||
__non_webpack_require__("./616.js");
|
||||
import(/* webpackFetchPriority: "low" */ "./style-2.css");
|
||||
abortable(() => import(/* webpackFetchPriority: "low" */ "./style-2.css"));
|
||||
expect(document.head._children).toHaveLength(16);
|
||||
const link3 = document.head._children[15];
|
||||
expect(link3._attributes.fetchpriority).toBe("low");
|
||||
|
|
|
@ -57,9 +57,7 @@ describe("browserslist target", () => {
|
|||
["node 10.0.0"],
|
||||
["node 10.17.0"],
|
||||
["node 12.19.0"],
|
||||
|
||||
// UC browsers for Android
|
||||
["and_uc 12.12"],
|
||||
["node 13.12.0"],
|
||||
|
||||
// QQ browser
|
||||
["and_qq 10.4"],
|
||||
|
@ -73,6 +71,45 @@ describe("browserslist target", () => {
|
|||
// Multiple
|
||||
["firefox 80", "chrome 80"],
|
||||
["chrome 80", "node 12.19.0"],
|
||||
["chrome 80", "node 13.12.0"],
|
||||
|
||||
// defaults and fully supports es6-module
|
||||
// maintained node versions
|
||||
[
|
||||
"and_chr 140",
|
||||
"and_ff 142",
|
||||
"and_qq 14.9",
|
||||
"and_uc 15.5",
|
||||
"android 140",
|
||||
"chrome 140",
|
||||
"chrome 139",
|
||||
"chrome 138",
|
||||
"chrome 137",
|
||||
"chrome 112",
|
||||
"chrome 109",
|
||||
"chrome 105",
|
||||
"edge 140",
|
||||
"edge 139",
|
||||
"edge 138",
|
||||
"firefox 143",
|
||||
"firefox 142",
|
||||
"firefox 141",
|
||||
"firefox 140",
|
||||
"ios_saf 26.0",
|
||||
"ios_saf 18.5-18.6",
|
||||
"kaios 3.0-3.1",
|
||||
"node 24.8.0",
|
||||
"node 22.19.0",
|
||||
"node 20.19.0",
|
||||
"op_mob 80",
|
||||
"opera 122",
|
||||
"opera 121",
|
||||
"opera 120",
|
||||
"safari 26.0",
|
||||
"safari 18.5-18.6",
|
||||
"samsung 28",
|
||||
"samsung 27"
|
||||
],
|
||||
|
||||
// Unknown
|
||||
["unknown 50"]
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProgressPlugin(),
|
||||
new webpack.ProgressPlugin(() => {}),
|
||||
{
|
||||
apply(compiler) {
|
||||
compiler.hooks.done.tapPromise("CacheTest", async () => {
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProgressPlugin(),
|
||||
new webpack.ProgressPlugin(() => {}),
|
||||
{
|
||||
apply(compiler) {
|
||||
compiler.hooks.done.tapPromise("CacheTest", async () => {
|
||||
|
|
Loading…
Reference in New Issue