Skip to content

Commit

Permalink
fix: use ES modules in README.md (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 8, 2022
1 parent 0f7246e commit 225f387
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Expand Up @@ -19,6 +19,12 @@ module.exports = {
'no-magic-numbers': 'off',
},
},
{
files: '*.md/*.js',
parserOptions: {
sourceType: 'module',
},
},
],
ignorePatterns: ['tests/fixtures/**/*'],
}
57 changes: 19 additions & 38 deletions README.md
Expand Up @@ -32,15 +32,11 @@ npm install @netlify/zip-it-and-ship-it
- _Return value_: `Promise<object[]>`

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

const zipNetlifyFunctions = async function () {
const archives = await zipFunctions('functions', 'functions-dist', {
archiveFormat: 'zip',
})

return archives
}
const archives = await zipFunctions('functions', 'functions-dist', {
archiveFormat: 'zip',
})
```

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

```js
const { zipFunction } = require('@netlify/zip-it-and-ship-it')

const zipNetlifyFunctions = async function () {
const archive = await zipFunctions('functions/function.js', 'functions-dist')
import { zipFunction } from '@netlify/zip-it-and-ship-it'

return archive
}
const archive = await zipFunctions('functions/function.js', 'functions-dist')
```

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

```js
const { listFunctions } = require('@netlify/zip-it-and-ship-it')

const listNetlifyFunctions = async function () {
const functions = await listFunctions('functions/function.js')
import { listFunctions } from '@netlify/zip-it-and-ship-it'

return functions
}
const functions = await listFunctions('functions/function.js')
```

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

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

const listNetlifyFunctionsFiles = async function () {
const functions = await listFunctionsFiles('functions/function.js')
return functions
}
const functions = await listFunctionsFiles('functions/function.js')
```

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

```js
const { zipFunctions } = require('@netlify/zip-it-and-ship-it')

const zipNetlifyFunctions = async function () {
const archives = await zipFunctions('functions', 'functions-dist', {
config: {
// Applying these settings to all functions.
'*': {
nodeBundler: 'esbuild',
},
},
})
import { zipFunctions } from '@netlify/zip-it-and-ship-it'

return archives
}
const archives = await zipFunctions('functions', 'functions-dist', {
config: {
// Applying these settings to all functions.
'*': {
nodeBundler: 'esbuild',
},
},
})
```

# Feature flags
Expand Down

1 comment on commit 225f387

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 7.6s

largeDepsNft: 33.2s

largeDepsZisi: 59.4s

Please sign in to comment.