mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
Fixes https://github.com/nodejs/loaders/issues/138 PR-URL: https://github.com/nodejs/node/pull/47824 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
23 lines
496 B
JavaScript
23 lines
496 B
JavaScript
import { get } from 'http';
|
|
|
|
export function load(url, context, nextLoad) {
|
|
if (url.startsWith('http://')) {
|
|
return new Promise((resolve, reject) => {
|
|
get(url, (rsp) => {
|
|
let data = '';
|
|
rsp.on('data', (chunk) => data += chunk);
|
|
rsp.on('end', () => {
|
|
resolve({
|
|
format: 'module',
|
|
shortCircuit: true,
|
|
source: data,
|
|
});
|
|
});
|
|
})
|
|
.on('error', reject);
|
|
});
|
|
}
|
|
|
|
return nextLoad(url);
|
|
}
|