7

I have module with dynamic import

index.mjs

...
const components = [
 'fer-dialog',
 'welcome-description',
 'welcome-diagram',
 'welcome-feedback',
 'welcome-logo',
]

 for (let i = 0; i < components.length; ++i) {         
   import(`${pathname}/component/${components[i]}/index.mjs`)
 }
....

My esbuild config

...
const buildParams = {
  entryPoints: ["./index.mjs"],
  outfile: '../build/index.mjs',
  format: "esm",
  target: "es2022",
  loader: {  '.css': 'copy', '.data': 'base64' , ".js": "jsx",".ttf":"base64", ".json": "copy", ".png": "file", ".jpeg": "file", ".jpg": "file", ".svg": "dataurl", ".woff": "file" },
  color: true,
  minify: true,
  bundle: true,
  sourcemap: true,
  mainFields : [ 'module' , 'main' ],
  define,
  logLevel: "error",
  external: ["*.gif"]
...

The bundle does not include dynamic imports.

Is there a plugin or possibility to add dynamic imports to the bundle ?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.