How to make Quokka.js recognize local modules

4.4k Views Asked by At

I'm looking for a clear way to either require

const MyModel = require("../../models/MyModel");

or import

import MyModel from "../../models/MyModel";

local modules in a way that Quokka understands in ES6. Both approaches compile and do not throw errors on runtime. However, Quokka either says the require code has an "Unexpected Identifier" or ignores the import code line entirely.

1

There are 1 best solutions below

0
On

Quokka supports module imports only for pro version. If you are ready to go, there might be additional configuration needed. You can configure inside the package.json file, the settings below:

"quokka" : {
    "babel" : {
        presets: ['env']
    }
 }

Also you are able to set it as global on ~/.quokka/config.json