4

I would like to dynamically load some components and am getting an error when executing the import() function. The import fails because it cannot find the file.

Does anyone know how I can do this in ParcelJS?

Error: Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: http://localhost:1234/js/widgets/widget1/widget.js

  var widgets = [
        '../js/widgets/widget1/widget.js',
        '../js/widgets/widget2/widget.js',
        '../js/widgets/widget3/widget.js'

      ]

       import(widgets[0]).then(function(Widget)
       {
          console.log('Widget index 0 loaded OK')
      })
Flimzy
  • 60,850
  • 13
  • 104
  • 147
Drew
  • 41
  • 1

0 Answers0