-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
js: Add Shims option #8165
Comments
This sounds like a worthwhile improvement. It felt heavy to edit package.json and force the shims to be a project-wide setting. Is this enabled by a new feature in ESBuild? I remember this issue where the ESBuild creator recommended the package.json |
It's the "import resolver" plugin feature. Not very new. Note that my main problem isn't the package.json editing -- it's the project relative (or absolute) file paths. |
Got it. Well I support the change, happy to review or update documentation when it's time. |
I think it would be a good idea. I don't understand how the compiled shims' |
In my head, this should just work. |
But, @chrischute -- a question: Given that you have React/ReactDOM included from CDN, what are the scenarios where you need to do an import? I can understand third-party apps, but in your own files? I'm trying to come up with a failing example, but now all my earlier test setups seems to work fine without any react imports, even though I swear they didn't before... |
I might be misunderstanding the question, but the main reason I import React is to make the IDE happy. I.e., I want to locally have React in my package for code completion, but want to use the CDN in production. Does that answer your question? |
It does; I have, however, not looked at this problem with those eyes. |
OK great, maybe you can see an easier solution given this info. |
This is very similar to using jsconfig or tsconfig files. ESBuild still does read those to resolve import and require. Using a shims variable is probably more elegant although jsconfig and tsconfig are read and understood by visual studio and adding production version of jsconfig or tsconfig is possible. Adding shims is definitely more elegant. |
This commit adds a new `shims` option to `js.Build` that allows swapping out a component with another. Fixes gohugoio#8165
This commit adds a new `shims` option to `js.Build` that allows swapping out a component with another. Fixes #8165
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is meant to improve the situation as described in https://gohugo.io/hugo-pipes/js#shimming-a-js-library
The above works, but it
package.json
I have invested some time today looking for a better way, and to cut a very long story short:
I suggest we add add a
shims
config option that works similar to thebrowser
element inpackage.json
, but resolves files inside the compositeassets
. So you would do:You obviously still needs to create the shim files, but that is simple enough. Thoughts?
I have tested the above, and it works.
/cc @chrischute @richtera
The text was updated successfully, but these errors were encountered: