Skip to content

Error in dynamic import in web component  #1008

@dman777

Description

@dman777

I am trying a dynamic import in chrome. I have

      const { default: Papa } = await import('papaparse');
      const csv = Papa.parse(data);

but I get the error Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'Papa') which traces to the module code

(function(root, factory)
{
	/* globals define */
	if (typeof define === 'function' && define.amd)
	{
		// AMD. Register as an anonymous module.
		define([], factory);
	}
	else if (typeof module === 'object' && typeof exports !== 'undefined')
	{
		// Node. Does not work with strict CommonJS, but
		// only CommonJS-like environments that support module.exports,
		// like Node.
		module.exports = factory();
	}
	else
	{
		// Browser globals (root is window)
		root.Papa = factory();
	}
	// in strict mode we cannot access arguments.callee, so we need a named reference to
	// stringify the factory method for the blob worker
	// eslint-disable-next-line func-name
}(this, function moduleFactory()

This is being used in the lit element library, which is a web component library using shadow dom. Am I doing anything wrong in the above to cause this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions