Skip to content

Commit 9a47ff0

Browse files
authored
Merge pull request #265 from jetstreamapp/chore/264
Add LWC compatible output
2 parents e0fa54c + d3c87c3 commit 9a47ff0

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 6.2.3
4+
5+
July 28, 2025
6+
7+
- Add LWC compatible output (#264)
8+
- Added deployment instructions on readme
9+
310
## 6.2.2
411

512
July 8, 2025

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,74 @@ WHERE Name LIKE 'a%'
508508
OR Name LIKE 'c%'
509509
```
510510
511+
## Using in LWC
512+
513+
The easiest way to utilize this library in LWC is to deploy the compiled code as a web component in your org.
514+
515+
:warning: The minified version ends up with `$A` characters in the output, which causes the deployment to SFD to fail, so we have created an unminified version of the library just for Salesforce.
516+
517+
### Obtaining the build artifacts
518+
519+
We don't store the built artifacts on github, so you will need to obtain from NPM or run the build command yourself.
520+
521+
#### Download from NPM
522+
523+
Download from [npm](https://www.npmjs.com/package/@jetstreamapp/soql-parser-js)
524+
525+
**Either:**
526+
527+
1. Go to the "Code Tab" on the [npm](https://www.npmjs.com/package/@jetstreamapp/soql-parser-js) listing
528+
1. Navigate to `/dist/lwc.index.mjs`
529+
2. Install this project in an existing node library by running `npm install @jetstreamapp/soql-parser-js`
530+
1. then navigating to the downloaded code in this folder: `node_modules/@jetstreamapp/soql-parser-js/dist/lwc`
531+
532+
#### Build the files yourself
533+
534+
1. Clone/download the repository from GitHub
535+
2. Ensure you have node installed (version 22 or higher)
536+
3. Install dependencies with `npm install`
537+
4. Run `npm build:lwc`
538+
5. The output will be placed in `/dist/lwc.index.mjs`
539+
540+
### Deploying and Using in Salesforce
541+
542+
Copy `index.mjs` into an LWC component.
543+
544+
For example:
545+
546+
```
547+
soqlParserJsLib
548+
- soqlParserJsLib.js <--- copy the code here
549+
- soqlParserJsLib.js-meta.xml
550+
```
551+
552+
After you have deployed the LWC, you can import it just like any other LWC import.
553+
554+
```js
555+
import { LightningElement } from 'lwc';
556+
import { parseQuery } from 'c/soqlParserJsLib';
557+
558+
export default class SoqlParserJs extends LightningElement {
559+
parsedQuery;
560+
561+
get parsedQueryString() {
562+
return this.parsedQuery ? JSON.stringify(this.parsedQuery, null, 2) : '';
563+
}
564+
565+
handleClick() {
566+
this.parsedQuery = parseQuery("SELECT Id, Name FROM Account WHERE Industry = 'Technology'");
567+
}
568+
}
569+
```
570+
571+
```html
572+
<template>
573+
<button class="slds-button slds-button_neutral" onclick="{handleClick}">Click Me</button>
574+
575+
<p>Parsed Query: {parsedQueryString}</p>
576+
</template>
577+
```
578+
511579
## CLI
512580

513581
Install globally or use `npx` to interact with the cli.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
"scripts": {
1616
"clean": "rm -rf ./dist/*",
1717
"prebuild": "npm run clean",
18-
"build": "npm-run-all build:esm build:cjs build:cli build:declarations",
18+
"build": "npm-run-all build:esm build:lwc build:cjs build:cli build:declarations",
1919
"build:esm": "esbuild src/index.ts --bundle --outfile=dist/esm/index.mjs --minify --format=esm --target=es2022",
20+
"build:lwc": "esbuild src/index.ts --bundle --outfile=dist/lwc/index.js --format=esm --target=es2022",
2021
"build:cjs": "esbuild src/index.ts --bundle --outfile=dist/cjs/index.js --minify --format=cjs --target=es2022",
2122
"build:cli": "esbuild cli/index.ts --bundle --outfile=dist/cli/index.js --minify --format=cjs --target=es2022 --platform=node",
2223
"build:declarations": "tsc --project tsconfig.json",

0 commit comments

Comments
 (0)