Closed john-999 closed 1 year ago
Did you take a look at this issue to see if something similar works for you?
Thanks for your reply.
Unfortunately, using the lodash-es
package does not seem to work - I get the error message:
[...] TypeError: The specifier “lodash/get” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
However, my importmap script
(which is always automatically generated by Rails) looks different from your example mentioned in #42:
<script type="importmap" data-turbo-track="reload">
{
"imports": {
//...
"i18n-js": "/assets/i18n-js-04b620e607b4a8fc4d369deb77ddaca4c314ff3f5b113425aa02a5463c0f2a03.js",
"bignumber.js": "/assets/bignumber.js-da37e3c473288a78d1c8f160c092a279052ebe856db1dcafe6e3d6d1b5afa239.js",
"lodash-es": "/assets/lodash-es-fe5434385acd06b4eed1fc708a6829d14f2a04a5586277d17c2fb7c39376efa4.js",
"make-plural": "/assets/make-plural-2d052f6889f01180b0da040eb353fe7f921e763196a1003a289337fa09a8f10d.js",
//...
}
}
</script>
An example of using i18n-js with importmaps (through esm.sh): https://codepen.io/fnando/pen/WNKejpx
Description
I have attempted to install, configure and use
i18n-js
via Importmaps (via Rails). Unfortunately, I get a ton of failing GET requests, where Lodash appears to look for the .js files using wrong paths.How to reproduce
The installation:
The resulting config/importmap.rb
All corresponding .js files are downloaded to:
The resulting importmap script looks like this:
The import statement in: my_app/javascript/controllers/my_controller.js
Some of the resulting failing requests, upon page load:
Let's take a look at the 1st failing request (line 1):
The request that has lead to this error shows: Lodash's
_.has
is the originThis .js file contains "problematic" import statements such as...
...as you can see in the full code:
Software: