Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
Webpack: How do I use magic comments to import a file into a file that will be published as a library then imported into a different application

I have a file published as umd library with a dynamic import that builds a select list of widgets based on configuration options. This is all working great in that the main js and widget js files are being published when I run the library directly. When I import the library into another project. It attempts to the path the widget import based upon the root of the url of the project instead of based off the url of the umd. Is there a way I can force the dynamic import to base its pathing off the absolute path of the library? I couldn't find anything in magic comments that would help.

My secondary option would be to just publish each of the widgets as their own distinct libraries and then webpackIgnore the import which I think should work

webpack config output:

output: {
      publicPath: "",
      path: require("path").resolve("publish/__dist"),
      filename: "[name].js",
      library: {
        name: "widget-container",
        type: "umd",
        umdNamedDefine: true,
      },
    },

import in library:

import(/* webpackChunkName: "widgets/widget" */ `../widgets/${b.slug}/js/widget.js`)
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda