Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambdaName not called index and route destination=lamdaName, fix nuxt/vercel-builder#669 #670

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nuxtjs/vercel-builder",
"version": "0.24.0",
"repository": "nuxt/vercel-builder",
"name": "@fabioni/vercel-builder-fix",
"version": "1.0.10",
"repository": "fabioni/vercel-builder",
"license": "MIT",
"exports": {
".": "./lib/index.js",
Expand All @@ -20,54 +20,54 @@
"refresh:example-basic": "cd examples/basic && rm yarn.lock && yarn && rm -rf node_modules",
"refresh:example-side-by-side-admin": "cd examples/side-by-side/admin && rm yarn.lock && yarn && rm -rf node_modules",
"refresh:example-side-by-side-app": "cd examples/side-by-side/app && rm yarn.lock && yarn && rm -rf node_modules",
"refresh:fixture": "cd test/fixture/www && rm package-lock.json && npm install && rm -rf node_modules",
"refresh:fixture": "cd test/fixture/www && rm yarn.lock && yarn && rm -rf node_modules",
"refresh:fixture-generated": "cd test/fixture-generated/www && rm yarn.lock && yarn && rm -rf node_modules",
"refresh:fixture-ts": "cd test/fixture-ts/www && rm yarn.lock && yarn && rm -rf node_modules",
"release": "release-it",
"test": "jest test"
},
"resolutions": {
"minimist": ">=1.2.7"
"minimist": ">=1.2.5"
},
"dependencies": {
"@nuxtjs/web-vitals": "^0.2.2",
"@vercel/node-bridge": "3.1.2",
"@nuxtjs/web-vitals": "^0.1.8",
"@vercel/build-utils": "2.11.0",
"@vercel/node-bridge": "2.1.0",
"consola": "2.15.3",
"execa": "^5.1.1",
"fs-extra": "10.1.0",
"jiti": "^1.16.0",
"rc9": "^1.2.4",
"replace-in-file": "^6.3.5",
"fs-extra": "9.1.0",
"jiti": "^1.12.9",
"rc9": "^1.2.0",
"replace-in-file": "^6.3.2",
"resolve-from": "^5.0.0",
"semver": "7.3.8",
"ufo": "^1.0.1"
"semver": "7.3.5",
"ufo": "^0.7.9"
},
"devDependencies": {
"@nuxt/types": "^2.15.8",
"@nuxtjs/eslint-config": "^12.0.0",
"@release-it/conventional-changelog": "^5.1.1",
"@types/aws-lambda": "^8.10.109",
"@nuxtjs/eslint-config": "^8.0.0",
"@release-it/conventional-changelog": "^4.1.0",
"@types/aws-lambda": "^8.10.91",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.0.0",
"@types/node": "^18.11.10",
"@types/semver": "^7.3.13",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"@vercel/build-utils": "5.7.0",
"@vercel/routing-utils": "2.1.3",
"@types/glob": "^7.2.0",
"@types/node": "^14.17.18",
"@types/semver": "^7.3.9",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"@vercel/routing-utils": "1.11.3",
"codecov": "^3.8.3",
"eslint": "^8.29.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.6",
"eslint": "^8.7.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^25.7.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "^9.8.0",
"jest": "29.3.1",
"eslint-plugin-vue": "^8.3.0",
"jest": "27.4.7",
"npm-run-all": "^4.1.5",
"nuxt": "2.15.8",
"release-it": "^15.5.1",
"release-it": "^14.12.3",
"siroc": "^0.16.0"
}
}
12 changes: 7 additions & 5 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface NuxtBuilderConfig {
export async function build (opts: BuildOptions & { config: NuxtBuilderConfig }): Promise<BuilderOutput> {
const { files, entrypoint, workPath, config = {}, meta = {} } = opts
// ---------------- Debugging context --------------
consola.log('Running with @nuxt/vercel-builder version', require('../package.json').version)
consola.log('Running with @fabioni/vercel-builder-fix version', require('../package.json').version)

// ----------------- Prepare build -----------------
startStep('Prepare build')
Expand Down Expand Up @@ -63,7 +63,9 @@ export async function build (opts: BuildOptions & { config: NuxtBuilderConfig })
}

// Node version
const nodeVersion = await getNodeVersion(entrypointPath, undefined, {}, meta)
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! nodeVersion now hardcoded to 18 in @fabioni/vercel-builder-fix')
// TODO node verion https://github.com/vercel/vercel/blob/main/packages/build-utils/src/fs/node-version.ts
const nodeVersion = { major: 18, range: '18.x', runtime: 'nodejs18.x' } //await getNodeVersion(entrypointPath, undefined, {}, meta)
const spawnOpts = getSpawnOptions(meta, nodeVersion)

// Prepare TypeScript environment if required.
Expand Down Expand Up @@ -161,7 +163,7 @@ export async function build (opts: BuildOptions & { config: NuxtBuilderConfig })
}
const buildDir = nuxtConfigFile.buildDir ? path.relative(entrypointPath, nuxtConfigFile.buildDir) : '.nuxt'
const srcDir = nuxtConfigFile.srcDir ? path.relative(entrypointPath, nuxtConfigFile.srcDir) : '.'
const lambdaName = nuxtConfigFile.lambdaName ? nuxtConfigFile.lambdaName : 'index'
const lambdaName = nuxtConfigFile.lambdaName ? nuxtConfigFile.lambdaName : 'lambdaname' //we don't call it index, otherwise a pre-generated index.vue file is not reachable anymore
const usesServerMiddleware = config.internalServer !== undefined ? config.internalServer : !!nuxtConfigFile.serverMiddleware

await exec('nuxt', [
Expand Down Expand Up @@ -280,7 +282,7 @@ export async function build (opts: BuildOptions & { config: NuxtBuilderConfig })
// lambdaName will be titled index, unless specified in nuxt.config.js
lambdas[lambdaName] = await createLambda({
handler: 'vercel__launcher.launcher',
runtime: nodeVersion.runtime,
runtime: nodeVersion.runtime, // hardcoded zu "nodejs18.x"
files: launcherFiles,
environment: {
NODE_ENV: 'production'
Expand All @@ -305,7 +307,7 @@ export async function build (opts: BuildOptions & { config: NuxtBuilderConfig })
{ src: `/${publicPath}.+`, headers: { 'Cache-Control': 'max-age=31557600' } },
...Object.keys(staticFiles).map(file => ({ src: `/${file}`, headers: { 'Cache-Control': 'max-age=31557600' } })),
{ handle: 'filesystem' },
{ src: '/(.*)', dest: '/index' }
{ src: '/(.*)', dest: '/' + lambdaName }
]
}
}
Loading