Skip to content

Commit 80151a5

Browse files
committed
Avoid using destructuring syntax in browser shim
1 parent 879ec98 commit 80151a5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

config.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
/**
2+
* This is a browser shim for the `config` module that gets its configuration
3+
* values from `next/config`. It supports the `get()` and `has()` methods but
4+
* not extras like `config.util`. Since this file will not be transpiled, it
5+
* must use syntax supported by all browsers.
6+
*/
17
var getConfig = require("next/config").default;
28

3-
var { serverRuntimeConfig, publicRuntimeConfig } = getConfig();
4-
59
/**
610
* Underlying `get` mechanism.
711
*
@@ -53,10 +57,13 @@ function has(obj, property) {
5357
return getImpl(obj, property) !== undefined;
5458
}
5559

56-
const {
57-
nodeConfigServerKey = "serverRuntimeConfig",
58-
nodeConfigPublicKey = "publicRuntimeConfig"
59-
} = publicRuntimeConfig;
60+
var runtimeConfig = getConfig();
61+
var serverRuntimeConfig = runtimeConfig.serverRuntimeConfig;
62+
var publicRuntimeConfig = runtimeConfig.publicRuntimeConfig;
63+
var nodeConfigServerKey =
64+
publicRuntimeConfig.nodeConfigServerKey || "serverRuntimeConfig";
65+
var nodeConfigPublicKey =
66+
publicRuntimeConfig.nodeConfigPublicKey || "publicRuntimeConfig";
6067

6168
var config = {};
6269
config[nodeConfigServerKey] = serverRuntimeConfig;

0 commit comments

Comments
 (0)