cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chan_HY_98
Regular Visitor

Share node_modules between PCF projects

Hi all. I am new to code component development for PowerApps and found that for every project created using pac pcf init, a folder of Node modules are installed. The node_modules folder is 160+ MB in size too. Therefore, I want to share the modules between 2 projects to reduce the size of each project folder and streamline the development process.

 

I tried the following directory structure while removing the node_modules and duplicated files from each project folder:

Root
/Project_1
/Project_2
/node_modules
/package.json
/package-lock.json
/pcfconfig.json
/tsconfig.json

When executing npm start watch from Project_1 directory, the components from both Project_1 and Project_2 are compiled together and only the first compiled component is launched in the local server.

 

Is it possible for multiple PCF projects to share a node_modules folder? If so, is there a way to only run a selected component?

 

Hope to hear from the community and the pros. Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
marchello
Frequent Visitor

Hi,

 

What I did was, I created a monorepo with pnpm. This way the node_modules are not duplicated and I can also share components between my PCF projects. You can launch and build the projects separately as you wish.

 

I also added Turborepo on top of everthing else, so when I build my PCF Solution only the modified projects are built, the rest are cached, so the build times are much shorter.

 

View solution in original post

2 REPLIES 2
marchello
Frequent Visitor

Hi,

 

What I did was, I created a monorepo with pnpm. This way the node_modules are not duplicated and I can also share components between my PCF projects. You can launch and build the projects separately as you wish.

 

I also added Turborepo on top of everthing else, so when I build my PCF Solution only the modified projects are built, the rest are cached, so the build times are much shorter.

 

Chan_HY_98
Regular Visitor

Hi @marchello. Thank you very much for your suggestion. I read up about monorepo and pnpm, and I have implemented them in my workspace with Nx as my monorepo support.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Users online (2,159)