Skip to content

Commit

Permalink
fix: add return obj to build func
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwa committed May 4, 2022
1 parent 3018922 commit 1eabdfc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
33 changes: 32 additions & 1 deletion pnpm-lock.yaml

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

25 changes: 19 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import {
BuildOptions,
download,
getNodeVersion,
getSpawnOptions,
BuildV2,
} from '@vercel/build-utils';
import path from 'path';
import { getConfig } from './config';
import { getMountPoint } from './utils';
import { npmBuild } from './npm';

export async function build({
export const build: BuildV2 = async ({
files,
entrypoint,
workPath,
config: rawConfig,
meta = {},
}: BuildOptions) {
}) => {
try {
const mountpoint = getMountPoint(entrypoint);
const entrypointDir = path.join(workPath, mountpoint);
Expand All @@ -26,9 +25,23 @@ export async function build({
const config = getConfig(rawConfig);
const nodeVersion = await getNodeVersion(entrypointDir, undefined, config);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
await npmBuild(config, entrypointDir, spawnOpts, meta);
const outputPath = await npmBuild(config, entrypointDir, spawnOpts, meta);
console.log('build finished,the output path is:', outputPath);

const routes = [
{
src: '/(.*)',
dest: '/',
},
];
return {
buildOutputVersion: 3,
buildOutputPath: outputPath,
routes,
};
} catch (error: any) {
console.error('build err ===> ', error);
console.error('build config ===> ', rawConfig);
throw error;
}
}
};
1 change: 1 addition & 0 deletions src/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export async function npmBuild(
spawnOpts,
meta
);
return distDir;
}

0 comments on commit 1eabdfc

Please sign in to comment.