-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Cloudflare Workers - Content manifest as external package #4399
Comments
The work-around I've done is to install the
|
@Acen This is a patch I've been using in order to support module workers: diff --git a/dist/compiler/plugins/serverBareModulesPlugin.js b/dist/compiler/plugins/serverBareModulesPlugin.js
index 4d13e28eab536ee13b2fc6cbd28cb9475ce21fb8..a3b4e476214cfaedbb159bc647ba07f82e55f7e3 100644
--- a/dist/compiler/plugins/serverBareModulesPlugin.js
+++ b/dist/compiler/plugins/serverBareModulesPlugin.js
@@ -31,6 +31,7 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
function serverBareModulesPlugin(remixConfig, onWarning) {
let isDenoRuntime = remixConfig.serverBuildTarget === "deno"; // Resolve paths according to tsconfig paths property
+ let isCloudflareRuntime = ["cloudflare-pages", "cloudflare-workers"].includes(remixConfig.serverBuildTarget ?? "");
let matchPath = isDenoRuntime ? undefined : index.createMatchPath(remixConfig.tsconfigPath);
@@ -85,12 +86,8 @@ function serverBareModulesPlugin(remixConfig, onWarning) {
}
}
- switch (remixConfig.serverBuildTarget) {
- // Always bundle everything for cloudflare.
- case "cloudflare-pages":
- case "cloudflare-workers":
- case "deno":
- return undefined;
+ if (isDenoRuntime || isCloudflareRuntime) {
+ return undefined;
}
for (let pattern of remixConfig.serverDependenciesToBundle) {
@@ -127,7 +124,7 @@ function getNpmPackageName(id) {
}
function isBareModuleId(id) {
- return !id.startsWith("node:") && !id.startsWith(".") && !path.isAbsolute(id);
+ return !id.startsWith("node:") && !id.startsWith(".") && !path.isAbsolute(id) && id !== "__STATIC_CONTENT_MANIFEST";
}
function warnOnceIfEsmOnlyPackage(packageName, fullImportPath, onWarning) {
diff --git a/dist/compiler.js b/dist/compiler.js
index b1cf495c3bc4ee202d4d833911773ecd26fb6bc1..c51e86596a3e665ab4c71796a70d1a412f35bfcd 100644
--- a/dist/compiler.js
+++ b/dist/compiler.js
@@ -370,6 +370,7 @@ function createServerBuild(config, options, assetsManifestPromiseRef) {
absWorkingDir: config.rootDirectory,
stdin,
entryPoints,
+ external: isCloudflareRuntime ? ["__STATIC_CONTENT_MANIFEST"] : undefined,
outfile: config.serverBuildPath,
write: false,
conditions: isCloudflareRuntime ? ["worker"] : isDenoRuntime ? ["deno", "worker"] : undefined, I just opened a PR in order to get this fixed upstream. |
Add the following to {
serverDependenciesToBundle: [/^(?!(__STATIC_CONTENT_MANIFEST)$).*$/u],
} This will bundle everything except |
As @huw said, this can be fixed via the This approach does result in an incorrect warning in the terminal that |
@markdalgleish With #7214 merged, should we also remove the regex from |
@MichaelDeBoey That regex is still needed so that esbuild doesn't throw an error trying to bundle it. That PR only silenced an incorrect warning from Remix. |
What version of Remix are you using?
1.7.3
Steps to Reproduce
Attempt to use Cloudflare Worker's static manifest from the KV.
Expected Behavior
The app builds
Actual Behavior
The app throws an error and stops the build.
The text was updated successfully, but these errors were encountered: