Skip to content

Commit

Permalink
namespace SSR page route entry points and route chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Mar 16, 2024
1 parent 5612fa0 commit 4592e6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ const getRollupConfigForSsr = async (compilation, input) => {
input: filepath,
output: {
dir: normalizePathnameForWindows(outputDir),
entryFileNames: '[name].route.js',
chunkFileNames: '[name].route.chunk.[hash].js'
entryFileNames: `${path.basename(filepath).split('.')[0]}.route.js`,
chunkFileNames: `${path.basename(filepath).split('.')[0]}.route.chunk.[hash].js`
},
plugins: [
greenwoodResourceLoader(compilation),
Expand Down
12 changes: 6 additions & 6 deletions packages/plugin-adapter-netlify/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ async function netlifyAdapter(compilation) {
const { id } = page;
const outputType = 'page';
const outputRoot = new URL(`./${id}/`, adapterOutputUrl);
const files = (await fs.readdir(outputDir))
.filter(file => file.startsWith(`${id}.route.chunk.`) && file.endsWith('.js'));
const chunks = (await fs.readdir(outputDir))
.filter(file => file.startsWith(`${id}.route.chunk`) && file.endsWith('.js'));

await setupOutputDirectory(id, outputRoot, outputType);

Expand All @@ -109,11 +109,11 @@ async function netlifyAdapter(compilation) {
{ recursive: true }
);

// and the URL chunk for renderer plugin and executeRouteModule
for (const file of files) {
// and any (URL) chunks for the page
for (const chunk of chunks) {
await fs.cp(
new URL(`./${file}`, outputDir),
new URL(`./${file}`, outputRoot),
new URL(`./${chunk}`, outputDir),
new URL(`./${chunk}`, outputRoot),
{ recursive: true }
);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/plugin-adapter-vercel/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async function vercelAdapter(compilation) {
const outputType = 'page';
const { id } = page;
const outputRoot = new URL(`./${basePath}/${id}.func/`, adapterOutputUrl);
const files = (await fs.readdir(outputDir))
.filter(file => file.indexOf('.route.chunk.') > 0 && file.endsWith('.js'));
const chunks = (await fs.readdir(outputDir))
.filter(file => file.startsWith(`${id}.route.chunk`) && file.endsWith('.js'));

await setupFunctionBuildFolder(id, outputType, outputRoot);

Expand All @@ -98,11 +98,11 @@ async function vercelAdapter(compilation) {
{ recursive: true }
);

// and the URL chunk for renderer plugin and executeRouteModule
for (const file of files) {
// and any (URL) chunks for the page
for (const chunk of chunks) {
await fs.cp(
new URL(`./${file}`, outputDir),
new URL(`./${file}`, outputRoot),
new URL(`./${chunk}`, outputDir),
new URL(`./${chunk}`, outputRoot),
{ recursive: true }
);
}
Expand Down

0 comments on commit 4592e6c

Please sign in to comment.