Skip to content

Commit

Permalink
chore: rename the function
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe committed Aug 15, 2024
1 parent c62375e commit 5c1c873
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Nde (Node.js Dependencies Extractor)
# Nde (Node.js Dependencies Emitter)

`nde` is a utility that analyzes your Node.js project's source code to extract the necessary dependencies and files required for deployment and emits these files to a designed node_modules directory that can be used for the deployment. `nde` can simplify the deployment flow and greatly reduce the size of the deployment package.

`nde` is a utility that analyzes your Node.js project's source code to extract only the necessary dependencies and files required for deployment. By emitting these essential files to a new directory, nde simplifies the deployment process and significantly reduces the deployment package size.

## Features

- **Efficient File Extraction and Size Reduction**: Automatically detects and extracts only the files required by your project,generate well-designed, production-ready node_modules directory, significantly reducing deployment package size. It can be used with some popular Node.js frameworks such as Express, Koa and NestJS e.g..
- **Efficient File Extraction and Size Reduction**: Automatically detects and extracts only the files required by your project,generate to designed, production-ready node_modules directory, significantly reducing deployment package size. It can be used with some popular Node.js frameworks such as Express, Koa and NestJS e.g..
- **Monorepo Tool Agnostic**: Compatible with any monorepo tool (e.g., pnpm, Rush, Nx, Turborepo) and offers faster deployment compared to deployment capability of monorepo tools.
- **Rich Configuration and Extensibility**: Supports customizable file inclusion rules, cache configuration, and other extensible options to meet diverse project needs.

## Usage

```
import { handleDependencies } from 'nde'
import { nodeDepEmit } from 'nde'
handleDependencies({
nodeDepEmit({
appDir: appDirectory,
serverRootDir: outputDirectory,
})
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type { NodeFileTraceOptions } from '@vercel/nft';
export { nodeFileTrace } from '@vercel/nft';


export const handleDependencies = async ({
export const nodeDepEmit = async ({
appDir,
sourceDir,
includeEntries,
Expand All @@ -43,8 +43,17 @@ export const handleDependencies = async ({
},
traceOptions,
}: {
/**
* Directory of the project
*/
appDir: string;
/**
* The directory where the code will be analyzed, all js files in that directory will be used as entries, and the node_modules directory will be generated in that directory
*/
sourceDir: string;
/**
* Some files to include, generally some files not analyzed by the code
*/
includeEntries?: string[];
traceFiles?: typeof defaultTraceFiles;
entryFilter?: (filePath: string) => boolean;
Expand Down
10 changes: 10 additions & 0 deletions tests/__snapshots__/nde.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`handle dependencies > basic usage 1`] = `
{
"dependencies": {},
"name": "project1-prod-prod-prod",
"private": true,
"version": "1.0.0",
}
`;
1 change: 0 additions & 1 deletion tests/fixtures/project1/src/package.json

This file was deleted.

4 changes: 2 additions & 2 deletions tests/nde.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { expect, describe, it, afterEach } from 'vitest'
import path from 'node:path'
import fse from 'fs-extra'
import { handleDependencies } from '../src';
import { nodeDepEmit } from '../src';

describe('handle dependencies', () => {
const project1Dir = path.join(__dirname, 'fixtures/project1');
Expand All @@ -15,7 +15,7 @@ describe('handle dependencies', () => {
await fse.remove(outputPkgPath);
})
it('basic usage', async() => {
await handleDependencies({
await nodeDepEmit({
appDir: project1Dir,
sourceDir: srcDir,
})
Expand Down

0 comments on commit 5c1c873

Please sign in to comment.