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

Compatibility with babel-plugin-import-glob #180

Closed
lukescott opened this issue May 16, 2017 · 6 comments
Closed

Compatibility with babel-plugin-import-glob #180

lukescott opened this issue May 16, 2017 · 6 comments

Comments

@lukescott
Copy link

lukescott commented May 16, 2017

I'm a contributor of babel-plugin-import-glob. I'm trying to get it working with this plugin. I have two issues:

1:

module-resolver does its transformation after import-glob. It looks like there are 4 ways to do transformations.

// Program enter:
visitor: {
  Program: {
    enter: (programPath, state) {
      programPath.traverse(importVisitors, state);
    }
  }
}
// Program exit:
visitor: {
  Program: {
    enter: (programPath, state) {
      programPath.traverse(importVisitors, state);
    }
  }
}
// Program:
visitor: {
  Program(programPath, state) {
    programPath.traverse(importVisitors, state);
  }
}
// "direct":
visitor: importVisitors

I'm not sure which one is best. I could change import-glob to exit and have it pick up the new path. So I do have a solution for this one. Just thought I would bring it up anyway - perhaps babel has introduced new ways of ordering plugins?

2:

module-resolver doesn't resolve unless it can find the file. So if I have something like src/field/*/component.js it won't resolve the file. Then import-glob can't find it either because the src/field part was not resolved.

I'm not sure how to solve this one. Both plugins want to resolve the file(s). Ideally I would like a way to resolve the src/field part of the path, ignoring (and preserving) the */components.js part.

@fatfisz
Copy link
Contributor

fatfisz commented May 17, 2017

Thanks for the detailed issue, I'll be able to take a look at this in a few hours.

Possible solution I see is silencing warnings for some paths as a config option.

@fatfisz
Copy link
Contributor

fatfisz commented May 17, 2017

The newest beta version should be working before every other plugin if it is placed before them. The module-resolver plugin is now traversing the whole file on Program enter.

I need to think a bit on the second problem. @tleunen Maybe you know how to handle this situation well?

@tleunen
Copy link
Owner

tleunen commented May 18, 2017

This is really a complex problem, because one plugin requires the other to fully resolve the path...

The only thing I'd see would be to provide a custom way to resolve the path (see #165), so the user could use something internal from the glob import inside our plugin

@fatfisz
Copy link
Contributor

fatfisz commented Jun 5, 2017

I was thinking about this recently; maybe we could allow aliasing for all the paths? Normal aliases wouldn't be affected if they weren't starting with "." or "/" already, and RegExp aliases could be used to provide the root.

@tleunen
Copy link
Owner

tleunen commented Jun 6, 2017

So, removing the check for a valid path? It would work for the alias (actually, the first version didn't check the validity), but how would you make the root resolution then?

@tleunen
Copy link
Owner

tleunen commented Dec 11, 2017

Closing because of inactivity.

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

3 participants