Skip to content

Commit f9100c5

Browse files
fix: Next build fix and improvements (#101)
* fix: enable eval calls in local env * fix: Add util alias in resolve * fix: accepts only nextjs v12.3.x in node build * fix: nextjs project runtimes validation
1 parent 2e245fd commit f9100c5

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

lib/env/runtime.env.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ function runtime(code) {
5656
return context;
5757
};
5858

59-
const edgeRuntime = new EdgeRuntime({ extend, initialCode: code });
59+
const edgeRuntime = new EdgeRuntime({
60+
extend,
61+
initialCode: code,
62+
codeGeneration: {
63+
strings: true,
64+
},
65+
});
6066
return edgeRuntime;
6167
}
6268

lib/presets/custom/next/compute/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const config = {
5959
mainFields: ['browser', 'main', 'module'],
6060
alias: {
6161
'next/dist/compiled/raw-body': require.resolve('raw-body'),
62+
util: require.resolve('util/'),
6263
},
6364
fallback: {
6465
async_hooks: false,

lib/presets/custom/next/compute/node/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { gte, coerce, valid, lt } from 'semver';
1+
import {
2+
gte, coerce, valid, lt,
3+
} from 'semver';
24
import path, { join } from 'path';
35
import fs from 'fs';
46

@@ -15,7 +17,7 @@ async function run(nextVersion, buildContext) {
1517

1618
const version = valid(coerce(nextVersion));
1719
const MESSAGE_ERROR_VERSION = 'Invalid Next.js version! Available versions for node runtime: 12.3.1';
18-
if (gte(version, '12.0.0') && lt(version, '13.0.0')) {
20+
if (gte(version, '12.3.0') && lt(version, '12.4.0')) {
1921
feedback.prebuild.info('Starting file processing!');
2022

2123
const OUT_DIR_CUSTOM_SERVER = '.edge/next-build';

lib/presets/custom/next/compute/prebuild.js

+3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ async function prebuild(buildContext) {
7878
const projectRuntime = getProjectRuntimes();
7979
if (projectRuntime === 'node') {
8080
await runNodeBuild(nextVersion, buildContext);
81+
} else if (projectRuntime === 'all') {
82+
throw new Error('Invalid runtimes in your Next.js project. Use only \'node\' or only \'edge\' in your project.');
8183
} else {
84+
// edge runtime
8285
await runDefaultBuild(nextVersion);
8386
}
8487

0 commit comments

Comments
 (0)