Closed joananespina closed 5 years ago
Just to clarify, adding bcrypt.js
using script tag will make dcodeIO
undefined.
So after reading a past issue I needed to use import
to make it work, so what I did was:
import("/path/to/bcrypt.min.js").catch((error)=>{ // console.log(error); // This throws a });
This method worked and dcodeIO
is now available, however, this also throws a TypeError: Cannot read property 'Promise' of undefined
error.
Can anyone confirm that these are normal behaviors when using bcrypt.js
on a browser?
Just pointing this out. In my last message, the import()
method only worked with Chrome, it failed on Firefox. I tried modifying the code to a simple encapsulated function, but I am afraid that it might cause some issues (although it looks like it wouldn't?), so just to be safe I am reverting back to using require.js
.
Closing this unless someone can give some feedback?
I was able to get rid of this TypeError by using the unminified version and changing the value of global
from this
to window
where it is injected into the loader function:
(function(global, factory) {
/* AMD */ if (typeof define === 'function' && define["amd"])
define([], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === "object" && module && module["exports"])
module["exports"] = factory();
/* Global */ else
(global["dcodeIO"] = global["dcodeIO"] || {})["bcrypt"] = factory();
}(this, function() {
Look for that code block and make the change on the last line. Seems to work fine so far.
Hello, I am working on a webapp project that uses bcrypt.js. Right now I am using the Require.js route to load bcrypt.js:
But I want to try to load it in the browser without Require.js to lessen my project's pageload, because I am only using Require.js to load bcrypt.js. Right now the only documentation I see is to use
var bcrypt = dcodeIO.bcrypt;
, butdcodeIO
is undefined when I load bcrypt.js using script tags?