Remove xhr2 dependency.

This commit is contained in:
Dillon Kearns 2021-07-07 08:56:58 -07:00
parent d22a663a90
commit b38815170f
4 changed files with 8 additions and 19 deletions

View File

@ -30,7 +30,9 @@ async function ensureRequiredDirs() {
async function run(options) {
await ensureRequiredDirs();
XMLHttpRequest = require("xhr2");
// since init/update are never called in pre-renders, and DataSource.Http is called using undici
// we can provide a fake HTTP instead of xhr2 (which is otherwise needed for Elm HTTP requests from Node)
XMLHttpRequest = {};
const generateCode = codegen.generate();

View File

@ -22,7 +22,9 @@ module.exports =
* @returns
*/
async function run(elmModule, path, request, addDataSourceWatcher) {
XMLHttpRequest = require("xhr2");
// since init/update are never called in pre-renders, and DataSource.Http is called using undici
// we can provide a fake HTTP instead of xhr2 (which is otherwise needed for Elm HTTP requests from Node)
XMLHttpRequest = {};
const result = await runElmApp(
elmModule,
path,

16
package-lock.json generated
View File

@ -24,8 +24,7 @@
"object-hash": "^2.2.0",
"serve-static": "^1.14.1",
"terser": "^5.7.0",
"undici": "^4.1.0",
"xhr2": "^0.2.1"
"undici": "^4.1.0"
},
"bin": {
"elm-pages": "generator/src/cli.js"
@ -5988,14 +5987,6 @@
}
}
},
"node_modules/xhr2": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.2.1.tgz",
"integrity": "sha512-sID0rrVCqkVNUn8t6xuv9+6FViXjUVXq8H5rWOH2rz9fDNQEd4g0EA2XlcEdJXRz5BMEn4O1pJFdT+z4YHhoWw==",
"engines": {
"node": ">= 6"
}
},
"node_modules/xmlbuilder": {
"version": "13.0.2",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz",
@ -10831,11 +10822,6 @@
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"requires": {}
},
"xhr2": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.2.1.tgz",
"integrity": "sha512-sID0rrVCqkVNUn8t6xuv9+6FViXjUVXq8H5rWOH2rz9fDNQEd4g0EA2XlcEdJXRz5BMEn4O1pJFdT+z4YHhoWw=="
},
"xmlbuilder": {
"version": "13.0.2",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz",

View File

@ -38,8 +38,7 @@
"object-hash": "^2.2.0",
"serve-static": "^1.14.1",
"terser": "^5.7.0",
"undici": "^4.1.0",
"xhr2": "^0.2.1"
"undici": "^4.1.0"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",