Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit 225f387

Browse files
authoredFeb 8, 2022
fix: use ES modules in README.md (#978)
1 parent 0f7246e commit 225f387

File tree

2 files changed

+25
-38
lines changed

2 files changed

+25
-38
lines changed
 

‎.eslintrc.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ module.exports = {
1919
'no-magic-numbers': 'off',
2020
},
2121
},
22+
{
23+
files: '*.md/*.js',
24+
parserOptions: {
25+
sourceType: 'module',
26+
},
27+
},
2228
],
2329
ignorePatterns: ['tests/fixtures/**/*'],
2430
}

‎README.md

+19-38
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,11 @@ npm install @netlify/zip-it-and-ship-it
3232
- _Return value_: `Promise<object[]>`
3333

3434
```js
35-
const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
35+
import { zipFunctions } from '@netlify/zip-it-and-ship-it'
3636

37-
const zipNetlifyFunctions = async function () {
38-
const archives = await zipFunctions('functions', 'functions-dist', {
39-
archiveFormat: 'zip',
40-
})
41-
42-
return archives
43-
}
37+
const archives = await zipFunctions('functions', 'functions-dist', {
38+
archiveFormat: 'zip',
39+
})
4440
```
4541

4642
Creates Zip `archives` from Node.js, Go, and Rust programs. Those `archives` are ready to be uploaded to AWS Lambda.
@@ -258,13 +254,9 @@ Additionally, the following properties also exist for Node.js functions:
258254
- _Return value_: `object | undefined`
259255

260256
```js
261-
const { zipFunction } = require('@netlify/zip-it-and-ship-it')
262-
263-
const zipNetlifyFunctions = async function () {
264-
const archive = await zipFunctions('functions/function.js', 'functions-dist')
257+
import { zipFunction } from '@netlify/zip-it-and-ship-it'
265258

266-
return archive
267-
}
259+
const archive = await zipFunctions('functions/function.js', 'functions-dist')
268260
```
269261

270262
This is like [`zipFunctions()`](#zipfunctionssrcfolder-destfolder-options) except it bundles a single Function.
@@ -276,13 +268,9 @@ The return value is `undefined` if the function is invalid.
276268
Returns the list of functions to bundle.
277269

278270
```js
279-
const { listFunctions } = require('@netlify/zip-it-and-ship-it')
280-
281-
const listNetlifyFunctions = async function () {
282-
const functions = await listFunctions('functions/function.js')
271+
import { listFunctions } from '@netlify/zip-it-and-ship-it'
283272

284-
return functions
285-
}
273+
const functions = await listFunctions('functions/function.js')
286274
```
287275

288276
### `srcFolders`
@@ -326,12 +314,9 @@ Like [`listFunctions()`](#listfunctionssrcfolder), except it returns not only th
326314
their required files. This is much slower.
327315

328316
```js
329-
const { listFunctionsFiles } = require('@netlify/zip-it-and-ship-it')
317+
import { listFunctionsFiles } from '@netlify/zip-it-and-ship-it'
330318

331-
const listNetlifyFunctionsFiles = async function () {
332-
const functions = await listFunctionsFiles('functions/function.js')
333-
return functions
334-
}
319+
const functions = await listFunctionsFiles('functions/function.js')
335320
```
336321

337322
### `srcFolders`
@@ -400,20 +385,16 @@ included in the bundle.
400385
You can enable esbuild by setting the [`config` option](#config) when calling `zipFunction` or `zipFunctions`:
401386

402387
```js
403-
const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
404-
405-
const zipNetlifyFunctions = async function () {
406-
const archives = await zipFunctions('functions', 'functions-dist', {
407-
config: {
408-
// Applying these settings to all functions.
409-
'*': {
410-
nodeBundler: 'esbuild',
411-
},
412-
},
413-
})
388+
import { zipFunctions } from '@netlify/zip-it-and-ship-it'
414389

415-
return archives
416-
}
390+
const archives = await zipFunctions('functions', 'functions-dist', {
391+
config: {
392+
// Applying these settings to all functions.
393+
'*': {
394+
nodeBundler: 'esbuild',
395+
},
396+
},
397+
})
417398
```
418399

419400
# Feature flags

1 commit comments

Comments
 (1)

github-actions[bot] commented on Feb 8, 2022

@github-actions[bot]
Contributor

⏱ Benchmark results

largeDepsEsbuild: 7.6s

largeDepsNft: 33.2s

largeDepsZisi: 59.4s

This repository has been archived.