Closed airowe closed 8 months ago
hey @airowe. could you try to comment out the line
unstable_enablePackageExports: true
in metro.config.js?
hey @airowe. could you try to comment out the line
unstable_enablePackageExports: true
in metro.config.js?
Thanks for the response, @xiongemi. I don't have that set. Here's my metro.config.js:
const { withNxMetro } = require('@nx/react-native');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const {
resolver: { sourceExts, assetExts },
} = defaultConfig;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = withNxMetro(
{
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
},
{
// Change this to true to see debugging info.
// Useful if you have issues resolving modules
debug: true,
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx'
extensions: [],
}
);
module.exports = mergeConfig(defaultConfig, config);
hey @airowe. i got it working after installing 'es6-shim' with below metro.config.js
:
const { withNxMetro } = require('@nx/react-native');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const exclusionList = require('metro-config/src/defaults/exclusionList');
const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const customConfig = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
unstable_enableSymlinks: true,
// unstable_enablePackageExports: true,
},
};
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
// Change this to true to see debugging info.
// Useful if you have issues resolving modules
debug: true,
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
extensions: [],
// Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
watchFolders: [],
});
@xiongemi Thanks for getting back to me. That error seems to now be resolved, but after the app is installed on the device the console log spits out a line for what seems like every file in my repository like this:
[Nx] Resolving: @myapp/ui-native/styles/colors.styles
There are quite a few lines showing in inability to resolve certain files
Unable to resolve with default Metro resolver: @myapp/ui-native/styles/colors.styles
Ultimately leading to the app not running due to module failure
BUNDLE src/main.tsx
LOG Running "DrtreatNative" with {"rootTag":1,"initialProps":{}} ERROR Invariant Violation: "DrtreatNative" has not been registered. This can happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and
AppRegistry.registerComponent
wasn't called., js engine: hermes
Any ideas?
what is the file extension of @myapp/ui-native/styles/colors.styles
? is it .ts file? do you have a repo that i could look at?
what is the file extension of
@myapp/ui-native/styles/colors.styles
? is it .ts file? do you have a repo that i could look at?
It is, yes. But there are other files that are not being resolved as well. Here are some examples:
I tried adding file extensions to the extensions: [],
block, but it didn't seem to have any impact.
Working on getting you access to the repo, but it's a privately maintained one. Do you have an established process for NDA-constrained support?
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Metro Resolver unable to find external lib in node_modules (see error below))
Expected Behavior
Metro Resolver should be able to find external lib in node_modules
GitHub Repo
No response
Steps to Reproduce
nx run-ios myapp --simulator \"iPhone 14 Pro\" --scheme \"DrtreatNativeDevelopment\""
success Successfully built the app 2023-09-25 15:30:20.338 xcodebuild[2122:1267151] Requested but did not find extension point with identifier Xcode.InterfaceBuilderBuildSupport.PlatformDefinition info Installing "/Users/me/Library/Developer/Xcode/DerivedData/myapp-bvvwydadluigygdtmcybjiecneym/Build/Products/Debug-iphonesimulator/MyAppDevelopment.app on iPhone 14 Pro" info Launching "com.my.app.development" success Successfully launched the app on the simulator BUNDLE src/main.tsx
Nx Report
Failure Logs
Package Manager Version
npm 9.5.1
Operating System
Additional Information
No response