salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.63k stars 394 forks source link

Integration of LWC (SFDC ) to LWC open source #2353

Closed ajay312 closed 3 years ago

ajay312 commented 3 years ago

Hi I could see lightning web component in open source which is web based (Modules) and we can build bundles..

Now we are trying one web component with different environments (SFDC & LWC Open source)

Could we build LWC in SFDC to bundle and deploy in web server ?

what is set up for building Lwc in SFDC?

pmdartus commented 3 years ago

As you can imagine there is a lot of work happening when an LWC component is pushed to the Salesforce platform. Unfortunately, there isn't a simple solution today to migrate platform components to an open-source project.

From a 10k foot view, to reuse an existing LWC component designed to run on the Salesforce platform in an open-source project you will need to substitue all the Salesforce APIs the component depends upon. Those APIs falls into 2 buckets:

Since this application is living outside the core platform, you will be in charge of authentication and the authorization to the Salesforce APIs. Also, there are things present on the platform that you won't be able to replicate in an open-source application, like Locker Service.

ajay312 commented 3 years ago

@pmdartus

We need bundle file from lwc SFDC to expose in web container .I tried this approach

import { resolveModule } from '@lwc/module-resolver'; const root = process.cwd(); resolveModule('c/quoteInfo', root, { modules: [{ dir: 'Quoteinfo/force-app/main/default/lwc', namespace: 'c' }], })

But unable to build my LWC component in SFDC

ajay312 commented 3 years ago

@pmdartus API is working fine in SFDC and LWC OSS accessed with Bearer token .We copied same files in LWC OSS its working fine.

Now we need to automate process so bundle file needed from LWC SFDC to LWC OSS

ajay312 commented 3 years ago

@pmdartus When i bundle LWC in SFDC with module resolver following error occurs:

🔨 Clearing build directory.
⌛ Creating build configuration 📦 Starting build process. 🆘 Module not found: Error: Can't resolve 'fs' in 'C:\Users\ajaypalavai\Downloads\LWC-poc\QuoteInfo\node_modules\@lwc\module-resolver\dist\commonjs' Module not found: Error: Can't resolve 'path' in 'C:\Users\ajaypalavai\Downloads\LWC-poc\QuoteInfo\node_modules\@lwc\module-resolver\dist\commonjs'

pmdartus commented 3 years ago

The @lwc/module-resolver is only be used at compile-time, not at runtime. The bundler is complaining here that it can't resolve path and fs that are Node.JS specific modules.

I will close this issue for now, since there isn't any action item on the LWC framework. We can keep discussing on this thread.

ajay312 commented 3 years ago

Fixed the issue by webpack fallback and added some tricky script .we are creating single LWC component works for salesforce platform and nodejs application..build was successful and got bundle Thank you @pmdartus