Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_assertValidProjectRoot(projectRoot);
await stopReactNativeServerAsync(projectRoot);
await Watchman.addToPathAsync(); // Attempt to fix watchman if it's hanging
await Watchman.unblockAndGetVersionAsync(projectRoot);
let { exp } = await readConfigJsonAsync(projectRoot);
let packagerPort = await _getFreePortAsync(19001); // Create packager options
const customLogReporterPath: string = require.resolve(path.join(__dirname, 'reporter'));
let packagerOpts: { [key: string]: any } = {
port: packagerPort,
customLogReporterPath,
// TODO: Bacon: Support .mjs (short-lived JS modules extension that some packages use)
sourceExts: getManagedExtensions([], { isTS: true, isReact: true, isModern: false }),
};
if (options.nonPersistent && Versions.lteSdkVersion(exp, '32.0.0')) {
packagerOpts.nonPersistent = true;
}
if (Versions.gteSdkVersion(exp, '33.0.0')) {
packagerOpts.assetPlugins = resolveModule('expo/tools/hashAssetFiles', projectRoot, exp);
}
if (options.maxWorkers) {
packagerOpts['max-workers'] = options.maxWorkers;
}
if (!Versions.gteSdkVersion(exp, '16.0.0')) {
delete packagerOpts.customLogReporterPath;
export function getModuleFileExtensions(...platforms: string[]): string[] {
// Webpack requires a `.` before each value
return getManagedExtensions(platforms).map(value => `.${value}`);
}
export default function withExpo(nextConfig: NextConfig = {}): NextConfig {
return {
...nextConfig,
pageExtensions: getManagedExtensions(['web']),
webpack(config: AnyConfiguration, options: any): AnyConfiguration {
const expoConfig = withUnimodules(
config,
{
projectRoot: nextConfig.projectRoot || process.cwd(),
},
{ supportsFontLoading: false }
);
// Use original public path
(expoConfig.output || {}).publicPath = (config.output || {}).publicPath;
// TODO: Bacon: use commonjs for RNW babel maybe...
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(expoConfig, options);
}
function getPlatformPreset(displayOptions, extensions) {
const moduleFileExtensions = getManagedExtensions(extensions);
const testMatch = ['', ...extensions].reduce((arr, cur) => {
const platformExtension = cur ? `.${cur}` : '';
const sourceExtension = `.[jt]s?(x)`;
return [
...arr,
`**/__tests__/**/*spec${platformExtension}${sourceExtension}`,
`**/__tests__/**/*test${platformExtension}${sourceExtension}`,
`**/?(*.)+(spec|test)${platformExtension}${sourceExtension}`,
];
}, []);
return withWatchPlugins({
displayName: displayOptions,
testMatch,
moduleFileExtensions,
snapshotResolver: require.resolve(`../src/snapshot/resolver.${extensions[0]}.js`),
module.exports = function getWebExtensions() {
return getManagedExtensions(['web']);
};