Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MainApplication : MultiDexApplication(), ReactApplication {
add(NavBarManagerPackage())
}

override fun getJSMainModuleName() = ".expo/.virtual-metro-entry"
override fun getJSMainModuleName() = "index"

override val isNewArchEnabled: Boolean
get() = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
Expand Down
10 changes: 9 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const webpack = {
};

const metro = {
presets: [require('@react-native/babel-preset')],
presets: [[require('@react-native/babel-preset'), {disableImportExportTransform: true}]],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

Suggested change
presets: [[require('@react-native/babel-preset'), {disableImportExportTransform: true}]],
presets: [[require('@react-native/babel-preset'), {disableImportExportTransform: runningIn !== 'babel-jest'}]],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about if, but for it we will have to wrap metro config into module to get the runningIn variable from api.
If metro is outside the function, it builds once when the module loads. If we move it inside it rebuilds on every Babel call. TBH I am not sure if it will impact the performance, but it might.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

plugins: [
['babel-plugin-react-compiler', ReactCompilerConfig], // must run first!

Expand Down Expand Up @@ -177,5 +177,13 @@ module.exports = (api) => {
const runningIn = api.caller((args = {}) => args.name);
console.debug(' - running in: ', runningIn);

const isJest = runningIn === 'babel-jest';
if (isJest) {
return {
...metro,
presets: [[require('@react-native/babel-preset'), {disableImportExportTransform: false}]],
};
}

return ['metro', 'babel-jest'].includes(runningIn) ? metro : webpack;
};
5 changes: 2 additions & 3 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const {getDefaultConfig: getExpoDefaultConfig} = require('expo/metro-config');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expo/metro-config could potentially be removed from the project deps as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t have this package directly added to package.json, so there’s nothing to remove on our side. We still have some expo packages in the project, it can be required indirectly as a transitive dependency though

const {getDefaultConfig: getReactNativeDefaultConfig} = require('@react-native/metro-config');

const {mergeConfig} = require('@react-native/metro-config');
Expand All @@ -13,7 +12,6 @@ const envPath = process.env.ENVFILE ? (path.isAbsolute(process.env.ENVFILE) ? pr
require('dotenv').config({path: envPath});

const defaultConfig = getReactNativeDefaultConfig(__dirname);
const expoConfig = getExpoDefaultConfig(__dirname);

const isE2ETesting = process.env.E2E_TESTING === 'true';
const e2eSourceExts = ['e2e.js', 'e2e.ts', 'e2e.tsx'];
Expand All @@ -37,6 +35,7 @@ const config = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: true,
inlineRequires: true,
},
}),
Expand All @@ -48,6 +47,6 @@ const config = {
: {},
};

const mergedConfig = wrapWithReanimatedMetroConfig(mergeConfig(defaultConfig, expoConfig, config));
const mergedConfig = wrapWithReanimatedMetroConfig(mergeConfig(defaultConfig, config));

module.exports = isDev ? mergedConfig : withSentryConfig(mergedConfig);
Loading