@codemoreira/esad 2.0.1-23 → 2.0.1-25
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/plugin/index.js +13 -21
- package/src/plugin/runtime-env.js +15 -0
package/package.json
CHANGED
package/src/plugin/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('node:path');
|
|
|
2
2
|
const fs = require('node:fs');
|
|
3
3
|
const Repack = require('@callstack/repack');
|
|
4
4
|
const { ExpoModulesPlugin } = require('@callstack/repack-plugin-expo-modules');
|
|
5
|
-
const { DefinePlugin,
|
|
5
|
+
const { DefinePlugin, BannerPlugin } = require('@rspack/core');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* ESAD Re.Pack Plugin Wrapper
|
|
@@ -76,15 +76,6 @@ function withESAD(env, options) {
|
|
|
76
76
|
presets: [
|
|
77
77
|
['babel-preset-expo', { platform }],
|
|
78
78
|
],
|
|
79
|
-
plugins: [
|
|
80
|
-
[
|
|
81
|
-
require.resolve('babel-plugin-transform-define'),
|
|
82
|
-
{
|
|
83
|
-
'process.env.EXPO_OS': platform,
|
|
84
|
-
'process.env.NODE_ENV': isDev ? 'development' : 'production',
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
],
|
|
88
79
|
sourceType: 'unambiguous',
|
|
89
80
|
caller: { name: 'repack', platform },
|
|
90
81
|
},
|
|
@@ -103,15 +94,6 @@ function withESAD(env, options) {
|
|
|
103
94
|
presets: [
|
|
104
95
|
['babel-preset-expo', { platform }],
|
|
105
96
|
],
|
|
106
|
-
plugins: [
|
|
107
|
-
[
|
|
108
|
-
require.resolve('babel-plugin-transform-define'),
|
|
109
|
-
{
|
|
110
|
-
'process.env.EXPO_OS': platform,
|
|
111
|
-
'process.env.NODE_ENV': isDev ? 'development' : 'production',
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
],
|
|
115
97
|
caller: { name: 'repack', platform },
|
|
116
98
|
},
|
|
117
99
|
},
|
|
@@ -134,8 +116,15 @@ function withESAD(env, options) {
|
|
|
134
116
|
}),
|
|
135
117
|
'__DEV__': JSON.stringify(isDev),
|
|
136
118
|
}),
|
|
137
|
-
new
|
|
138
|
-
|
|
119
|
+
new BannerPlugin({
|
|
120
|
+
raw: true,
|
|
121
|
+
entryOnly: true,
|
|
122
|
+
banner: `
|
|
123
|
+
if (typeof process === 'undefined') { var process = { env: {} }; }
|
|
124
|
+
if (typeof process.env === 'undefined') { process.env = {}; }
|
|
125
|
+
process.env.EXPO_OS = '${platform}';
|
|
126
|
+
process.env.NODE_ENV = '${isDev ? 'development' : 'production'}';
|
|
127
|
+
`,
|
|
139
128
|
}),
|
|
140
129
|
new ExpoModulesPlugin(),
|
|
141
130
|
new Repack.RepackPlugin(),
|
|
@@ -162,6 +151,9 @@ function withESAD(env, options) {
|
|
|
162
151
|
}
|
|
163
152
|
})
|
|
164
153
|
],
|
|
154
|
+
experiments: {
|
|
155
|
+
parallelLoader: false,
|
|
156
|
+
},
|
|
165
157
|
};
|
|
166
158
|
|
|
167
159
|
// Add Host-specific DevServer magic for Expo
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESAD Runtime Environment Polyfill
|
|
3
|
+
* This file is injected at the very beginning of the bundle to ensure
|
|
4
|
+
* that Expo and React Navigation find the expected environment variables.
|
|
5
|
+
*/
|
|
6
|
+
if (typeof global !== 'undefined') {
|
|
7
|
+
global.process = global.process || {};
|
|
8
|
+
global.process.env = global.process.env || {};
|
|
9
|
+
|
|
10
|
+
// These values are placeholders that will be replaced by DefinePlugin
|
|
11
|
+
// or set via BannerPlugin, but here we provide a safe fallback object.
|
|
12
|
+
if (typeof global.process.env !== 'object' || global.process.env === null) {
|
|
13
|
+
global.process.env = {};
|
|
14
|
+
}
|
|
15
|
+
}
|