There are libraries that do not follow the naming patterns we're trying to match.
A few examples are:
Suggested:
"moment-timezone": "https://unpkg.com/moment-timezone@^0.5.27/index.js",
"moment": "https://unpkg.com/moment@^2.24.0/moment.js",
"tinycolor2": "https://unpkg.com/tinycolor2@^1.4.1/tinycolor.js"
Should be:
"moment-timezone": "https://unpkg.com/moment-timezone@^0.5.27/builds/moment-timezone-with-data.min.js",
"moment": "https://unpkg.com/moment@^2.24.0/min/moment.min.js",
"tinycolor2": "https://unpkg.com/tinycolor2@^1.4.1/dist/tinycolor-min.js"
I was thinking about adding a rule dedicated to handling those exceptions. It won't be perfect but at least we'd be able to start addressing the "odd" recommendations. Thoughts?
Isn't there a way to retrieve those names from somewhere like package.json?
for the examples I provided the package.json main points to the suggestion we've made.
We could try the jspm/main and jspm/files properties as well. But then if we get multiple results, how could we decide which one is authority?
I would prefer to avoid exceptions, because once we go down that route, there is no end to it and it will be close to impossible to maintain it.
Agreed, it's a rabbit hole we should try to avoid for as long as we can.
The only things I can suggest:
This way we could implement something like
With this approach we should be able to cover more cases, and provide better suggestions for the ones that have multiple possibilities.
The only thing is that it requires changes on Rencore's API, and I'm not sure if this is possible/how long it will take/etc...
What do you think?
We've updated the API and a new version that exposes the detected type is available at https://scriptcheck-weu-fn.azurewebsites.net/api/v2/script-check
Great! do you have a mapping of the values it returns?
ok so after some poking around your API and guessing here is what I think it returns and the action we should take based on the return information:
Am I missing anything else?
Correct, these are the four values supported at the moment. I'm not sure how easy it is to handle dependencies, so let's leave that aside for now and see if it's needed. I could see if I can get the global name for UMD in the API.
thanks, and to be clear "module" and "script" are gone now?
Yes. Now we have the 4 values you mentioned, plus non-module if the detected script is not a module.