Skip to content

Dynamic imports support? #5

@kurtextrem

Description

@kurtextrem

Suppose the following code:

a.mjs

const A = "bc"
console.log(A)

import("./b.mjs").then(() => {
    console.log("b.mjs loaded")
})

b.mjs

const B = "de"
console.log(B)

The output is then:
a.js

const A = "bc";console.log(A);$1._1import * as $1 from "./a.kt-01tEKKx.js";

a.kt-xxxx.js

export var _1=import("./b.mjs").then(() => {
    console.log("b.mjs loaded")
});

So it seems like the generated output is not valid JS, so I assume Kuto does not support dynamic imports?

If you're wondering about my use-case, I have a main bundle where I import routes via import(...). I hoped that either Kuto would do the chunking / splitting automatically, or I could could feed e.g. esbuild splitting=true output, run Kuto over it and Kuto would do this:

main bundle 
|-------------> static (kuto)
|-------------> route1 (dynamic import split by esbuild/kuto)
                              |-------> static_route1 (kuto)
                              |-------> static_route1_route2 (shared static, kuto)
|-------------> route2 (dynamic import split by esbuild/kuto)
                              |-------> static_route1_route2 (shared static, kuto)

extract into dynamic chunks that have their static parts also separated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions