1

I'm trying to work in a github repository project that is not in Source format and is using Metadata API format structure.

The repository has stored all component code into an src folder including package.xml. I'm trying to deploy the same into Scratch Org using VS Code, but it throws me an error like this:

Error

src/lwc/jsconfig/jsconfig.js-meta.xml
Cannot find Lightning Component Bundle jsconfig.

This error comes up when I execute following command:

sfdx force:mdapi:deploy -d ./src -w -1 -u My_Scratch_Org

I've .forceignore file in root of the project with following content:

# LWC configuration files
**/jsconfig.json
**/.eslintrc.json

Can we exclude this file specifically when using mdapi:deploy? Does mdapi:deploy command not respect .forceignore?

Also, if I delete this jsconfig.json file from lwc folder, my deployment goes without error, but every time I launch VS Code, it again pops up in my lwc folder.

4
  • 1
    AFAIK it simply uses the package.xml file and nothing else, but I could be wrong.
    – Phil W
    Apr 8 '20 at 16:29
  • The package.xml does not contain this file .jsconfig.json, but is still included as part of deployment. Is there a way to ignore it? or could it be a bug?
    – VarunC
    Apr 8 '20 at 16:54
  • Is the error on salesforce or is it coming from the validation ? Can you see your deployment status to see where this is coming from ? Also could you run the command via CLI and not using Vscode extension to triage where the error is coming from Apr 8 '20 at 19:05
  • Yes, I'm running the command via CLI from Terminal panel and yes the error comes after I execute the force:mdapi:deploy command (as highlighted in my post) & the deployment fails to deploy anything due to this one error all the time. I've to manually delete this file every time before executing the deploy command.
    – VarunC
    Apr 8 '20 at 20:16
0

.forceignore file works only with the source command sfdx force:source:push which is intended to be used with scratch orgs.

To be able to push this project to a scratch org, you shall to convert it first to source format:

sfdx force:mdapi:convert -r path/to/metadata -d path/to/outputdir

If you can use deploy instead of push, you can use a manifest to do this

sfdx force:source:deploy -x path/to/package.xml

More info: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_mdapi.htm

7
  • Do I need to convert to source first before using this command? sfdx force:source:deploy -x path/to/package.xml
    – VarunC
    Apr 8 '20 at 17:16
  • Yes. it works with source format, Apr 8 '20 at 17:18
  • Trouble with converting is, since Repo is in metadata-API format, but converting it to source format means I work in different structure and won't be able to commit to repository that way. Any suggestions there?
    – VarunC
    Apr 8 '20 at 17:19
  • Have you tried this salesforce.stackexchange.com/questions/250154/… Apr 8 '20 at 17:24
  • Yes, but not applicable here. The LWC components within lwc folder are all appropriately placed with respective .xml configuration file. The .jsconfig.json file is Not part of my repository, and it gets created in my local project folder inside lwc - every time I launch VS Code and open my project. And then when I deploy it return the said error.
    – VarunC
    Apr 8 '20 at 17:28
0

Can we exclude this file specifically when using mdapi:deploy?

The right approach for deploying this to scratch org would be converting to dx source format.

It is also a bug if you are getting an error.

Does mdapi:deploy command not respect .forceignore?

No it does not support for mdapi:deploy. Only supported for force:source command and also mdapi:convert command provided you place .forceignore in the src directory for that with package.xml.

1
  • I have the same problem as well. I have the tests folder within the lwcfolder, I want the tests and the files in our git repo, but I dont want to be installed by our pipeline to the sandbox or prod. But I get an error on tests folder. I haven't found a solution yet. Apr 9 at 21:03
0

You can filter your metadata folder before deploying it, using SFDX Essentials sfdx plugin

Command essentials:metadata:filter-from-package-xml

Doc here -> https://github.com/nvuillam/sfdx-essentials#sfdx-essentialsmetadatafilter-from-packagexml

It requires that you have a package.xml file containing only what you need to deploy (if you do not have it, you can generate it from Package builder then manually remove all that you don't need)

Example:

  sfdx essentials:metadata:filter-from-packagexml -i tmp/myMdFolder/ -p myPackage.xml -o tmp/myMdFolderFiltered/
  sfdx force:mdapi:deploy -d tmp/myMdFolderFiltered/ -w 60 -u MyOrgId
0

it looks like forceignore can be referenced by force:mdapi:convert, depending on which folder it exists in:

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm

Where to Put .forceignore

Be sure the paths that you specify in .forceignore are relative to the directory containing the .forceignore file. For the .forceignore file to work its magic, you must put it in the proper location, depending on which command you are running.

Add the .forceignore file to the root of your project for the force:source:* tracking commands.

Add the file to the Metadata retrieve directory (with package.xml) for force:mdapi:convert.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.