@fto-consult/expo-ui 5.0.2 → 5.1.0

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/babel.config.js CHANGED
@@ -2,30 +2,19 @@ module.exports = function(api,opts) {
2
2
  opts = typeof opts =='object' && opts ? opts : {};
3
3
  api = api && typeof api =='object'? api : {};
4
4
  ///les chemin vers la variable d'environnement, le chemin du fichier .env,@see : https://github.com/brysgo/babel-plugin-inline-dotenv
5
- let environmentPath = opts.environmentPath || opts.envPath;
6
5
  //console.log(environmentPath," is envvv ",opts);
7
6
  const path = require("path");
8
7
  const fs = require("fs");
9
8
  const dir = path.resolve(__dirname);
10
9
  typeof api.cache =='function' && api.cache(true);
11
- const inlineDovOptions = {};
10
+ const inlineDovOptions = { unsafe: true};
12
11
  const options = {base:dir,...opts,platform:"expo"};
13
- /*** par défaut, les variables d'environnements sont stockés dans le fichier .env situé à la racine du projet, référencée par la prop base */
14
- if(!environmentPath || typeof environmentPath !== 'string'){
15
- const baseStr = typeof options.base =='string' && fs.existsSync(options.base)? options.base : typeof options.dir =='string' && fs.existsSync(options.dir)? options.dir : dir;
16
- environmentPath = path.resolve(baseStr,".env");
17
- } else {
18
- environmentPath = "";
19
- }
20
- if(environmentPath && fs.existsSync(environmentPath)){
21
- // File ".env" will be created or overwritten by default.
22
- try {
23
- fs.copyFileSync(environmentPath, path.resolve(dir,'.env'));
24
- }
25
- catch (e){
26
- inlineDovOptions.path = environmentPath;
27
- }
12
+ const environmentPath = require("./copy-env-file")();
13
+ if(fs.existsSync(environmentPath)){
14
+ inlineDovOptions.path ='./.env';
28
15
  }
16
+ /*** par défaut, les variables d'environnements sont stockés dans le fichier .env situé à la racine du projet, référencée par la prop base */
17
+
29
18
  const alias = require("./babel.config.alias")(options);
30
19
  return {
31
20
  presets: [
@@ -36,7 +25,11 @@ module.exports = function(api,opts) {
36
25
  ["inline-dotenv",inlineDovOptions],
37
26
  ["module-resolver", {"alias": alias}],
38
27
  ['@babel/plugin-proposal-export-namespace-from'],
39
- ['transform-inline-environment-variables'],
28
+ ['transform-inline-environment-variables',{
29
+ "include": [
30
+ "NODE_ENV"
31
+ ]
32
+ }],
40
33
  ['react-native-reanimated/plugin'],
41
34
  ],
42
35
  };
package/bin/index.js CHANGED
@@ -52,6 +52,8 @@ if(parsedArgs.electron){
52
52
  }
53
53
  const electronProjectRoot = path.resolve(projectRoot,"electron");
54
54
  const isElectionInitialized = require("../electron/is-initialized")(electronProjectRoot);
55
+ process.env.isElectron = true;
56
+ process.env.isElectronScript = true;
55
57
  if(!isElectionInitialized || script =='init'){
56
58
  if(script !=='init'){
57
59
  console.log("initializing electron application before ....");
@@ -4,22 +4,28 @@ module.exports = function({config,nodeModulesPath}){
4
4
  const expoUi = path.resolve(require("./expo-ui-path")());
5
5
  nodeModulesPath = Array.isArray(nodeModulesPath)? nodeModulesPath : [];
6
6
  config.resolve.modules = Array.isArray(config.resolve.modules)? config.resolve.modules:[]
7
- config.resolve.modules = [path.resolve(base, 'node_modules'), 'node_modules',...nodeModulesPath,...config.resolve.modules];
7
+ config.resolve.modules = [path.resolve(base, 'node_modules'),path.resolve(expoUi,"node_modules"),...nodeModulesPath,...config.resolve.modules];
8
8
  config.module.rules.push({
9
9
  test: /\.(js|jsx|ts|tsx)$/,
10
+ type: "javascript/auto",
10
11
  include: [
11
12
  base,
12
- path.resolve(expoUi,"node_modules","@fto-consult"),
13
- /(common)/
13
+ /node_modules\/@fto-consult/,
14
+ expoUi,
14
15
  ],
15
16
  exclude:[
16
- path.resolve(base,"nodes_modules"),
17
- path.resolve(expoUi,"node_modules"),
18
17
  /node_modules[/\\](?!react-native-paper|react-native|react-native-vector-icons|react-native-safe-area-view)/,
19
- /(node_modules)/
20
18
  ],
21
19
  use: {
22
20
  loader: 'babel-loader',
21
+ },
22
+ });
23
+ config.module.rules.push({
24
+ test: /\.mjs$/,
25
+ include: /node_modules/,
26
+ type: 'javascript/auto',
27
+ resolve: {
28
+ fullySpecified: false
23
29
  }
24
30
  });
25
31
  config.plugins.push(require("@fto-consult/common/circular-dependencies"));
@@ -0,0 +1,22 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const writeFile = require("./electron/utils/writeFile");
4
+ /*** create and copy environment path to this directory
5
+ *
6
+ */
7
+ module.exports = (projectRoot,forceCreate)=>{
8
+ projectRoot = projectRoot && typeof projectRoot =="string" && fs.existsSync(projectRoot) && projectRoot || process.cwd();
9
+ const environmentPath = path.resolve(projectRoot,".env");
10
+ const localEnv = path.resolve(__dirname,".env");
11
+ if(environmentPath && fs.existsSync(environmentPath)){
12
+ // File ".env" will be created or overwritten by default.
13
+ try {
14
+ fs.copyFileSync(environmentPath, localEnv,fs.constants.COPYFILE_FICLONE_FORCE);
15
+ }
16
+ catch (e){}
17
+ }
18
+ if(!fs.existsSync(localEnv) && forceCreate !==false){
19
+ writeFile(localEnv,"");
20
+ }
21
+ return localEnv;
22
+ }
@@ -2,6 +2,9 @@ const exec = require('child_process').exec;
2
2
  const fs = require("fs");
3
3
  const _exec = (cmd,cmdOpts,logMessages)=>{
4
4
  cmdOpts = typeof cmdOpts =='object' && cmdOpts || {};
5
+ cmdOpts.env = typeof cmdOpts.env =="object" && cmdOpts.env || {};
6
+ cmdOpts.env = {...process.env,...cmdOpts.env};
7
+ cmdOpts.env.platform = cmdOpts.env.platform || "electron";
5
8
  return new Promise((resolve,reject)=>{
6
9
  const timer = cmdOpts.loader !==false ? loaderTimer(cmd) : null;
7
10
  exec(cmd,cmdOpts, (error, stdout, stderr) => {
package/metro.config.js CHANGED
@@ -1,6 +1,10 @@
1
- const { getDefaultConfig } = require('@expo/metro-config');
2
1
  const path = require("path");
2
+ const fs = require("fs");
3
3
  module.exports = function(opts){
4
+ const nodeModulePath = `${process.cwd()}/node_modules`;
5
+ const mConfigPath = fs.existsSync(`${nodeModulePath}/@expo/metro-config`) && `${nodeModulePath}/@expo/metro-config` || "@expo/metro-config";
6
+ const { getDefaultConfig } = require(`${mConfigPath}`);
7
+
4
8
  opts = opts && typeof opts =='object'? opts : {};
5
9
  let {assetExts,sourceExts} = opts;
6
10
  assetExts = Array.isArray(assetExts)? assetExts: [];
@@ -8,10 +12,11 @@ module.exports = function(opts){
8
12
  const projectRoot = process.cwd();
9
13
  const localDir = path.resolve(__dirname);
10
14
  const config = getDefaultConfig(projectRoot);
11
- config.watchFolders = [projectRoot];
15
+ config.watchFolders = Array.isArray(config.watchFolders) && config.watchFolders || [];
12
16
  if(projectRoot !== localDir){
13
17
  config.watchFolders.push(localDir);
14
18
  }
19
+ config.projectRoot = projectRoot;
15
20
  config.resolver.assetExts = [
16
21
  ...config.resolver.assetExts,
17
22
  ...assetExts,
@@ -25,5 +30,11 @@ module.exports = function(opts){
25
30
  ]
26
31
  // Remove all console logs in production...
27
32
  config.transformer.minifierConfig.compress.drop_console = false;
33
+ /*config.platforms = Array.isArray(config.platforms) && config.platforms || [];
34
+ ['ios', 'android', 'windows', 'web',"electron"].map(p=>{
35
+ if(!config.platforms.includes(p)){
36
+ config.platforms.push(p);
37
+ }
38
+ });*/
28
39
  return config;
29
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "5.0.2",
3
+ "version": "5.1.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,7 +61,7 @@
61
61
  "@emotion/native": "^11.10.0",
62
62
  "@expo/html-elements": "^0.2.0",
63
63
  "@expo/vector-icons": "^13.0.0",
64
- "@fto-consult/common": "^2.20.13",
64
+ "@fto-consult/common": "^2.20.14",
65
65
  "@gorhom/portal": "^1.0.14",
66
66
  "@react-native-async-storage/async-storage": "^1.17.11",
67
67
  "@react-native-community/datetimepicker": "^6.7.3",
@@ -85,6 +85,7 @@
85
85
  "google-libphonenumber": "^3.2.31",
86
86
  "htmlparser2-without-node-native": "^3.9.2",
87
87
  "mongo-parse": "^2.1.0",
88
+ "process": "^0.11.10",
88
89
  "prop-types": "^15.8.1",
89
90
  "react": "^18.2.0",
90
91
  "react-apexcharts": "^1.4.0",
@@ -113,7 +114,7 @@
113
114
  "devDependencies": {
114
115
  "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
115
116
  "@babel/preset-react": "^7.18.6",
116
- "@expo/metro-config": "^0.5.2",
117
+ "@expo/metro-config": "^0.7.1",
117
118
  "@expo/webpack-config": "^18.0.1",
118
119
  "babel-plugin-inline-dotenv": "^1.7.0",
119
120
  "babel-plugin-module-resolver": "^4.1.0",
@@ -0,0 +1,184 @@
1
+ // shim for using process in browser
2
+ var process = module.exports = {};
3
+
4
+ // cached from whatever global is present so that test runners that stub it
5
+ // don't break things. But we need to wrap it in a try catch in case it is
6
+ // wrapped in strict mode code which doesn't define any globals. It's inside a
7
+ // function because try/catches deoptimize in certain engines.
8
+
9
+ var cachedSetTimeout;
10
+ var cachedClearTimeout;
11
+
12
+ function defaultSetTimout() {
13
+ throw new Error('setTimeout has not been defined');
14
+ }
15
+ function defaultClearTimeout () {
16
+ throw new Error('clearTimeout has not been defined');
17
+ }
18
+ (function () {
19
+ try {
20
+ if (typeof setTimeout === 'function') {
21
+ cachedSetTimeout = setTimeout;
22
+ } else {
23
+ cachedSetTimeout = defaultSetTimout;
24
+ }
25
+ } catch (e) {
26
+ cachedSetTimeout = defaultSetTimout;
27
+ }
28
+ try {
29
+ if (typeof clearTimeout === 'function') {
30
+ cachedClearTimeout = clearTimeout;
31
+ } else {
32
+ cachedClearTimeout = defaultClearTimeout;
33
+ }
34
+ } catch (e) {
35
+ cachedClearTimeout = defaultClearTimeout;
36
+ }
37
+ } ())
38
+ function runTimeout(fun) {
39
+ if (cachedSetTimeout === setTimeout) {
40
+ //normal enviroments in sane situations
41
+ return setTimeout(fun, 0);
42
+ }
43
+ // if setTimeout wasn't available but was latter defined
44
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
45
+ cachedSetTimeout = setTimeout;
46
+ return setTimeout(fun, 0);
47
+ }
48
+ try {
49
+ // when when somebody has screwed with setTimeout but no I.E. maddness
50
+ return cachedSetTimeout(fun, 0);
51
+ } catch(e){
52
+ try {
53
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
54
+ return cachedSetTimeout.call(null, fun, 0);
55
+ } catch(e){
56
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
57
+ return cachedSetTimeout.call(this, fun, 0);
58
+ }
59
+ }
60
+
61
+
62
+ }
63
+ function runClearTimeout(marker) {
64
+ if (cachedClearTimeout === clearTimeout) {
65
+ //normal enviroments in sane situations
66
+ return clearTimeout(marker);
67
+ }
68
+ // if clearTimeout wasn't available but was latter defined
69
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
70
+ cachedClearTimeout = clearTimeout;
71
+ return clearTimeout(marker);
72
+ }
73
+ try {
74
+ // when when somebody has screwed with setTimeout but no I.E. maddness
75
+ return cachedClearTimeout(marker);
76
+ } catch (e){
77
+ try {
78
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
79
+ return cachedClearTimeout.call(null, marker);
80
+ } catch (e){
81
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
82
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
83
+ return cachedClearTimeout.call(this, marker);
84
+ }
85
+ }
86
+
87
+
88
+
89
+ }
90
+ var queue = [];
91
+ var draining = false;
92
+ var currentQueue;
93
+ var queueIndex = -1;
94
+
95
+ function cleanUpNextTick() {
96
+ if (!draining || !currentQueue) {
97
+ return;
98
+ }
99
+ draining = false;
100
+ if (currentQueue.length) {
101
+ queue = currentQueue.concat(queue);
102
+ } else {
103
+ queueIndex = -1;
104
+ }
105
+ if (queue.length) {
106
+ drainQueue();
107
+ }
108
+ }
109
+
110
+ function drainQueue() {
111
+ if (draining) {
112
+ return;
113
+ }
114
+ var timeout = runTimeout(cleanUpNextTick);
115
+ draining = true;
116
+
117
+ var len = queue.length;
118
+ while(len) {
119
+ currentQueue = queue;
120
+ queue = [];
121
+ while (++queueIndex < len) {
122
+ if (currentQueue) {
123
+ currentQueue[queueIndex].run();
124
+ }
125
+ }
126
+ queueIndex = -1;
127
+ len = queue.length;
128
+ }
129
+ currentQueue = null;
130
+ draining = false;
131
+ runClearTimeout(timeout);
132
+ }
133
+
134
+ process.nextTick = function (fun) {
135
+ var args = new Array(arguments.length - 1);
136
+ if (arguments.length > 1) {
137
+ for (var i = 1; i < arguments.length; i++) {
138
+ args[i - 1] = arguments[i];
139
+ }
140
+ }
141
+ queue.push(new Item(fun, args));
142
+ if (queue.length === 1 && !draining) {
143
+ runTimeout(drainQueue);
144
+ }
145
+ };
146
+
147
+ // v8 likes predictible objects
148
+ function Item(fun, array) {
149
+ this.fun = fun;
150
+ this.array = array;
151
+ }
152
+ Item.prototype.run = function () {
153
+ this.fun.apply(null, this.array);
154
+ };
155
+ process.title = 'browser';
156
+ process.browser = true;
157
+ process.env = {};
158
+ process.argv = [];
159
+ process.version = ''; // empty string to avoid regexp issues
160
+ process.versions = {};
161
+
162
+ function noop() {}
163
+
164
+ process.on = noop;
165
+ process.addListener = noop;
166
+ process.once = noop;
167
+ process.off = noop;
168
+ process.removeListener = noop;
169
+ process.removeAllListeners = noop;
170
+ process.emit = noop;
171
+ process.prependListener = noop;
172
+ process.prependOnceListener = noop;
173
+
174
+ process.listeners = function (name) { return [] }
175
+
176
+ process.binding = function (name) {
177
+ throw new Error('process.binding is not supported');
178
+ };
179
+
180
+ process.cwd = function () { return '/' };
181
+ process.chdir = function (dir) {
182
+ throw new Error('process.chdir is not supported');
183
+ };
184
+ process.umask = function() { return 0; };
package/readMe.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ## Installation des dépendences, packages de dévéloppement
2
2
 
3
3
  ```javascript
4
- npm i --D @babel/plugin-proposal-export-namespace-from @babel/preset-react babel-plugin-inline-dotenv babel-plugin-module-resolver babel-plugin-transform-inline-environment-variables @expo/metro-config @expo/webpack-config
4
+ npm i --D @babel/plugin-proposal-export-namespace-from @babel/preset-react babel-plugin-inline-dotenv babel-plugin-module-resolver babel-plugin-transform-inline-environment-variables @expo/metro-config @expo/webpack-config
5
5
  ```
6
6
 
7
7
  ## **#ELECTRON**
@@ -10,6 +10,9 @@ import PhoneNumber from "./PhoneNumber";
10
10
  import SelectCountry from "$ecomponents/Countries/SelectCountry";
11
11
  import {getFlag} from "$ecomponents/Countries";
12
12
 
13
+ export {PhoneNumber};
14
+ export * from "./PhoneNumber";
15
+
13
16
  import libPhoneNumber from 'google-libphonenumber';
14
17
  const asYouTypeFormatter = libPhoneNumber.AsYouTypeFormatter;
15
18
 
@@ -116,6 +119,7 @@ export default function PhoneInputComponent(props){
116
119
  country : iso2,
117
120
  displayValue,
118
121
  defaultValue : modifiedNumber,
122
+ countryDialCode
119
123
  }
120
124
  setState(nState);
121
125
  return nState;
@@ -137,6 +141,9 @@ export default function PhoneInputComponent(props){
137
141
  <>
138
142
  <TextField
139
143
  {...rest}
144
+ toCase = {(val)=>{
145
+ return (val.startsWith("+")?"+":"")+val.replace(/[^\s0-9]/g, '');
146
+ }}
140
147
  testID = {testID}
141
148
  error = {error}
142
149
  errorText = {errorText}
@@ -162,18 +169,19 @@ export default function PhoneInputComponent(props){
162
169
  }
163
170
  keyboardType ={keyboardTypes.number}
164
171
  defaultValue = {state.displayValue}
165
- onChange = {({value:nValue})=>{
172
+ onChange = {(args)=>{
173
+ const {value:nValue} = args;
166
174
  const prevState = state;
167
175
  const nState = updateValue(nValue);
168
- if(prevState.defaultValue === nState.defaultValue || (prevState.defaultValue.length <= 3 && nState.defaultValue.length <= 3)) return;
169
- let value = nState.displayValue;
170
- if(value.length <=3){
171
- value = "";
172
- }
173
- if(prevState.defaultValue === value) return;
174
- if(onChange){
175
- onChange({value,country:nState.country,displayValue:nState.displayValue,realValue:nState.defaultValue})
176
- }
176
+ let value = defaultStr(nState.defaultValue).trim();
177
+ if(prevState.defaultValue === value) return;
178
+ if(value =="+" || value =="("){
179
+ value = "";
180
+ }
181
+ if(prevState.defaultValue === value) return;
182
+ if(onChange){
183
+ onChange({...nState,value,country:nState.country,displayValue:nState.displayValue,realValue:nState.defaultValue})
184
+ }
177
185
  }}
178
186
  ref = {ref}
179
187
  style = {[props.style,inputProps.style,disabledStyle]}
@@ -31,7 +31,7 @@ const isIos = _isIos();
31
31
 
32
32
 
33
33
  const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
34
- let {defaultValue,color,validType,validRule,placeholder,outlined,placeholderColor,
34
+ let {defaultValue,toCase:toCustomCase,color,validType,validRule,placeholder,outlined,placeholderColor,
35
35
  label,labelProps,labelStyle,fontSize,containerProps,selection,roundness,
36
36
  autoCapitalize,disabled,editable,readOnly,elevation,divider,render,
37
37
  leftContainerProps,left,right,rightContainerProps,rows,
@@ -149,8 +149,11 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
149
149
  if(t === emptyValue){
150
150
  t = "";
151
151
  }
152
- if((upper !== true && lower !== true) || isAndroid) return typeof t =='string'? t : "";
153
- return isNonNullString(t)? (upper ? t.toUpperCase() : lower ? t.toLowerCase():t) : ""
152
+ const ret = ((upper !== true && lower !== true) || isAndroid) ? (typeof t =='string'? t : "") : (isNonNullString(t)? (upper ? t.toUpperCase() : lower ? t.toLowerCase():t) : "");
153
+ if(toCustomCase){
154
+ toCustomCase(ret);
155
+ }
156
+ return ret;
154
157
  };
155
158
  const [text, _setText] = React.useState(toCase(defaultValue));
156
159
  const previousText = React.usePrevious(text);
@@ -748,5 +751,6 @@ TextFieldComponent.propTypes = {
748
751
  ///le style à afficher sur l'affix
749
752
  affixStyle : PropTypes.object,
750
753
  handleOpacity : PropTypes.bool,///si l'opacité sera géré automatiquement en fonction du status disabled de la textField
754
+ toCase : PropTypes.func,
751
755
  };
752
756
 
@@ -16,7 +16,6 @@ export default function NavigationComponent (props){
16
16
  const drawerScreens = handleContent({screens:allScreens,hasGetStarted,initialRouteName,state,Factory:Stack});
17
17
  const stackScreens = handleContent({screens:allScreens.modals,hasGetStarted,initialRouteName,state,Factory:Stack});
18
18
  if(!drawerScreens.length && !stackScreens.length){
19
- willRenderNavigation = false;
20
19
  console.error("apps will stuck on splash screen because any valid screen has been found on screens ",allScreens);
21
20
  }
22
21
  setInitialRouteName(initialRouteName);
package/webpack.config.js CHANGED
@@ -1,22 +1,35 @@
1
- /**@see : https://www.npmjs.com/package/@expo/webpack-config/v/0.11.4 */
2
- const createExpoWebpackConfigAsync = require('@expo/webpack-config')
3
- const path = require("path");
1
+ /**@see : https://www.npmjs.com/package/@expo/webpack-config */
4
2
  const isObj = x => x && typeof x =='object' && !Array.isArray(x);
3
+ //const webpack = require("webpack");
4
+ const fs = require("fs");
5
+ const supportedPlatforms = ["web","electron"];
6
+ const mainExtensions = [".js", ".jsx",".ts",".tsx",".mjs"];
7
+ const path = require("path");
8
+
5
9
  // Expo CLI will await this method so you can optionally return a promise.
6
10
  module.exports = async function(env, argv,opts) {
11
+ const nodeModulePath = `${process.cwd()}/node_modules`;
12
+ const wConfigPath = fs.existsSync(`${nodeModulePath}/@expo/webpack-config`) && `${nodeModulePath}/@expo/webpack-config` || "@expo/webpack-config";
13
+ const webpackPath = fs.existsSync(`${nodeModulePath}/webpack`) && `${nodeModulePath}/webpack` || "webpack";
14
+ const webpack = require(`${webpackPath}`);
15
+ const createExpoWebpackConfigAsync = require(wConfigPath);
7
16
  env = env || {};
8
17
  opts = typeof opts =="object" && opts ? opts : {};
9
18
  const babel = isObj(opts.babel)? opts.babel : {};
10
- const isElectron = typeof env.platform =="string" && env.platform.toLowerCase().trim() ==='electron';
19
+ const isElectron = process.env.isElectron || process.env.platform =="electron" || typeof env.platform =="string" && env.platform.toLowerCase().trim() ==='electron';
11
20
  if(isElectron){
12
21
  env.platform = "electron";
13
22
  env.mode = env.mode =="production" && "production" || "development";
14
23
  env.pwa = false;
15
24
  }
25
+ const platform = isElectron && "electron" || process.env.platform && supportedPlatforms.includes(process.platform) && process.platform || typeof opts.platform =="string" && supportedPlatforms.includes(opts.platform)? opts.platform : "web";
16
26
  const transpileModules = Array.isArray(opts.transpileModules)? opts.transpileModules : [];
27
+ const projectRoot = opts.projectRoot && typeof opts.projectRoot =="string" && fs.existsSync(opts.projectRoot) && opts.projectRoot || process.cwd();
17
28
  const config = await createExpoWebpackConfigAsync(
18
29
  {
19
30
  ...env,
31
+ platform,
32
+ projectRoot,
20
33
  babel: {
21
34
  ...babel,
22
35
  dangerouslyAddModulePathsToTranspile: [
@@ -35,7 +48,6 @@ module.exports = async function(env, argv,opts) {
35
48
  type: "javascript/auto",
36
49
  use: {loader: 'babel-loader'}
37
50
  });
38
- //config.resolve.alias['moduleA'] = 'moduleB';
39
51
  config.mode = (config.mode =="development" || config.mode =='production') ? config.mode : "development";
40
52
  // Maybe you want to turn off compression in dev mode.
41
53
  if (config.mode === 'development') {
@@ -51,11 +63,27 @@ module.exports = async function(env, argv,opts) {
51
63
  config.performance.maxAssetSize = typeof config.performance.maxAssetSize =='number'? config.performance.maxAssetSize : 512000;
52
64
  config.devtool = (config.mode === 'development') ? 'inline-source-map' : false;
53
65
  require("./compiler.config.js")({config,...opts});
66
+ const envPath = require("./copy-env-file")();
67
+ const extensions = config.resolve.extensions;
54
68
  if(isElectron){
55
- const electronPath = process.cwd();
56
- config.output = config.output || {};
57
- config.output.publicPath = "./";
58
- config.output.path = path.join(electronPath,"dist");
69
+ mainExtensions.map((ex)=>{
70
+ const nExt = `.electron${ex}`;
71
+ if(!extensions.includes(nExt)){
72
+ extensions.unshift(nExt);
73
+ }
74
+ });
75
+ //const electronPath = process.cwd();
76
+ //config.output = config.output || {};
77
+ //config.output.publicPath = "./";
78
+ //config.output.path = path.join(electronPath,"dist");
79
+ //writeFile(path.resolve(__dirname,"is-electron-platform.txt"),` ${JSON.stringify(extensions)} is extensions to resolve`)
59
80
  }
81
+ //fix process is not defined
82
+ config.plugins.unshift(new webpack.ProvidePlugin({
83
+ process: 'process/browser',
84
+ }));
85
+ config.resolve.alias.process = "process/browser";
86
+ config.resolve.fallback = typeof config.resolve.fallback =="object" && config.resolve.fallback || {};
87
+ config.resolve.fallback = {...config.resolve.fallback,process: require.resolve('process/browser')};
60
88
  return config;
61
- };
89
+ };;