Make env preset build-data scripts reproducible (#8299)
This commit is contained in:
parent
301db1b921
commit
f2fd9e982e
@ -60,8 +60,8 @@
|
|||||||
"@babel/core": "7.0.0-beta.52",
|
"@babel/core": "7.0.0-beta.52",
|
||||||
"@babel/helper-fixtures": "7.0.0-beta.52",
|
"@babel/helper-fixtures": "7.0.0-beta.52",
|
||||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.52",
|
"@babel/helper-plugin-test-runner": "7.0.0-beta.52",
|
||||||
|
"caniuse-db": "1.0.30000851",
|
||||||
"compat-table": "kangax/compat-table#90d02e486227d179d2ce9b850dbb3f9846443cab",
|
"compat-table": "kangax/compat-table#90d02e486227d179d2ce9b850dbb3f9846443cab",
|
||||||
"electron-to-chromium": "^1.3.27",
|
"electron-to-chromium": "1.3.48"
|
||||||
"request": "^2.83.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,43 +1,18 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const request = require("request");
|
|
||||||
|
|
||||||
// This mapping represents browsers who have shipped ES Modules Support.
|
const moduleSupport = require("caniuse-db/features-json/es6-module.json");
|
||||||
// For more information, checkout the specifications:
|
|
||||||
// * https://www.ecma-international.org/ecma-262/6.0/#sec-modules
|
|
||||||
// * https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
|
|
||||||
const lastKnown = {
|
|
||||||
chrome: 61,
|
|
||||||
safari: 10.1,
|
|
||||||
ios_saf: 10.3,
|
|
||||||
edge: 16,
|
|
||||||
};
|
|
||||||
|
|
||||||
const acceptedWithCaveats = {
|
const acceptedWithCaveats = {
|
||||||
safari: true,
|
safari: true,
|
||||||
ios_saf: true,
|
ios_saf: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
function input() {
|
const { stats } = moduleSupport;
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
request(
|
|
||||||
"https://raw.githubusercontent.com/Fyrd/caniuse/master/features-json/es6-module.json",
|
|
||||||
function(error, response, body) {
|
|
||||||
if (error || response.statusCode !== 200) {
|
|
||||||
return reject(
|
|
||||||
new Error(
|
|
||||||
`Error retrieving es6-module.json. ${
|
|
||||||
error ? error : `statusCode=${response.statusCode}`
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
const allowedBrowsers = {};
|
||||||
const { stats } = JSON.parse(body);
|
|
||||||
const allowedBrowsers = {};
|
|
||||||
|
|
||||||
Object.keys(stats).forEach(browser => {
|
Object.keys(stats).forEach(browser => {
|
||||||
if (browser !== "and_chr") {
|
if (browser !== "and_chr") {
|
||||||
const browserVersions = stats[browser];
|
const browserVersions = stats[browser];
|
||||||
const allowedVersions = Object.keys(browserVersions)
|
const allowedVersions = Object.keys(browserVersions)
|
||||||
@ -53,25 +28,10 @@ function input() {
|
|||||||
allowedBrowsers[browser] = allowedVersions[0].split("-")[0];
|
allowedBrowsers[browser] = allowedVersions[0].split("-")[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve(allowedBrowsers);
|
const dataPath = path.join(__dirname, "../data/built-in-modules.json");
|
||||||
} catch (error) {
|
const data = {
|
||||||
return reject(new Error(`Error parsing es6-module.json.`));
|
"es6.module": allowedBrowsers,
|
||||||
}
|
};
|
||||||
}
|
fs.writeFileSync(dataPath, `${JSON.stringify(data, null, 2)}\n`);
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function output(minVersions) {
|
|
||||||
const dataPath = path.join(__dirname, "../data/built-in-modules.json");
|
|
||||||
const data = {
|
|
||||||
"es6.module": minVersions,
|
|
||||||
};
|
|
||||||
fs.writeFileSync(dataPath, `${JSON.stringify(data, null, 2)}\n`);
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.resolve(input())
|
|
||||||
.then(minVersions => output(minVersions))
|
|
||||||
.catch(output(lastKnown));
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user