@expofp/utils 3.28.3 → 3.29.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.
@@ -2,7 +2,15 @@ export async function importNodeModule(moduleName) {
2
2
  if (typeof process === 'undefined' || !process.versions?.node) {
3
3
  throw new Error('importNodeModule can only be used in Node.js environments');
4
4
  }
5
- // prevents Vite/Rollup from analyzing the import specifier
6
- // eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
7
- return new Function('moduleName', 'return import(moduleName)')(moduleName);
5
+ try {
6
+ // prevents every bundler (Vite, Rollup, webpack alike) from analyzing the specifier
7
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
8
+ return (await new Function('moduleName', 'return import(moduleName)')(moduleName));
9
+ }
10
+ catch {
11
+ // A `new Function` scope has no dynamic-import callback under module
12
+ // runners like vitest's — fall back to a literal import, hidden from
13
+ // bundlers by the magic comments instead.
14
+ return (await import(/* @vite-ignore */ /* webpackIgnore: true */ moduleName));
15
+ }
8
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expofp/utils",
3
- "version": "3.28.3",
3
+ "version": "3.29.0",
4
4
  "type": "module",
5
5
  "description": "ExpoFP SDK internal: shared utilities",
6
6
  "homepage": "https://developer.expofp.com/",