Symphonious

Living in a state of accord.

Moolah Diaries: Making inject-loader and vuetify-loader play nice

I’ve been upgrading Moolah after a long period of neglect. One of the tasks is to update it to WebPack 4. Mostly this went smoothly by just creating a new project with vue-cli and bringing its generated build setup over to replace the old one.  Then a bunch of tweaking.

One thing that did bite however, was tests using inject-loader started failing as soon as I added vuetify-loader to the project with:

Error: Module parse failed: 'import' and 'export' may only appear at the top level

There may be a better way to fix this in config, but the simple answer is to adjust the inject-loader import line from something like:

import categoryStoreLoader from 'inject-loader!categoryStore';

to:

import categoryStoreLoader from 'inject-loader!babel-loader!categoryStore';

Adding in the extra babel-loader ensures the imports are processed and replaced by require and everything works.