MCPcopy
hub / github.com/webpack/webpack / resolve

Function resolve

lib/config/browserslistTargetHandler.js:66–484  ·  lib/config/browserslistTargetHandler.js::resolve
(browsers)

Source from the content-addressed store, hash-verified

64 * @returns {EcmaTargetProperties & PlatformTargetProperties & ApiTargetProperties} target properties
65 */
66const resolve = (browsers) => {
67 /**
68 * Checks all against a version number
69 * @param {Record<string, number | [number, number]>} versions first supported version
70 * @returns {boolean} true if supports
71 */
72 const rawChecker = (versions) =>
73 browsers.every((v) => {
74 const [name, parsedVersion] = v.split(class="st">" ");
75 if (!name) return false;
76 const requiredVersion = versions[name];
77 if (!requiredVersion) return false;
78 const [parsedMajor, parserMinor] =
79 class="cm">// safari TP supports all features for normal safari
80 parsedVersion === class="st">"TP"
81 ? [Infinity, Infinity]
82 : parsedVersion.includes(class="st">"-")
83 ? parsedVersion.split(class="st">"-")[0].split(class="st">".")
84 : parsedVersion.split(class="st">".");
85 if (typeof requiredVersion === class="st">"number") {
86 return Number(parsedMajor) >= requiredVersion;
87 }
88 return requiredVersion[0] === Number(parsedMajor)
89 ? Number(parserMinor) >= requiredVersion[1]
90 : Number(parsedMajor) > requiredVersion[0];
91 });
92 const anyNode = browsers.some((b) => b.startsWith(class="st">"node "));
93 const anyBrowser = browsers.some((b) => /^(?!node)/.test(b));
94 const browserProperty = !anyBrowser ? false : anyNode ? null : true;
95 const nodeProperty = !anyNode ? false : anyBrowser ? null : true;
96
97 return {
98 /* eslint-disable camelcase */
99 const: rawChecker({
100 chrome: 49,
101 and_chr: 49,
102 edge: 12,
103 class="cm">// Prior to Firefox 13, <code>const</code> is implemented, but re-assignment is not failing.
104 class="cm">// Prior to Firefox 46, a <code>TypeError</code> was thrown on redeclaration instead of a <code>SyntaxError</code>.
105 firefox: 36,
106 and_ff: 36,
107 class="cm">// Not supported in for-in and for-of loops
108 class="cm">// ie: Not supported
109 opera: 36,
110 op_mob: 36,
111 safari: [10, 0],
112 ios_saf: [10, 0],
113 class="cm">// Before 5.0 supported correctly in strict mode, otherwise supported without block scope
114 samsung: [5, 0],
115 android: 37,
116 and_qq: [10, 4],
117 class="cm">// Supported correctly in strict mode, otherwise supported without block scope
118 baidu: [13, 18],
119 and_uc: [12, 12],
120 kaios: [2, 5],
121 node: [6, 0]
122 }),
123 let: rawChecker({

Callers 15

getPromiseMethod · 0.85
storePromiseMethod · 0.85
getPromiseMethod · 0.85
storePromiseMethod · 0.85
isAlreadyRemovedFunction · 0.85
handleExternalsMethod · 0.85
getResolveMethod · 0.85
readResourceMethod · 0.85
_loadEnvMethod · 0.85
_loadFileMethod · 0.85
applyMethod · 0.85
_openPackMethod · 0.85

Calls 2

rawCheckerFunction · 0.85
testMethod · 0.45

Tested by 8

compileFunction · 0.68
compileFunction · 0.68
createCompilerFunction · 0.68
createStatsFunction · 0.68
compileFunction · 0.68
runFunction · 0.68
compileFunction · 0.68
runCompilerAsyncFunction · 0.68