diff --git a/packages/cli/src/config/rollup.config.js b/packages/cli/src/config/rollup.config.js index 8d5594039..7771d1141 100644 --- a/packages/cli/src/config/rollup.config.js +++ b/packages/cli/src/config/rollup.config.js @@ -181,7 +181,7 @@ function greenwoodSyncApiRoutesOutputPath(compilation) { if (bundle[key].exports?.find(exp => exp === 'handler')) { const ext = bundle[key].facadeModuleId.split('.').pop(); const relativeFacade = new URL(`file://${bundle[key].facadeModuleId}`).pathname.replace(apisDir.pathname, `${basePath}/`).replace(`.${ext}`, ''); - const route = `/api${relativeFacade}`; // ew URL(`file://${bundle[key].facadeModuleId}`).pathname.replace(apisDir.pathname, `${basePath}/`).replace(`.${ext}`, ''); + const route = `/api${relativeFacade}`; if (compilation.manifest.apis.has(route)) { const api = compilation.manifest.apis.get(route); @@ -457,14 +457,14 @@ const getRollupConfigForScriptResources = async (compilation) => { }; const getRollupConfigForApis = async (compilation) => { - const { outputDir, pagesDir } = compilation.context; + const { outputDir, pagesDir, apisDir } = compilation.context; return [...compilation.manifest.apis.values()] .map(api => normalizePathnameForWindows(new URL(`.${api.path}`, pagesDir))) .map((filepath) => { // account for windows pathname shenanigans by "casting" filepath to a URL first const ext = filepath.split('.').pop(); - const entryName = new URL(`file://${filepath}`).pathname.replace(pagesDir.pathname, '').replace('/', '-').replace(`.${ext}`, ''); + const entryName = new URL(`file://${filepath}`).pathname.replace(apisDir.pathname, '').replace(/\//g, '-').replace(`.${ext}`, ''); return { input: filepath, diff --git a/packages/cli/test/cases/build.plugins.adapter/src/api/nested/endpoint.js b/packages/cli/test/cases/build.plugins.adapter/src/pages/api/nested/endpoint.js similarity index 100% rename from packages/cli/test/cases/build.plugins.adapter/src/api/nested/endpoint.js rename to packages/cli/test/cases/build.plugins.adapter/src/pages/api/nested/endpoint.js diff --git a/packages/plugin-adapter-netlify/test/cases/build.default/src/api/nested/endpoint.js b/packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/nested/endpoint.js similarity index 100% rename from packages/plugin-adapter-netlify/test/cases/build.default/src/api/nested/endpoint.js rename to packages/plugin-adapter-netlify/test/cases/build.default/src/pages/api/nested/endpoint.js diff --git a/packages/plugin-adapter-vercel/src/index.js b/packages/plugin-adapter-vercel/src/index.js index 26fab2254..61030a83d 100644 --- a/packages/plugin-adapter-vercel/src/index.js +++ b/packages/plugin-adapter-vercel/src/index.js @@ -115,7 +115,7 @@ async function vercelAdapter(compilation) { const api = apiRoutes.get(key); const { outputPath } = api; const id = key.replace(`${basePath}/api/`, '').replace(/\//g, '-'); - const outputRoot = new URL(`./${basePath}/api/${id}.func/`, adapterOutputUrl); + const outputRoot = new URL(`.${basePath}/api/${id}.func/`, adapterOutputUrl); const { assets = [] } = value; await setupFunctionBuildFolder(id, outputType, outputRoot); diff --git a/packages/plugin-adapter-vercel/test/cases/build.default/src/api/nested/endpoint.js b/packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/nested/endpoint.js similarity index 100% rename from packages/plugin-adapter-vercel/test/cases/build.default/src/api/nested/endpoint.js rename to packages/plugin-adapter-vercel/test/cases/build.default/src/pages/api/nested/endpoint.js