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
importmap json does not include a package in package.json #52
Comments
Importmap is an alternative to yarn, not an addition to it. You use it instead of it. bin/importmap pin face-api |
@phanhaiquang if you try clearing your browser cache the default export issue should be resolved now. Unfortunately @tensorflowjs/core doesn't currently seem to be working with another error - I've create a JSPM project issue to track this in jspm/project#134, you can watch that issue further. |
Thank @guybedford . I clear cache and the error disappeared. But it faces another error as you mention. :( |
@dhh I saw your YouTube and you mention that we could also use importmap & yarn together. It is the way you added "trix" to package.json, and pin it in config/importmap.rb. I tried to do the same by adding the lib to package.json and pin it in config file. But I am not sure what is still missing. Do you mean that I could not pin a package inside node_modules ? And if I need to use the lib, I need to download the lib and put to "vendor" folder ? |
Those are two separate paths. It's either import map, and then you lean on the asset pipeline, where "trix" is made available by the Action Text gem, or you use JS bundling, and then we recommend jsbundling-rails. |
Thanks a lot @dhh for prompt response ! |
Hello, Replaying to @dhh's statement, what about using yarn to download js package, but not including with sprockets JS assets pipeline command I am struggling to take this path, but without success. BTW. When using |
The whole point of this importmap-rails setup is to avoid needing node as part of development or deployment. If you're already fine with using node, you can use jsbundling-rails instead. I don't think it makes sense to mix yarn with importmap-rails. vendor/javascript is correct. If we missed a spot, do open a PR with an update 🙏 |
Regarding to this particular package (face-api.js library), I could make it work by jsbulding and esbuild. But I really likes importmap so that I tried and could make it works finally. The reason that I could not "pin" to ES6 is that the package has an issue with ES6 as an earlier comment in this loop. Below are my steps
At the time when I did these steps, I tried "importmap pin" with --download and it does not work (--download was just supported in today release) so that I need to download manually. With latest importmap-rails version with --download, I think we can replace steps 1-4 by a single step. I also get trouble with "import" command. "import * as faceapi from ..." does not work. I need to use "import "vendor/face-api.js/dist/face-api.js"". |
Are you sure that face-api.js doesn't work via bin/importmap? Have you tried |
I used ES6 for that "importmap pin" and it has error. Googling shows that the error is not completely resolved (another error happens after i clean my cached) At that time, I did not try to change the provider from ES6 to JSPM (actually, I did not know that I can change. Because I did not read your readme carefull). |
Thanks for this tip. I want to dive more into Learning a lot, thanks for your support. I was impressed by quick response to my 1st note.
I prepared a pull request for this point. Please bear with me as this is my first commit to a public project on GitHub 😉 |
@phanhaiquang I managed to get the face-api case working on JSPM in jspm/project#134 (see the last sandbox link there). If you have any further issues with it feel free to follow up there. |
No, for my bad it just returns
|
Hi,
I am using "face-api.js" package (https://github.com/justadudewhohacks/face-api.js).
When I use "./bin/importmap pin face-api.js", there are packages added to config/importmap.rb and I have a problem with tslib because it does not provide default export. It seems that this is common issue with ES6 tslib.
So that I want to use package.json to manage this lib.
yarn add face-api.js
Then, I "pin" this inside config/importmap.rb
pin 'face-api.js'
Add it to application.js
import "face-api.js";
And, use it in my js component
import * as faceapi from "face-api.js";
After restart rails server, i got this error
---- error on my browser's console ----
Uncaught TypeError: Failed to resolve module specifier "face-api.js". Relative references must start with either "/", "./", or "../".
Rails server reports some more warning in console
---- rails server ----
Rendered logins/index.html.erb within layouts/application (Duration: 7.4ms | Allocations: 2177)
Importmap skipped missing path: face-api.js.js
I tried to change "face-api.js" to "face-api", but it does not work.
Using "importmap json" does not show this package in my import map
I am not sure what is missing. Could you please give a support ?
Thanks,
The text was updated successfully, but these errors were encountered: