Repository navigation
chore: revamp build setup + bump/prune deps #1369
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
Changes from all commits
001cc82
8a359d6
e45e3d9
d833a48
8d9d4da
bf4ab8c
ac5fff3
0fc18d9
51760f5
ddeb58d
fd8e280
c011585
d2ca7c5
a9b375f
d96a720
7c8e6a1
c3ee120
f3b5a85
cbf7cdd
17b0931
9523957
ecc417b
f0a3b46
47a3905
7a4c6c9
7108b88
670d697
4393f7b
003426c
9eeb895
9981ee1
eabbf9e
1c9112f
5698f46
3c3ede6
3b3ec80
9f356a5
fbee7ff
04c0f29
f1c227f
6b2e22a
fd0e66d
cc16d22
7839619
8894d13
6668583
4a365d5
5f5fbab
779fa35
bc5ff6e
e72b5d8
ea844c8
ec2e930
79191b2
c41db7a
28e2c0d
03a5ca2
31e7fd1
71f143b
399de77
38a7d70
a07a680
f64beff
34da5ae
c487aee
29f4eef
086ae69
23e869d
d0a3e27
7d9169c
9d24010
8a774ec
f29fbd5
3b10446
252db5e
2bae833
5e4c75c
46e3b60
361ca1c
8a32aad
b5ba8e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,10 @@ module | |
| .env | ||
| .env* | ||
|
|
||
| .wireit | ||
| *.tsbuildinfo | ||
| .eslintcache | ||
|
|
||
|
|
||
| # Dependency directories | ||
| node_modules | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Getting started | ||
|
|
||
| Clone the project and `cd` into it: | ||
| ``` | ||
| git clone [email protected]:jsforce/jsforce.git | ||
| cd jsforce | ||
|
iowillhoit marked this conversation as resolved.
Resolved
|
||
| ``` | ||
|
|
||
| then install dependencies and build: | ||
| ``` | ||
| npm install | ||
| npm run build | ||
| ``` | ||
|
|
||
| `npm run build` will generate all the distributions for node and browsers: | ||
| * Node CJS build (dir: `lib`) | ||
| * Browser ESM build (dir: `browser`) | ||
| * Browser bundles (dir: `dist`) | ||
|
|
||
| # Type-checking | ||
|
|
||
| Babel doesn't perform type-checking when transpiling TS to JS, run `npm run typecheck` to validate the code and tests with the TypeScript compiler. | ||
|
|
||
| # Linting | ||
| Run `npm run lint` to lint the project with ESLint. | ||
|
|
||
| # Tests | ||
| jsforce has mostly E2E tests, written in TS (file name ends with `test.ts`, use `.ts` for test utils) and are located under the `test` folder. | ||
| Keep in mind these tests are executed in a browser and node env, so you have to be careful not to use browser/node-specific code or they will fail, or write node-only tests like this: | ||
| https://github.com/jsforce/jsforce/blob/7c8e6a130a149cc7f310e6628f786f94a98c91b9/test/bulk2.test.ts#L136 | ||
|
|
||
| We run them on latest Chrome and Node (`Current`, `LTS` and `Maintenance` releases) on CI. | ||
|
|
||
| ## Scratch org setup for testing | ||
|
|
||
| > [!NOTE] | ||
| > The Salesforce CLI is required for this, install instructions: | ||
| > | ||
| > https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm | ||
|
|
||
| E2E tests need an org to run tests against, if you have a dev hub and the `sf` CLI you can create a scratch org for testing with the `org-setup` script: | ||
|
|
||
| 1) Set a default dev hub globally: `sf config set target-dev-hub <hub-username> --global`. | ||
| 2) Run `npx zx scripts/org-setup.mjs`, if it finishes successfully you'll see the following output: | ||
| ``` | ||
| Run tests using this scratch org by appending SF_LOGIN_URL=<login-url> SF_USERNAME=<username> SF_PASSWORD=<password> | ||
| ``` | ||
|
|
||
| Set these 3 env vars in you current shell session, tests will use them to establish a connection to the org. | ||
|
|
||
| ## Running tests on the browser | ||
| Due to the Same-origin policy we can't make API requests to Salesforce without a proxy server (REST API supports CORS but jsforce also uses the SOAP API which doesn't), to start the proxy server and run the tests: | ||
|
|
||
| 1) Set the proxy URL env var: `SF_AJAX_PROXY_URL="http://localhost:3123/proxy"`. If you want to use a different port, use the `PORT` env var and update the URL. | ||
| 2) Run `npm run test:browser-ci` | ||
|
|
||
| This will start a proxy server ([`jsforce-ajax-proxy`](https://github.com/jsforce/jsforce-ajax-proxy)), wait until it is ready and then run `karma start` to launch Chrome and run the tests. | ||
| If you host your own proxy server or want to use a 3rd party one set it via `SF_AJAX_PROXY_URL` and run `npm run test:browser` (will only run `karma start`). | ||
|
|
||
| We use [`karma`](https://karma-runner.github.io/latest/index.html) as the test runner and [`jasmine`](https://github.com/jasmine/jasmine/) for testing. | ||
| `karma` is set up to use `webpack` + `babel` ([`babel-loader`](https://github.com/babel/babel-loader)) to transpile and load TS tests in the browser. | ||
|
|
||
| ## Running tests on node | ||
| Run all tests by running the `npm run test:node` script or pass it a file path if you want to run a specific one, e.g. `npm run test:node -- test/cache.test.ts`. | ||
|
|
||
| [`jest`](https://jestjs.io/) is used both as the test runner and testing framework. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,59 +3,44 @@ module.exports = { | |
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| useBuiltIns: 'usage', | ||
| corejs: 3, | ||
| targets: { node: '8' }, | ||
| targets: { node: 18 }, | ||
| }, | ||
| ], | ||
| '@babel/preset-typescript', | ||
| ], | ||
| plugins: [ | ||
| '@babel/plugin-proposal-optional-chaining', | ||
| '@babel/plugin-proposal-nullish-coalescing-operator', | ||
| '@babel/plugin-proposal-class-properties', | ||
|
cristiand391 marked this conversation as resolved.
Resolved
|
||
| [ | ||
| '@babel/plugin-transform-runtime', | ||
| { | ||
| corejs: 3, | ||
| corejs: "3", | ||
| }, | ||
| ], | ||
| ], | ||
| env: { | ||
| module: { | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| modules: false, | ||
| useBuiltIns: 'usage', | ||
| corejs: 3, | ||
| targets: { node: '8' }, | ||
| }, | ||
| ], | ||
| '@babel/preset-typescript', | ||
| ], | ||
| }, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the babel config for the node ESM build done by the (now deleted) deleted since this was added a few years before package exports so it doesn't work well with newer node, logged W-14321367 to re-enable node ESM builds once Shane finishes his dual-publish work. |
||
| browser: { | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| modules: false, | ||
| useBuiltIns: 'usage', | ||
| corejs: 3, | ||
| targets: { browsers: 'last 2 versions, ie 11, not dead' }, | ||
| corejs: "3.33", | ||
| targets: { browsers: 'last 2 versions, not dead, > 0.2%' }, | ||
|
cristiand391 marked this conversation as resolved.
Resolved
|
||
| }, | ||
| ], | ||
| '@babel/preset-typescript', | ||
| ], | ||
| }, | ||
| // This env config is used by jest for TS: | ||
| // https://jestjs.io/docs/getting-started#using-babel | ||
| // | ||
| // for type-check run `tsc` before running tests. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is covered in wireit scripts using dependencies. |
||
| test: { | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| targets: { node: '8' }, | ||
| targets: { node: 18 }, | ||
|
iowillhoit marked this conversation as resolved.
Resolved
|
||
| }, | ||
| ], | ||
| '@babel/preset-typescript', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| /* global jest */ | ||
| jest.setTimeout(120000); | ||
| jest.retryTimes(3, {logErrorsBeforeRetry: true}) |
Uh oh!
There was an error while loading. Please reload this page.