|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 | 15 | import { promises as fsPromises } from 'fs';
|
16 |
| -import { dirname, join } from 'path'; |
| 16 | +import { join } from 'path'; |
17 | 17 |
|
18 | 18 | import { DeployConfig, PathFactory, exec, spawn } from '../../utils';
|
19 | 19 |
|
@@ -72,7 +72,7 @@ export const build = async (config: DeployConfig | Required<DeployConfig>, getPr
|
72 | 72 | let bootstrapScript = '';
|
73 | 73 | if (serverRenderMethod) {
|
74 | 74 | let stack = serverRenderMethod.slice();
|
75 |
| - const entry = `./${packageJson.main || 'index.js'}`; |
| 75 | + const entry = packageJson.name; |
76 | 76 | if (stack.shift() === 'require') {
|
77 | 77 | bootstrapScript += `const bootstrap = Promise.resolve(require('${entry}'))`;
|
78 | 78 | } else {
|
@@ -105,19 +105,11 @@ export const build = async (config: DeployConfig | Required<DeployConfig>, getPr
|
105 | 105 | }
|
106 | 106 |
|
107 | 107 | if (serverRenderMethod) {
|
108 |
| - const npmPackResults = JSON.parse(await exec(`npm pack ${getProjectPath()} --dry-run --json`) as string); |
109 |
| - |
110 |
| - await Promise.all( |
111 |
| - // TODO types |
112 |
| - npmPackResults. |
113 |
| - find(({ name }: any) => name === packageJson.name ). |
114 |
| - files. |
115 |
| - map(({ path }: any) => |
116 |
| - mkdir(dirname(deployPath('functions', path)), { recursive: true }).then(() => |
117 |
| - copyFile(getProjectPath(path), deployPath('functions', path)) |
118 |
| - ) |
119 |
| - ) |
120 |
| - ); |
| 108 | + const npmPackResults = JSON.parse(await exec(`npm pack ${getProjectPath()} --json`, { cwd: deployPath('functions')}) as string); |
| 109 | + const matchingPackResult = npmPackResults.find((it: any) => it.name === packageJson.name); |
| 110 | + const { filename } = matchingPackResult; |
| 111 | + packageJson.dependencies ||= {}; |
| 112 | + packageJson.dependencies[packageJson.name] = `file:${filename}`; |
121 | 113 | }
|
122 | 114 |
|
123 | 115 | return { usingCloudFunctions: !!serverRenderMethod, framework: 'express', rewrites: [], redirects: [], headers: [], packageJson, bootstrapScript };
|
|
0 commit comments