Skip to main content
Martin — LTTR
Participant
December 6, 2022
Answered

Can we use JavaScript modules in CEP UI?

  • December 6, 2022
  • 2 replies
  • 1025 views

Hi,

 

we're building a CEP-based UI for Adobe Illustrator 2023. Our panel's HTML code contains a script tag as follows:

<script type="module" crossorigin src="./index.js"></script>

The page fails to load in the Illustrator panel because the engine complains that the index.js file is returned with MIME type "" while the specification requires "text/javascript" for JavaScript files loaded as type="module". If the files are served locally (not sure yet), CORS errors might also appear according to the previously linked MDN page. 


Is there a way how to use JavaScript modules in CEP UI? Or do we need to find a way how to compile the source as a non-module JavaScript? Thanks.

This topic has been closed for replies.
Correct answer Manan Joshi

Seems this is something that html specification does not permit(i.e.loading modules from a file url which). See the following discussion that looks to be similiar to your issue. It has a suggestion as well which you can try

https://community.adobe.com/t5/illustrator-discussions/converting-es6-modules-for-use-in-cep-html-panel/td-p/12010317

-Manan

2 replies

Participant
February 27, 2023

Were you able to find a work around for this? I am not able to use Firebase kind of back end libraries on the plugin I am developing. I need to import modules but CEP gets them as plain files so same error. Do I need to just serve everything on a server?

Martin — LTTR
Participant
February 28, 2023

No workaround. They're serving files from disc directly, so modules would not work as the specification prevents so.

Manan JoshiCommunity ExpertCorrect answer
Community Expert
December 8, 2022

Seems this is something that html specification does not permit(i.e.loading modules from a file url which). See the following discussion that looks to be similiar to your issue. It has a suggestion as well which you can try

https://community.adobe.com/t5/illustrator-discussions/converting-es6-modules-for-use-in-cep-html-panel/td-p/12010317

-Manan

-Manan