-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Aurelia adds /index to modules path after ModuleConcatenationPlugin #156
Comments
When using Aurelia with Webpack, you should use a path that refer to an actual JS module rather than a folder. For a plugin local to your project, doing Resolving See the note in this section about how we changed the |
@jods4 thank you so much for pointing that; after I found the issue and debugged it, I didn't think about looking on the wiki, I went to the issues and found a couple related to the Now, I understand this correctly, the problem is not on either Wouldn't the fix I propose solve it? maybe with an extra condition just o be sure: if (
id.endsWith('/index') &&
!realModule.rawRequest.endsWith('index') &&
`${realModule.rawRequest}/index` === id
) {
...
} If you think this can cause another problem, can you tell me the reason? I'm no very familiar with how the plugin does certain stuff but I would like to understand it a little bit better :D. Also, in case that "fix" can't be implemented, wouldn't it be possible to add a warning log when It's kind of frustrating that the error doesn't give you a clue of what can be the reason for it; and then there's the fact that it only happens for some modules (the ones webpack wants to concatenate). Thanks! |
@homer0 Does it always work? If I have an Does it work when Aurelia resolves relative modules at runtime? Probably not, because unlike Node, the browser runtime can't know if a name is supposed to be a folder or a file, so it always assumes it's a file. Removing This is actually the main reason why we changed the Does it work well with dynamically built module names? e.g. data-driven I see where you're coming from and I agree that supporting this resolution logic would not be a bad thing. As it stands, I don't think this is safe to merge. That said, when we can't make it work, I'm 100% in favor of detecting and warning users early. Ideally with a suggested fix.
|
@jods4 Hey! sorry I couldn't reply before, a loooot of work :P. Thanks for the answer!
I understand this; in theory, we could add use
This I believe I don't understand; from what I could see, once the bundle is created, Aurelia doesn't care if it's a file or a directory, it's just the module ID on the webpack "container". This is actually how I discovered the first "symptom" of the issue: Aurelia was looking for
Not sure about this, nor about the following question about aliases. Now, regarding the other points:
Now, for the case of my app, I just disabled |
@homer0 no problem, it's the same here... Overwhelmed by work it took me 3 weeks to get back at you.
You can (not saying you should) use relative modules. For example I commonly see features or plugin entries just being a list like this: aurelia.globalResources([
PLATFORM.moduleName('./autoFocus'),
PLATFORM.moduleName('./data-tables'),
]); Those relatives path will be resolved to full module names by Aurelia. At runtime it can't say if current module path is a file or folder. It always assumes the former and resolution will fail. |
@jods4 Hey! no worries, same here. I'm actually using that syntax for some components, but while they may be resolved by Aurelia, what I got from debugging the bundle is that Once again, thanks! and I'll try to make some time for the PR, sorry! Edit: You can mark this as an "edge case" and close the issue :D. |
I'm submitting a bug report
3.0.0
Please tell us about your environment:
Operating System:
OSX 10.13.6
Node Version:
10.15.3
NPM Version:
6.4.1
JSPM OR Webpack AND Version
webpack 4.29.1
Browser:
all
Language:
ESNext
Current behavior:
When using
.plugin(PLATFORM.moduleName('my/plugin/path'))
on a production build, whereModuleConcatenationPlugin
runs by default, the module ends up on the bundle with the keymy/plugin/path/index
, so the app fails to run asmy/plugin/path
doesn't exist.Expected/desired behavior:
On the main
configure
of the app, use.plugin
for a local folder index file that includes a component/service/valueConverter, basically anything that theModuleConcatenationPlugin
may want to optimize:That's enough for
ModuleConcatenationPlugin
to try to putmy-constant
insidemy-module/index.js
and for thePreserveModuleNamePlugin
to changemodules/my-module
tomodules/my-module/index
.For
PreserveModuleNamePlugin
not to add the/index
.Not sure if this is the right way to do it, but if we add the following code before this line, it works:
I'm not that familiar with the module structure, so I'm not sure if we can "trust" in
rawRequest
The text was updated successfully, but these errors were encountered: