Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespacing of modules #37

Open
HummerDK opened this issue Mar 18, 2024 · 7 comments
Open

Namespacing of modules #37

HummerDK opened this issue Mar 18, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@HummerDK
Copy link

Hi

I have a setup where I use storybook to showcase components. In order for me to be able to push the components directly to a Salesforce org they need to be present in the "force-app/main/default/lwc" folder. That means when I run my local server, the components is not registered under the namespace "c" as they are when deployed to Salesforce.

Would it be possible to include an option to define a namspace for each module definition like showcased below?

"modules": [ { "dir": "src/demoComponents" }, { "namespace": "c" "dir": "force-app/main/default/lwc" } ]

Best
Rasmus

@nolanlawson nolanlawson added the enhancement New feature or request label Mar 18, 2024
@nolanlawson
Copy link
Contributor

Thanks for opening the issue. This package delegates module resolution to the @lwc/module-resolver package, which actually lives over in the lwc repo.

Could you explain more about the problem you're running into exactly? I don't quite understand the problem space or the solution you're proposing. Thanks!

@HummerDK
Copy link
Author

HummerDK commented Mar 18, 2024

When having a Salesforce project, LWC components must be placed in a folder structure like "force-app/main/default/lwc/". When these components is deployed to a Salesforce org, you must refer to the component like <c-component-name> So all components is given a prefix of "c".

In the same project structure, I am running LWC open source to do local development and showcasing of these components in Storybook. Since my components is placed in the given folder structure "force-app/main/default/lwc/", I am not able to refer to them, as on the Salesforce platform, using <c-component-name>.

I would like to override the prefix of the components names, when the module resolver pick up the components.
Imagine that i could define a namespace like this is the lwc.config.json

{ "namespace": "c", "dir": "src/modules" },

It can be done on single components ( https://github.com/salesforce/lwc/tree/master/packages/%40lwc/module-resolver#alias-module-record), but i would like to do it for all components no matter what folder structure they are placed within

@muenzpraeger
Copy link
Collaborator

Something that I did in the past was just to symlink force-app/main-default/lwc to my-lwc-oss-folder/c, and the use that one for Storybook.

@HummerDK
Copy link
Author

Something that I did in the past was just to symlink force-app/main-default/lwc to my-lwc-oss-folder/c, and the use that one for Storybook.

I agree that it could fix the problem, I just think it would be nicer if the module resolver would support this as configuration instead

@muenzpraeger
Copy link
Collaborator

Agreed. I did a quick search on GitHub and found a mod that actually provides what you're looking for.

https://github.com/lukethacoder/lwc-module-resolver

@HummerDK
Copy link
Author

Agreed. I did a quick search on GitHub and found a mod that actually provides what you're looking for.

https://github.com/lukethacoder/lwc-module-resolver

Thanks for finding the fork from lukethacoder! I still hope they will consider to add the support in the original package :)

@PTST
Copy link

PTST commented Mar 20, 2024

This would greatly help our LWC development process as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants