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

Commit

Permalink
feat: add repositoryRoot property (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 12, 2021
1 parent 1d31869 commit 13a5ee7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ Format of the archive created for each function. Defaults to ZIP archives.

If set to `none`, the output of each function will be a directory containing all the bundled files.

#### `basePath`

- _Type_: `string`
- _Default value_: `undefined`

The directory which all relative paths will be resolved from. These include paths in the `includedFiles` config
property, as well as imports using dynamic expressions such as `require(\`./files/${name}\`)`.

#### `config`

- _Type_: `object`
Expand Down Expand Up @@ -172,6 +180,14 @@ JSON-formatted string with the following properties:

Maximum number of functions to bundle at the same time.

#### `repositoryRoot`

- _Type_: `string`
- _Default value_: The value of `basePath`

The path of the project's repository root. This defines the boundary where Node modules can be found. It usually is the
same value as the `basePath` property, but may be a parent directory in the case of a monorepo setup.

### Return value

This returns a `Promise` resolving to an array of objects describing each archive. Every object has the following
Expand Down
16 changes: 10 additions & 6 deletions src/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const zipFunctions = async function (
featureFlags: inputFeatureFlags,
manifest,
parallelLimit = DEFAULT_PARALLEL_LIMIT,
repositoryRoot = basePath,
} = {},
) {
validateArchiveFormat(archiveFormat)
Expand Down Expand Up @@ -90,6 +91,7 @@ const zipFunctions = async function (
mainFile: func.mainFile,
name: func.name,
pluginsModulesPath,
repositoryRoot,
runtime: func.runtime,
srcDir: func.srcDir,
srcPath: func.srcPath,
Expand Down Expand Up @@ -121,6 +123,7 @@ const zipFunction = async function (
config: inputConfig = {},
featureFlags: inputFeatureFlags,
pluginsModulesPath: defaultModulesPath,
repositoryRoot = basePath,
} = {},
) {
validateArchiveFormat(archiveFormat)
Expand All @@ -143,16 +146,17 @@ const zipFunction = async function (
archiveFormat,
basePath,
config,
srcPath,
destFolder,
mainFile,
filename,
extension,
featureFlags,
filename,
mainFile,
pluginsModulesPath,
repositoryRoot,
runtime,
srcDir,
srcPath,
stat,
runtime,
pluginsModulesPath,
featureFlags,
})

return formatZipResult({ ...zipResult, mainFile, name, runtime })
Expand Down

1 comment on commit 13a5ee7

@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: 11.1s

largeDepsZisi: 1m 0.1s

Please sign in to comment.