Skip to content

Commit

Permalink
refactor(esbuild): Optimize for Node targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkobits committed Jul 12, 2023
1 parent 3a71734 commit 152fd8e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
19 changes: 17 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"cosmiconfig": "^8.2.0",
"deepmerge": "^4.3.1",
"esbuild": "^0.18.11",
"esbuild-node-externals": "^1.8.0",
"fs-extra": "^11.1.1",
"node-version": "^3.0.0",
"read-pkg-up": "^10.0.0",
Expand Down
9 changes: 8 additions & 1 deletion src/lib/configuration/strategies/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';

import { TsconfigPathsPlugin } from '@esbuild-plugins/tsconfig-paths';
import * as esbuild from 'esbuild';
import { nodeExternalsPlugin } from 'esbuild-node-externals';
import fs from 'fs-extra';
import currentNodeVersion from 'node-version';
import * as tsConfck from 'tsconfck';
Expand Down Expand Up @@ -72,7 +73,13 @@ export async function esbuildStrategy<M = any>(filePath: string, pkgInfo: Packag
target: `node${currentNodeVersion.major}`,
outfile: tempFileName,
format,
plugins: []
platform: 'node',
bundle: true,
plugins: [
nodeExternalsPlugin({
packagePath: path.resolve(pkgInfo.root ?? '', 'package.json')
})
]
};

// If the user has a TypeScript configuration file, enable TypeScript
Expand Down

0 comments on commit 152fd8e

Please sign in to comment.