mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Polyfill node:crypto, allow building with files outside of project directory
This commit is contained in:
2 files changed
+6
-6
No files matched your search
@@ -226,6 +226,11 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
|
||||
path: `${esmUrl}/${moduleName}?target=${target ?? "esnext"}`,
|
||||
namespace: "esm",
|
||||
};
|
||||
case "crypto":
|
||||
return {
|
||||
path: `${esmUrl}/crypto-browserify?target=${target ?? "esnext"}`,
|
||||
namespace: "esm",
|
||||
};
|
||||
default:
|
||||
return {
|
||||
errors: [{ text: `Module not found: ${args.path}` }],
|
||||
|
||||
@@ -99,11 +99,6 @@ export function fsPlugin(options: FsPluginOptions): Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
// Security: prevent accessing files outside the project directory
|
||||
if (resolved.startsWith("/") && !resolved.startsWith(cwd)) {
|
||||
throw new Error(`Access to files outside the project directory is not allowed: ${resolved}`);
|
||||
}
|
||||
|
||||
// Vite query parameters https://vite.dev/guide/assets
|
||||
const [cleaned, query] = resolved.split("?");
|
||||
|
||||
@@ -174,7 +169,7 @@ async function tryFileVariants(
|
||||
const packageJson = JSON.parse(packageJsonText);
|
||||
|
||||
// Check for various entry point fields
|
||||
const entryPoint = packageJson.exports?.['.']
|
||||
const entryPoint = packageJson.exports?.['.']
|
||||
|| packageJson.module
|
||||
|| packageJson.main
|
||||
|| 'index.js';
|
||||
|
||||
Reference in new issue
Block a user