Skip to content

Commit b8ffa3a

Browse files
sommeeeerconico974
andauthored
add check for config and config.default (#464)
* Add check for config.default being undefined * Add check for both config and config.default * Create eighty-masks-cheat.md --------- Co-authored-by: conico974 <nicodorseuil@yahoo.fr>
1 parent 7beaf82 commit b8ffa3a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.changeset/eighty-masks-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
add check for config and config.default

docs/pages/config.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ There is two build arguments that you can pass to the `open-next build` command:
77

88
### Configuration File
99

10-
For personalisation you need to create a file `open-next.config.ts` at the same place as your `next.config.js`, and export a default object that satisfies the `OpenNextConfig` interface.
10+
For personalisation you need to create a file `open-next.config.ts` at the same place as your `next.config.js`, and export a default object that satisfies the `OpenNextConfig` interface. It is possible to not have an `open-next.config.ts` file, the default configuration will then be applied automatically.
1111

1212
This file needs to be placed at the same level as your `next.config.js` file.
1313

14+
If you have an `open-next.config.ts` file, make sure you have atleast this:
15+
16+
```ts
17+
export default {
18+
default: {},
19+
};
20+
```
21+
1422
If you want to take a look at some simple configuration examples, you can check the [simple example](/config/simple_example).
1523

1624
For more advanced use cases, you can check [how to implement custom overrides](/config/custom_overrides).

packages/open-next/src/build.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ export async function build(
5858
// On Windows, we need to use file:// protocol to load the config file using import()
5959
if (process.platform === "win32") configPath = `file://${configPath}`;
6060
config = (await import(configPath)).default as OpenNextConfig;
61+
if (!config || !config.default) {
62+
logger.error(
63+
`config.default cannot be empty, it should be at least {}, see more info here: https://open-next.js.org/config#configuration-file`,
64+
);
65+
process.exit(1);
66+
}
6167
validateConfig(config);
6268

6369
compileOpenNextConfigEdge(tempDir, config, openNextConfigPath);

0 commit comments

Comments
 (0)