-
Notifications
You must be signed in to change notification settings - Fork 58
Unable to import module as directory #37
Comments
same issue as this, please take a look in, thanks! |
I did quick look into the code and it seems to be working only with files. This may be greater modification, than I thought. Unfortunately I have no idea of rollup and rollup plugin system. I am wondering, if behaviour:
would do the trick. I am going to experiment a little. But - for me at least - it looks like hackish solution. |
…ectory/index.js), fix rollup#37
@lduoduo you may be interested in my PR. |
Thank you for writing up this issue, we had a similar pull request some time ago: #25 The responsibility of this plugin is to only handle aliases, not to handle Node's resolution mechanism. If you would like to use that functionality, please use Please feel free to re-open if you think this is not resolved. |
Can you provide us with working example? Because AFAIR it's impossible to combine these two modules, to achieve appropriate effect. |
as example:
|
HackI got it working for the else if (fs.existsSync(path.resolve(filePath, 'index.js'))) {
updatedId = filePath + '/index.js'
} Before you get too excited, this only handles that case, so if your needs are more complex ( ThoughtsAfter reading the issues here, on rollup-plugin-node-resolve, and rollup it seems that we're basically in a stalemate. Both plugin authors assert that their plugin isn't responsible for the duties (even partially so) of the other and I agree with them. Doing so would introduce more complexity and hence more opportunity for bugs–not to mention a higher maintenance cost. The root cause seems to be due to rollup not passing the module id to other plugins once it is resolved. While I think that rollup having some mechanism for passing the module id to other plugins is likely the better way to go, in the meantime people who use this for their projects have to get things done and so hacks like mine above wind up being the (hopefully temporary) compromise. |
I cannot load modules as
import x from '@/directory'
(wheredirectory
containsindex.js
).My config:
What doesn't work
import x from '@/directory'
What works
import x from './directory'
import x from '@/directory/index.js'
The text was updated successfully, but these errors were encountered: