How to use the @expo/webpack-config/loaders.createBabelLoaderFromEnvironment function in @expo/webpack-config

To help you get started, we’ve selected a few @expo/webpack-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-cli / packages / electron-adapter / src / Webpack.ts View on Github external
if (entries.renderer.length > 2) {
          throw new Error(
            `electron-adapter app entry hack doesn't work with this version of electron-webpack. The expected entry length should be 2, instead got: [${entries.renderer.join(
              ', '
            )}]`
          );
        } else {
          console.log(` Using custom entry point > ${expoEntryPointPath}`);
        }
      }
      return entries;
    };
  }

  const babelConfig = createBabelLoaderFromEnvironment(env);

  // Modify externals https://github.com/electron-userland/electron-webpack/issues/81
  const includeFunc = babelConfig.include as (path: string) => boolean;
  if (config.externals) {
    config.externals = (config.externals as any)
      .map((external: any) => {
        if (typeof external !== 'function') {
          const relPath = path.join('node_modules', external);
          if (!includeFunc(relPath)) return external;
          return null;
        }
        return (ctx: any, req: any, cb: any) => {
          const relPath = path.join('node_modules', req);
          return includeFunc(relPath) ? cb() : external(ctx, req, cb);
        };
      })