@opennextjs/cloudflare 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,7 +42,7 @@ const optionalDependencies = [
42
42
  */
43
43
  export async function bundleServer(buildOpts) {
44
44
  patches.copyPackageCliFiles(packageDistDir, buildOpts);
45
- const { appPath, outputDir, monorepoRoot } = buildOpts;
45
+ const { appPath, outputDir, monorepoRoot, debug } = buildOpts;
46
46
  const baseManifestPath = path.join(outputDir, "server-functions/default", getPackagePath(buildOpts), ".next");
47
47
  const serverFiles = path.join(baseManifestPath, "required-server-files.json");
48
48
  const nextConfig = JSON.parse(fs.readFileSync(serverFiles, "utf-8")).config;
@@ -60,7 +60,11 @@ export async function bundleServer(buildOpts) {
60
60
  outfile: openNextServerBundle,
61
61
  format: "esm",
62
62
  target: "esnext",
63
- minify: false,
63
+ // Minify code as much as possible but stay safe by not renaming identifiers
64
+ minifyWhitespace: !debug,
65
+ minifyIdentifiers: false,
66
+ minifySyntax: !debug,
67
+ legalComments: "none",
64
68
  metafile: true,
65
69
  // Next traces files using the default conditions from `nft` (`node`, `require`, `import` and `default`)
66
70
  //
@@ -142,7 +146,9 @@ export async function bundleServer(buildOpts) {
142
146
  */
143
147
  export async function updateWorkerBundledCode(workerOutputFile) {
144
148
  const code = await readFile(workerOutputFile, "utf8");
145
- const patchedCode = await patchCodeWithValidations(code, [["require", patches.patchRequire]]);
149
+ const patchedCode = await patchCodeWithValidations(code, [
150
+ ["require", patches.patchRequire, { isOptional: true }],
151
+ ]);
146
152
  await writeFile(workerOutputFile, patchedCode);
147
153
  }
148
154
  /**
@@ -10,7 +10,6 @@ export function patchResolveCache(updater, buildOpts) {
10
10
  const packagePath = getPackagePath(buildOpts);
11
11
  const outputPath = path.join(outputDir, "server-functions/default");
12
12
  const indexPath = path.relative(buildOpts.appBuildOutputPath, path.join(outputPath, packagePath, `index.mjs`));
13
- console.error({ index: indexPath });
14
13
  return updater.updateContent("patch-resolve-cache", [
15
14
  {
16
15
  field: {
@@ -18,6 +18,5 @@ export async function patchCodeWithValidations(code, patches) {
18
18
  throw new Error(`Failed to patch ${target}`);
19
19
  }
20
20
  }
21
- console.log(`All ${patches.length} patches applied\n`);
22
21
  return patchedCode;
23
22
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opennextjs/cloudflare",
3
3
  "description": "Cloudflare builder for next apps",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opennextjs-cloudflare": "dist/cli/index.js"