|
1 |
| -/* eslint-disable no-console, no-continue, no-unused-vars */ |
| 1 | +/* eslint-disable no-continue, no-unused-vars */ |
2 | 2 | import camelCase from 'camelcase';
|
3 | 3 | import glob from 'glob';
|
4 | 4 | import set from 'lodash.set';
|
@@ -187,32 +187,31 @@ export function exportFunctions({
|
187 | 187 | // eslint-disable-next-line no-restricted-syntax
|
188 | 188 | for (const file of files) {
|
189 | 189 | const absPath = resolve(cwd, file);
|
190 |
| - const standardRelativePath = absPath.substr(cwd.length + 1); /* ? */ |
191 |
| - const funcName = funcNameFromRelPath(standardRelativePath); /* ? */ |
192 |
| - if (isDeployment() || funcNameMatchesInstance(funcName)) { |
193 |
| - if (!isDeployment()) log.timeEnd(moduleSearchMsg); |
194 |
| - if (absPath.slice(0, -2) === __filename.slice(0, -2)) continue; // Prevent exporting self |
195 |
| - |
196 |
| - if (exportPathMode) { |
197 |
| - set(exports, funcName.replace(/-/g, '.'), standardRelativePath); |
198 |
| - continue; |
199 |
| - } |
200 |
| - if (!isDeployment()) log.time(coldModuleMsg); |
201 |
| - let funcTrigger: any; |
202 |
| - try { |
203 |
| - // eslint-disable-next-line no-eval |
204 |
| - const mod = eval('require')(absPath); // This is to preserve require call in webpack |
205 |
| - funcTrigger = extractTrigger(mod, getFunctionInstance()); |
206 |
| - } catch (err) { |
207 |
| - console.error(err); |
208 |
| - continue; |
209 |
| - } |
210 |
| - if (!isDeployment()) log.timeEnd(coldModuleMsg); |
211 |
| - if (!funcTrigger) continue; |
212 |
| - const propPath = funcName.replace(/-/g, '.'); /* ? */ |
213 |
| - set(exports, propPath, funcTrigger); |
| 190 | + const normalizedRelativePath = absPath.slice(cwd.length + 1); // * This step normalises glob match search string |
| 191 | + const funcName = funcNameFromRelPath(normalizedRelativePath); /* ? */ |
| 192 | + if (!isDeployment() && !funcNameMatchesInstance(funcName)) continue; |
| 193 | + if (!isDeployment()) log.timeEnd(moduleSearchMsg); |
| 194 | + if (absPath.slice(0, -2) === __filename.slice(0, -2)) continue; // Prevent exporting self |
| 195 | + |
| 196 | + if (exportPathMode) { |
| 197 | + set(exports, funcName.split('-'), normalizedRelativePath); |
| 198 | + continue; |
214 | 199 | }
|
215 |
| - } // End loop |
| 200 | + if (!isDeployment()) log.time(coldModuleMsg); |
| 201 | + let funcTrigger: any; |
| 202 | + try { |
| 203 | + // eslint-disable-next-line no-eval |
| 204 | + const mod = eval('require')(absPath); // This is to preserve require call in webpack |
| 205 | + funcTrigger = extractTrigger(mod, getFunctionInstance()); |
| 206 | + } catch (err) { |
| 207 | + console.warn(err); |
| 208 | + continue; |
| 209 | + } |
| 210 | + if (!isDeployment()) log.timeEnd(coldModuleMsg); |
| 211 | + if (!funcTrigger) continue; |
| 212 | + const propPath = funcName.split('-'); |
| 213 | + set(exports, propPath, funcTrigger); |
| 214 | + } |
216 | 215 |
|
217 | 216 | if (isDeployment()) log.timeEnd(deployMsg);
|
218 | 217 | return exports;
|
|
0 commit comments