Skip to content
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

Handle commonjs require('./someDirName') #34

Closed
anodynos opened this issue Nov 4, 2013 · 5 comments
Closed

Handle commonjs require('./someDirName') #34

anodynos opened this issue Nov 4, 2013 · 5 comments

Comments

@anodynos
Copy link
Owner

anodynos commented Nov 4, 2013

CommonJs/nodejs has require('./someDirName') which simply looks and requires './someDirName/index.js'

  • uRequire should make sure it finds it in AMD/UMD.
  • Taking it further, when there is no 'index.js', it could by default try create stub objects with all modules names as keys and the module as value, ie
/someDirName/
   - moduleA.js
   - moduleB.js

where require('./someDirName') would return a generated object

{ moduleA: require('moduleA'),  moduleB: require('moduleB') }

What about nested subdirectories inside 'someDirName' ?

@willprice
Copy link

If one were to implement this (importing index.js), which test cases would be the most relevant to look at? I might have a bash at this.

@anodynos
Copy link
Owner Author

anodynos commented Aug 8, 2014

Unfortunatelly the /process directory is fabulously absent from the unit tests :-( That where reading filenames and instantiating BundleFiles takes place.

In short we need to replace dependencies like 'some/path/directory' to 'some/path/directory/index' (when index.js is present), so it works on AMD/UMD properly.
I'll have a look on how to hack this quickly, so I can perhaps implement it or guide you to have a bash at it.

@anodynos
Copy link
Owner Author

The 'dirname/index.js' case is best handled at Dependency and be transparent in all other parts - Ill have a go about it.

@willprice
Copy link

Awesome, thanks.

On 13 August 2014 20:32, Agelos Pikoulas notifications@github.com wrote:

The 'dirname/index.js' case is best handled at Dependency
https://github.com/anodynos/uRequire/blob/master/source/code/fileResources/Dependency.coffee
and be transparent in all other parts - Ill have a go about it.


Reply to this email directly or view it on GitHub
#34 (comment).

[image: --]
Will Price
[image: http://]about.me/will_price
http://about.me/will_price

@anodynos
Copy link
Owner Author

Hey @willprice check it out - appending /index in the dependency should work on both commonjs and AMD/UMD in version 0.6.19. Let me know if it worked OK for your project.

*Note that the 2nd part (automatic generation of index.js) is not dealt with - you need to have index.js or index.coffee etc in place *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants