-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic imports do not respect watchFolders configuration #1269
Comments
Hmm - thanks for the report. That's unexpected and it's particularly surprising that dynamic imports should be any different here - does it work if you use a static |
Sure thing!
Indeed it does, a simple
up with the imports in
Additionally it works fine if I prevent hoisting of |
That is quite bizarre! The resolution logic should be exactly the same afaik. Would you be able to share your |
Sure, it's fairly simple: // eslint-disable-next-line @typescript-eslint/no-var-requires
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
watchFolders: [path.resolve(__dirname, "../../")],
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config); |
Also, it is not an Expo project. |
The same issue was encountered when using dynamic import in version rn-0.74/73 of Monorepo, but it is normal in non Monorepo. |
we are also experiencing this issue in an Expo project in an Nx repo. Though we only see the issue in 'dev' mode, i.e. running |
Do you want to request a feature or report a bug?
A bug
What is the current behavior?
Dynamic import fails to resolve:
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.react-native-url-polyfill
in the react native workspacewatchFolders
to include../../
:watchFolders: [path.resolve(__dirname, "../../")],
react-native-url-polyfill
exists at../../node_modules/react-native-url-polyfill
import("react-native-url-polyfill/auto")
I'm sorry, I do not have time to create a reproducible example repo right now.
What is the expected behavior?
Dynamic import should resolve successfully.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
The text was updated successfully, but these errors were encountered: