cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RevanthReddy
New Member

Using JS files in PCF

I'm trying to include an external JS file in my PCF component. But it's giving me an error.

In the Microsoft documents, they showed that a .js file can be used instead of .ts file

How can I resolve this?

@HemantG 

2 REPLIES 2
ben-thompson
Solution Sage
Solution Sage

See the replies at https://powerusers.microsoft.com/t5/Power-Apps-Component-Framework/Unable-to-load-external-JS-files/...

 

You need to rewrite your Javascript and move it to within the index.ts typescript file or create a separate typescript library and call it from / import it into the index.ts file.

 

Separate Javascript files will not work because a PCF component is a typescript file that is converted to javascript as the PCF component is built and unless you javascript is referenced within the index.ts file it will be ignored.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".
rexkenley
Kudo Collector
Kudo Collector

RevanthReddy

 

Please take a look at my repository on how you can include js files. I basically just treat the index.ts as a "wrapper container" and don't write any additional ts files. You can pretty much take your control and plug it into another "powerapps like framework" if you use my methodology. If you have any questions, please feel free to ask.

 

Starter kit: https://github.com/rexkenley/pcf-react

Pcf Html Editor: https://github.com/rexkenley/d365MultipleLinesHTML

 

If you want to use ts, just rename your .js files to .ts. It's that easy.

https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html

 

 

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Users online (85,268)