Import without SSR in Marko.js

 •  Filed under markojs

I was looking for a nice way to do a "dynamic import" in Marko.js, like the following Next.js code:

import dynamic from 'next/dynamic'
const L = dynamic(import('leaflet'), { ssr: false})

This seems pretty good:

var L
class {
  onMount() {
    L = require('leaflet')
    ...