-
Notifications
You must be signed in to change notification settings - Fork 2.4k
How to load commonjs module from requirejs, document not describe clearly. #1037
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
Comments
packages config is only for dealing with code that is laid out using a package directory structure like the Packages spec mentioned on the CommonJS site, it is not about understanding how to load a CommonJS-formatted module. If you want that, then cajon might be a better loader option. Closing as I think the cajon loader is a better fit for the described use case. |
The document described folder structure, but it never said what the it is export.foo = 'bar' // I think this is a CommonJS module define or
But what a RequireJS supported CommonJS Packages's main javascript file content look like, docs never metioned. |
That makes sense, will reopen to track a doc fix to explain more. |
Any intention to address this? Like reporter @guileen I've read all the documentation and I'm still baffled. I'm trying to use RequireJS to load the Node modules 'events' and 'util' but they just throw the error 'module is not defined'. |
This seems pretty well covered under http://www.requirejs.org/docs/commonjs.html, which is linked from the sidebar ("CommonJS Notes") and from the package config API section:
|
I follow http://requirejs.org/docs/api.html#packages to learn how RequireJs load CommonJS modules, but I can't get it.
I have below file.
foo/foo.js with content:
main.js:
But it said can't read bar of undefined
The text was updated successfully, but these errors were encountered: