@wular/pnext 0.0.18 → 0.0.19
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.
- package/package.json +1 -1
- package/src/config.ts +21 -12
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -193,18 +193,27 @@ export function pathToFileHref(filePath: string) {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
export function publicEnvDefines() {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
const publicEnv = Object.fromEntries([
|
|
197
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
198
|
+
['NODE_ENV', process.env.NODE_ENV ?? 'production'],
|
|
199
|
+
...Object.entries(process.env).filter(
|
|
200
|
+
([key]) => key.startsWith('NEXT_PUBLIC_') || key.startsWith('PNEXT_PUBLIC_'),
|
|
201
|
+
),
|
|
202
|
+
]) as Record<string, string>
|
|
203
|
+
return {
|
|
204
|
+
// The whole object, not just the keys that happen to be SET at build time. A browser has no
|
|
205
|
+
// `process`, so a `NEXT_PUBLIC_*` the source reads but the environment never defined would
|
|
206
|
+
// otherwise survive as a bare reference and throw ReferenceError on first evaluation - taking
|
|
207
|
+
// hydration, and every event handler on the page, down with it. Reading a missing key off this
|
|
208
|
+
// yields undefined, which is what Next inlines for one.
|
|
209
|
+
'process.env': JSON.stringify(publicEnv),
|
|
210
|
+
...Object.fromEntries(
|
|
211
|
+
Object.entries(publicEnv).map(([key, value]) => [
|
|
212
|
+
`process.env.${key}`,
|
|
213
|
+
JSON.stringify(value),
|
|
214
|
+
]),
|
|
215
|
+
),
|
|
216
|
+
}
|
|
208
217
|
}
|
|
209
218
|
|
|
210
219
|
type FrameworkRuntimeAlias =
|