Skip to content

Commit 20b6c1f

Browse files
committed
not use process.env anymore, since i couldnt typeof check it and still get injection
1 parent 7786edf commit 20b6c1f

File tree

3 files changed

+132
-192
lines changed

3 files changed

+132
-192
lines changed

CHANGELOG-FRONTIER.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## 8.6.0
22

3-
- Add some logic in env.js to look for REACT_APP_ZION_UI_VERSION and REACT_APP_REACT_SCRIPTS_VERSION env vars and calculate
4-
those versions based on the info in their respective package.json files
3+
- Add some logic in webpack.config.js to look for CRA_MAGIC_ZION_UI_VERSION and CRA_MAGIC_REACT_SCRIPTS_VERSION and calculate
4+
those versions based on the info in their respective package.json files, and send that info to DefinePlugin, which will
5+
inject the values directly into any code that has that variable name (which will be in @fs/zion-config)
56

67
## 8.5.5
78

packages/react-scripts/config/env.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@ const fs = require('fs')
1212
const path = require('path')
1313
const paths = require('./paths')
1414

15-
let zionUiVersion
16-
try {
17-
const resolvedZionUiPath = require.resolve('@fs/zion-ui')
18-
const zionUiPackageJson = require(`${resolvedZionUiPath.split('@fs/zion-ui')[0]}@fs/zion-ui/package.json`)
19-
zionUiVersion = zionUiPackageJson.version
20-
} catch (error) {
21-
zionUiVersion = '-'
22-
}
23-
24-
let reactScriptsVersion
25-
try {
26-
const reactScriptsPackageJson = require('../package.json')
27-
reactScriptsVersion = reactScriptsPackageJson.version
28-
} catch (error) {
29-
reactScriptsVersion = '-'
30-
}
31-
3215
// Make sure that including paths.js after env.js will read .env variables.
3316
delete require.cache[require.resolve('./paths')]
3417

@@ -88,13 +71,7 @@ function getClientEnvironment(publicUrl) {
8871
.filter(key => REACT_APP.test(key))
8972
.reduce(
9073
(env, key) => {
91-
if (key === 'REACT_APP_ZION_UI_VERSION') {
92-
env[key] = zionUiVersion
93-
} else if (key === 'REACT_APP_REACT_SCRIPTS_VERSION') {
94-
env[key] = reactScriptsVersion
95-
} else {
96-
env[key] = process.env[key]
97-
}
74+
env[key] = process.env[key]
9875
return env
9976
},
10077
{

0 commit comments

Comments
 (0)