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`)