-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat(ui5-tooling-modules): respect cjs file extensions and try bundling them as well #595
Conversation
this helps as it uses the nodeResolve plugin to look for esm modules in the dependencies which does not work with require.resolve (for my understanding)
IMO, this PR should be rejected and closed. Looking in the |
thank you for the input! I thought this could lead to issues but wasn't sure (worked fine for me, in my case of course ^^), that's why I went with proposing this PR.
I'm not sure in what way I could tell the UI5 tooling (in my case) to pull in the appropriate module type then. So far I simply relied on ui5-tooling-modules to do the job (previously to this, I used shimming a while back). But here |
I believe it has more to do with the way the module is resolved and consumed by See the entry points in marked's package.json. At this moment, |
This makes so much sense(!) and is rather eye-opening and in line with what I read up and thought during the analysis of my problem. That also easily explains why the rollup node resolve part "just works". Thank you, much appreciated! (: I was looking a bit into the require.resolve part at first and thought that in there a "solution" should be found as this seems to be the "root" of the issue. I'm not that experienced here so after some time I went on to then find out the, in this PR proposed, "solution" ... because it worked. ^^ As you already said, this PR could and probably should then be rejected & closed. I'm a bit curious however how this might go on / move forward. I'll keep looking if time allows and will obviously keep observing closely. :P |
@mauriciolauffer @wridgeu regarding ignoring the
{
"dependencies": {
"chart.js": "*"
}
}
import { Chart } from "chart.js" ``: "main": "dist/chart.js",
"module": "dist/chart.esm.js", This is the benefit of the usage of the |
One thing which we could try to leverage the |
@petermuessig indeed, following the PS: I didn't say it's ignoring |
This sounds great. Although I wouldn't know how to go about this for now. From what I have read though this is not possible with the "native" Maybe I've read the docs wrong but I'll keep checking back on this & reading up on it if time allows it. Thanks for the feedback to both of you, much appreciated & a lot learned. :) I'd say we could close this PR then and open up an Issue instead. ^^ |
I've made an Issue out of this, thanks for the feedback! Learned a lot. :) Issue: #602 |
Hey there 👋
this is my first PR in the ecosystem showcase so I hope things aren't too out of hand. Even though the actual change is quite small. 😅
I've had the issue (also described in a bit more detail further below) that one of my third party libraries (marked.js to be precise) swapped their build between versions 4.0.1 and 4.0.2 (this PR).
As far as I understand the
require.resolve
is able to successfully determine the dependency path, however in this particular case it is the.cjs
build of marked. Looking through the code a bit more I realized that maybe using rollup withinutil.js
could also solve my issues here. Sure enough by already using the rollup node resolve plugin, the proper esm build can be "pulled" or rather bundled up and be used accordingly. This fixes my issues during dev but also build time.Here is some more information (including a few twitter threads that I created when looking into this ^^). Maybe this help to determine if this is even a valid approach or something else could've been done ...
I haven't done a lot when it comes to this but I've been debugging the whole AST, Espree, Acorn stuff the past few days and was able to learn a bit at least. If there is anything I might have missed in my thoughts or if this is a bad idea or should be resolved differently then I'd love to know! Maybe then I should create an Issue rather than a PR. (:
I made sure that running
yarn dev
will result in a still functioning demo app and that it still successfully loads chart.js. ^^Thanks for reading all this!
BR,
Marco