@vercel/remix
Advanced tools
Comparing version 1.2.10 to 1.2.11
@@ -5,2 +5,3 @@ "use strict"; | ||
const fs_1 = require("fs"); | ||
const vm_1 = require("vm"); | ||
const path_1 = require("path"); | ||
@@ -147,6 +148,13 @@ const build_utils_1 = require("@vercel/build-utils"); | ||
} | ||
const [staticFiles, renderFunction] = await Promise.all([ | ||
const [staticFiles, renderFunction, ssrRoutes] = await Promise.all([ | ||
(0, build_utils_1.glob)('**', (0, path_1.join)(entrypointFsDirname, 'public')), | ||
createRenderFunction(entrypointFsDirname, repoRootPath, serverBuildPath, needsHandler, nodeVersion), | ||
getSsrRoutes(entrypointFsDirname), | ||
]); | ||
const output = staticFiles; | ||
for (const path of ssrRoutes) { | ||
output[path] = renderFunction; | ||
} | ||
// Add a 404 path for not found pages to be server-side rendered by Remix | ||
output['404'] = renderFunction; | ||
return { | ||
@@ -164,9 +172,6 @@ routes: [ | ||
src: '/(.*)', | ||
dest: '/render', | ||
dest: '/404', | ||
}, | ||
], | ||
output: { | ||
render: renderFunction, | ||
...staticFiles, | ||
}, | ||
output, | ||
}; | ||
@@ -211,2 +216,22 @@ }; | ||
} | ||
async function getSsrRoutes(entrypointDir) { | ||
// Find the name of the manifest file | ||
const buildDir = (0, path_1.join)(entrypointDir, 'public/build'); | ||
const manifestFileName = (await fs_1.promises.readdir(buildDir)).find(n => n.startsWith('manifest-')); | ||
if (!manifestFileName) { | ||
throw new Error(`Failed to find manifest file in "${buildDir}"`); | ||
} | ||
const context = { | ||
window: {}, | ||
}; | ||
(0, vm_1.createContext)(context); | ||
const code = await fs_1.promises.readFile((0, path_1.join)(buildDir, manifestFileName), 'utf8'); | ||
(0, vm_1.runInContext)(code, context); | ||
const routes = context.window.__remixManifest?.routes || {}; | ||
return Object.keys(routes) | ||
.filter(id => id !== 'root') | ||
.map(id => { | ||
return routes[id].path || 'index'; | ||
}); | ||
} | ||
//# sourceMappingURL=build.js.map |
@@ -7,1 +7,8 @@ export interface AppConfig { | ||
} | ||
export interface RemixBuildManifest { | ||
routes: { | ||
[id: string]: { | ||
path: string; | ||
}; | ||
}; | ||
} |
{ | ||
"name": "@vercel/remix", | ||
"version": "1.2.10", | ||
"version": "1.2.11", | ||
"license": "MIT", | ||
@@ -27,6 +27,6 @@ "main": "./dist/index.js", | ||
"@types/node": "14.18.33", | ||
"@vercel/build-utils": "6.1.0", | ||
"@vercel/build-utils": "6.2.0", | ||
"typescript": "4.9.4" | ||
}, | ||
"gitHead": "a4d16c681a7e85f64a2d78432d499c599b398bde" | ||
"gitHead": "a585969dd3b77a4ed36d6a2ca11b34f9050489f1" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35032
329
3