You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note - webpack will use import(...) (we have other externals types, follow our docs to look find other possible values if you need) so if you need to support very old envs you need to think about other ways
One complicating factor is that the url for the import map is actually dynamically generated with hashes (url changes when file contents change) via a rails view helper and really looks like this:
What is http://localhost:3000/assets/rails-constants-0ac54660d36cd34c7e89b718a2521795e9a894af62143d83adcf0a786ee8badf.js format? Maybe you can a create github repo with an example of code and how you run, because your solution should work too
Also please run npm ls webpack (we should have webpack v5)
Activity
benlieb commentedon May 22, 2023
Is it possible to refer to importmap?
https://stackoverflow.com/questions/76309809/how-can-i-configure-webpack-to-use-external-javascript-module
alexander-akait commentedon May 22, 2023
@benlieb You can use the
importfield in your package.json https://nodejs.org/api/packages.html#subpath-importsbenlieb commentedon May 22, 2023
@alexander-akait I'm not sure this solves the problem I'm having. It would be great if it did though!
I have a writeup on SO: https://stackoverflow.com/questions/76309809/how-can-i-configure-webpack-to-use-external-javascript-module
alexander-akait commentedon May 22, 2023
@benlieb Okay, you can:
"imports"toexternalsYou need to get:
Note - webpack will use
import(...)(we have other externals types, follow our docs to look find other possible values if you need) so if you need to support very old envs you need to think about other waysbenlieb commentedon May 22, 2023
Thank you for your help, I really need it. But I still don't understand.
Why would I use
When it is already loaded in to the browser with:
I thought the following would work with this:
But guess not?
One complicating factor is that the url for the import map is actually dynamically generated with hashes (url changes when file contents change) via a rails view helper and really looks like this:
That url isn't hard-codeable into my webpack config file.
Is there any other way that using the
importtype in the webpack config?alexander-akait commentedon May 22, 2023
What is
http://localhost:3000/assets/rails-constants-0ac54660d36cd34c7e89b718a2521795e9a894af62143d83adcf0a786ee8badf.jsformat? Maybe you can a create github repo with an example of code and how you run, because your solution should work tooAlso please run
npm ls webpack(we should have webpack v5)benlieb commentedon May 22, 2023
Looks like maybe webpacker is too old:
benlieb commentedon May 22, 2023
The format of the js file is like:
alexander-akait commentedon May 22, 2023
@benlieb Yeah, this explains why your solution didn't work, make sense to migrate https://github.com/rails/jsbundling-rails/, if it is not possible you can try to proxy some requests on request URLs
benlieb commentedon May 22, 2023
We are deciding between that and shakpacker. Thank you for your time. Very appreciated! I'll check in when we have progress!
webpack-bot commentedon Aug 22, 2023
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
webpack-bot commentedon Sep 6, 2023
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
11 remaining items