Resolve accompanies to just the original import id#462
Resolve accompanies to just the original import id#462klaftertief wants to merge 1 commit intohmsk:mainfrom
Conversation
49f051c to
ec2a146
Compare
|
Uh, looks really simpler! However, we need to rely on plugin context to resolve importing. The relative path may include some alias or magic words to work with other plugins. But I'm curious about the problem you faced originally. Can you give me an easier way to reproduce that situation? |
|
Thanks for the quick response. I'll see if I can spin up a SSCCE... Good to know about the context to resolve imports. But does it really apply to Elm modules? The path/id of the original Elm module (as imported from JS) is not touched, everything
Can you give an example here? |
|
what if vite's config has alias setting like: We'd expect |
|
Thanks, yes, this would totally not work with this PR :-) |
b3d2607 to
df9eedf
Compare
b5c115a to
45186cb
Compare
Maybe I misunderstood how combining multiple main files worked, at least I could not make it work for our use-case.
I really love how the feature is used by just adding multiple Elm modules as query params, this makes it super flexible.
We have four different Elm apps which should be compiled into one bundle. There are four different JS modules that import the combined Elm apps individually. So
index-a.js,index-band so on each importA.elm?with=B.elm&with=C.elm&with=D.elm. This is simplified, as the JS and Elm entry points might live at different directory levels. It worked at some cases, but adding the fourth Elm module to the list made it break. I believe this was caused by setting a wrongimporterwhen walking the import tree in the original implementation. I do not know a lot about Vite's or Rollup's internals, but it made me wonder if it is actually needed.In this PR I made it such that the path in each
withparam is relative to the originally required Elm module,A.elmin this case. So in the implementation I use a simplepath.resolveto add each accompany to the list of compilable Elm modules. It is much simpler and is something I can understand. But I also have a feeling I'm missing something in the original implementation.