-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Browserify: "Cannot find module './aes'" #294
Comments
Revamping the module system is on the roadmap -- we jotted down some preliminary ideas here: #126. In general, we need to get a tool chain setup that can wrap forge modules in a variety of different ways for different loaders (AMD/CommonJS/browserify/etc). Just haven't had the time to get to it yet; PRs welcome! But, we could potentially look into the kind of change you're talking about as a near term fix for browserify should some time shake loose. We need to ensure that any change doesn't cause havoc with the other ways people are loading the library, which means better module loader tests are needed as well. |
for what it's worth, I was able to workaround this by generating and using the standalone forge bundle and then replacing every occurrence of In package.json: "dependencies": {
"node-forge": "0.6.40"
},
"main": "main.js",
"scripts": {
"forge": "(cd node_modules/node-forge && npm install && npm run bundle && cp js/forge.bundle.js ../../)",
"build": "npm run forge && browserify main.js | sed \"s/require[(]'node-forge'[)]/window.forge/g\" > bundle.js"
} Then in the HTML: <head>
<script src="forge.bundle.js"></script>
<script src="bundle.js"></script>
</head> |
Should hopefully be solved by #357 (comment). |
Should be addressed in a new release now that #456 has been merged. |
When packaging your library into a browserify project, I get
For a module to work in browserify, its
require()
s need to be statically analyzable. I'm not sure the easiest way to do that for you, but just puttingwould probably do the trick. I know it is duplicative, so maybe you can find a way that isn't duplicating code but yet is still statically analyzable.
One way to test would probably be this:
And make it so that it doesn't throw anymore.
The text was updated successfully, but these errors were encountered: