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

processing index.js files #4

Closed
shaunc opened this issue Nov 24, 2015 · 2 comments
Closed

processing index.js files #4

shaunc opened this issue Nov 24, 2015 · 2 comments

Comments

@shaunc
Copy link

shaunc commented Nov 24, 2015

I have been compiling successfully using this example for a couple months. However, recently I have refactored, which involved putting code in src/save/index.js:

import {parse} from '../parse/parse';

In dist/save/index.js this translates to:

var _parseParse = require('parse/parse');

which isn't correct and fails.

I notice in the Brocfile, there is

// Fix relative imports inside /index's
resolveModuleSource: function (source, filename) {
  var match = filename.match(/(.+)\/index\.\S+$/i);

  // is this an import inside an /index file?
  if (match) {
    var path = match[1];
    return source
      .replace(/^\.\//, path + '/')
      .replace(/^\.\.\//, '');
    return ns;
  } else {
    return source;
  }
}

However, this seems not to be called -- when I put diagnostics in this function, they are never triggered. In any case, the content is mystifying: in particular

      .replace(/^\.\.\//, '');

just gets rid of ".." ... certainly seems wrong to me, though I don't know what the input looks like as I couldn't get debugger to stop here or to print anything out. Is this a problem here, or perhaps with broccoli-babel-transpiler (as resolveModuleSource seems not to be called)?

UPDATE

Was using broccoli-babel-transpiler v5.4.5. When I updated to 5.5.0, I can now see my diagnostics (so resolveModuleSource is being called). The resulting "require" remains the same, though.

@shaunc
Copy link
Author

shaunc commented Nov 24, 2015

(As you may recall, I'm using this in a node project.)
#2

I guess the resolveModuleSource is there for web projects in any case. For use in node, its not needed (and breaks things, as I just learned). Getting rid of it in the Brocfile resolves this issue.

@shaunc shaunc closed this as completed Nov 24, 2015
@givanse
Copy link
Owner

givanse commented Nov 24, 2015

I'm glad you figured it out, thanks for reporting back!

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

No branches or pull requests

2 participants