mirror of
https://github.com/emn178/js-sha256.git
synced 2026-08-12 20:32:16 +08:00
fix recognize environment is node when use browserfs #53
This commit is contained in:
+5
-4
@@ -5,10 +5,11 @@ const disableNodeJs = {
|
||||
name: 'disable-node-js',
|
||||
transform(code, id) {
|
||||
if (id.endsWith('/src/sha256.js')) {
|
||||
return code.replace(
|
||||
"var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node && process.type != 'renderer';",
|
||||
'var NODE_JS = false;'
|
||||
);
|
||||
const nodeJsDeclaration = /^\s*var NODE_JS = .*;$/m;
|
||||
if (!nodeJsDeclaration.test(code)) {
|
||||
this.error('Could not find the NODE_JS declaration');
|
||||
}
|
||||
return code.replace(nodeJsDeclaration, ' var NODE_JS = false;');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user