WebPack provides a handy way to externalize dependencies. This can be nice if you would like the consuming application to furnish this dependency.
In my situation, I am targeting UMD output, and I use the object
external syntax for most external dependencies, and string for a few others:
- https://webpack.js.org/configuration/externals/#object
- https://webpack.js.org/configuration/externals/#string
However, I have one dependency that recommends the following usage:
import vtkGenericRenderWindow from 'vtk.js/Sources/Rendering/Misc/GenericRenderWindow';
import vtkWidgetManager from 'vtk.js/Sources/Widgets/Core/WidgetManager';
import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume';
import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper';
import vtkInteractorStyleMPRSlice from 'vtk.js/Sources/Interaction/Style/InteractorStyleMPRSlice';
import vtkPaintFilter from 'vtk.js/Sources/Filters/General/PaintFilter';
This butts up against the limitation outlined in the "Authoring Libraries" Guide:
https://webpack.js.org/guides/author-libraries/#external-limitations
And requires the regex
option to work.
When using the regex
option to externalize, how does WebPack know where/how to link up the dependency my parent application provides to the code that matches the regex
pattern?
Helpful: