Reputation: 3251
I'm currently trying to Code Split & Lazy Load the javascript in my huge app and got to a point where I have to lazy import a .js
file from a .coffee
file.
In a normal .js
file I do something like this:
import(/* webpackChunkName: "vnd-forms" */ 'js/vendor/forms').then(() => {
do_something
});
I knew writing the same thing in .coffee
will fail, but here it is:
error: regular expressions cannot begin with *
import(/* webpackChunkName: "vnd-forms" */ 'js/vendor/forms').then(() ->
How can I lazy import that file in .coffee
files?
I'm using Webpacker 4.3, Rails 4.2. We are migrating from coffeescript to es6 in baby steps since the codebase is humongous.
Upvotes: 2
Views: 301
Reputation: 3251
It turns out coffeescript has these backticks :)
`import(/* webpackChunkName: "vnd-forms" */ 'js/vendor/forms')`.then(() ->
do_something
)
Now everything loads properly!
Upvotes: 2