From 58aafd143dabecd436cafc8066e9acbab913adf1 Mon Sep 17 00:00:00 2001 From: Ricardo Morin Date: Tue, 21 Jan 2020 14:09:40 -0800 Subject: [PATCH 1/4] Fix require for Node.js --- Source/Core/Resource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Resource.js b/Source/Core/Resource.js index 941fc1a42c36..504b028f3e4c 100644 --- a/Source/Core/Resource.js +++ b/Source/Core/Resource.js @@ -1902,7 +1902,7 @@ import TrustedServers from './TrustedServers.js'; // Specifically use the Node version of require to avoid conflicts with the global // require defined in the built version of Cesium. - var nodeRequire = global.require; // eslint-disable-line + var nodeRequire = global.require ? global.require : require; // eslint-disable-line // Note: only the 'json' and 'text' responseTypes transforms the loaded buffer var URL = nodeRequire('url').parse(url); From d11b2c0e435607e28c934117959ff885a7bce9f1 Mon Sep 17 00:00:00 2001 From: Ricardo Morin Date: Tue, 21 Jan 2020 14:13:26 -0800 Subject: [PATCH 2/4] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 993ae2a159dc..1ec0025ce023 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -244,3 +244,5 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Tinco Andringa](https://github.com/tinco) * [André Borud](https://github.com/andreborud) * [Nathan Schulte](https://github.com/nmschulte) +* [Ricardo Morin](https://github.com/jimmyangel) + From f3700f26e39c3a53401d57089fa37b60039415e1 Mon Sep 17 00:00:00 2001 From: Ricardo Morin Date: Wed, 29 Jan 2020 12:01:44 -0800 Subject: [PATCH 3/4] Use "require" directly --- Source/Core/Resource.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Source/Core/Resource.js b/Source/Core/Resource.js index 504b028f3e4c..5289096b4c05 100644 --- a/Source/Core/Resource.js +++ b/Source/Core/Resource.js @@ -1899,15 +1899,10 @@ import TrustedServers from './TrustedServers.js'; } function loadWithHttpRequest(url, responseType, method, data, headers, deferred, overrideMimeType) { - - // Specifically use the Node version of require to avoid conflicts with the global - // require defined in the built version of Cesium. - var nodeRequire = global.require ? global.require : require; // eslint-disable-line - // Note: only the 'json' and 'text' responseTypes transforms the loaded buffer - var URL = nodeRequire('url').parse(url); - var http = URL.protocol === 'https:' ? nodeRequire('https') : nodeRequire('http'); - var zlib = nodeRequire('zlib'); + var URL = require('url').parse(url); + var http = URL.protocol === 'https:' ? require('https') : require('http'); + var zlib = require('zlib'); var options = { protocol : URL.protocol, hostname : URL.hostname, From 8df711f95a1e8198c1fde18c2d75f0dc883292cb Mon Sep 17 00:00:00 2001 From: Ricardo Morin Date: Wed, 29 Jan 2020 19:23:13 -0800 Subject: [PATCH 4/4] Disable eslint for require --- Source/Core/Resource.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Resource.js b/Source/Core/Resource.js index 5289096b4c05..f17caa2ab79c 100644 --- a/Source/Core/Resource.js +++ b/Source/Core/Resource.js @@ -1900,9 +1900,9 @@ import TrustedServers from './TrustedServers.js'; function loadWithHttpRequest(url, responseType, method, data, headers, deferred, overrideMimeType) { // Note: only the 'json' and 'text' responseTypes transforms the loaded buffer - var URL = require('url').parse(url); - var http = URL.protocol === 'https:' ? require('https') : require('http'); - var zlib = require('zlib'); + var URL = require('url').parse(url); // eslint-disable-line + var http = URL.protocol === 'https:' ? require('https') : require('http'); // eslint-disable-line + var zlib = require('zlib'); // eslint-disable-line var options = { protocol : URL.protocol, hostname : URL.hostname,