mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
register: allow load sourcemap from file
This commit is contained in:
1 file changed
+6
@@ -50,6 +50,12 @@ require.extensions['.js'] = function loader(module, filename) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(filename, 'utf-8');
|
const content = fs.readFileSync(filename, 'utf-8');
|
||||||
|
const lastLine = content.trim().split('\n').pop();
|
||||||
|
if (lastLine.startsWith('//# sourceMappingURL=data:application/json;base64,')) {
|
||||||
|
const info = lastLine.split('//# sourceMappingURL=data:application/json;base64,')[1];
|
||||||
|
const payload = JSON.parse(Buffer.from(info, 'base64').toString());
|
||||||
|
map[filename] = payload;
|
||||||
|
}
|
||||||
return module._compile(content, filename);
|
return module._compile(content, filename);
|
||||||
} catch (e) { // ESM
|
} catch (e) { // ESM
|
||||||
return module._compile(transform(filename), filename);
|
return module._compile(transform(filename), filename);
|
||||||
|
|||||||
Reference in new issue
Block a user