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

Gets a basic deep module reference test working with 1.1.0 node-resolve #54

Merged
merged 1 commit into from
Feb 8, 2015

Conversation

justinbmeyer
Copy link
Contributor

For #51, this uses the 1.1.0 node-resolve to make deep module references mappable.

It works by adding a pathFilter that checks browser for a matching key and returns that value. It handles if the user does or does not end the map with .js.

It includes a test.

Thanks!

@@ -73,6 +73,15 @@ test('object browser field as main', function(done) {
});
});

test('deep module reference mapping', function(done) {
resolve('module-l/direct', { basedir: __dirname+"/fixtures", package: { main: 'fixtures' } }, function(err, path, pkg) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quotes please

@defunctzombie
Copy link
Collaborator

@justinbmeyer This is all that is necessary to make direct require work and be able to shim via browser field in the nested modules?

@defunctzombie
Copy link
Collaborator

Once you make the style changes, please squash into a single commit and reference the original discussion as you have. Great job on following this through!

@justinbmeyer
Copy link
Contributor Author

@defunctzombie Yes, it seems like this is all that is needed as most of the hard work is now being done in node-resolve. I tested this against the workflow in CanJS (where CanJS has everything in dist/cjs) that uses browserify and it worked right.

I will hopefully get the pull request cleaned up for tomorrow. Thanks!

@justinbmeyer
Copy link
Contributor Author

Updated. Thanks!

defunctzombie added a commit that referenced this pull request Feb 8, 2015
Gets a basic deep module reference test working with 1.1.0 node-resolve
@defunctzombie defunctzombie merged commit ae6f1e3 into browserify:master Feb 8, 2015
@defunctzombie
Copy link
Collaborator

published in v1.7.0

Thanks!

@mantoni
Copy link

mantoni commented Feb 9, 2015

Now this seems to break browserify for me when I resolve files that are not .js files. I'm using custom transforms to precompile hogan templates which stopped working. If I manually downgrade browser-resolve to v1.6 it works fine again. But v1.7 is picked up by the current browserify release.

@justinbmeyer
Copy link
Contributor Author

@mantoni Can you add a breaking test? Or give a small breaking example. What error do you get? I can get in a patch asap.

@mantoni
Copy link

mantoni commented Feb 9, 2015

@justinbmeyer Thanks. Had to run away. Will try and isolate tomorrow.

return;
}

if(typeof info.browser) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be if (typeof info.browser === 'object')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugg, patch incoming

Sent from my iPhone

On Feb 10, 2015, at 2:10 AM, Maximilian Antoni notifications@github.com wrote:

In index.js:

  • opts.pathFilter = function(info, path, relativePath) {
  •   if(relativePath[0] != '.') {
    
  •       relativePath = './' + relativePath;
    
  •   }
    
  •   var mappedPath;
    
  •   if(pathFilter) {
    
  •       mappedPath = pathFilter.apply(this, arguments);
    
  •   }
    
  •   if(mappedPath) {
    
  •       return mappedPath;
    
  •   }
    
  •   if(!info.browser) {
    
  •       return;
    
  •   }
    
  •   if(typeof info.browser) {
    
    Shouldn't this be if (typeof info.browser === 'object')?


Reply to this email directly or view it on GitHub.

@mantoni
Copy link

mantoni commented Feb 10, 2015

Narrowed it down to this: browserify/resolve#69
Please consider nailing the dependency to resolve@1.0.0 for the time being.

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

Successfully merging this pull request may close these issues.

None yet

3 participants