-
Notifications
You must be signed in to change notification settings - Fork 674
Closed as not planned
Closed as not planned
Copy link
Description
I'm changing the way how the Babel plugin works in react-native-reanimated/react-native-worklets. These changes include creating a new file, that's immediately required in the newly transformed code.
To exemplify, let's say I have a file:
// file.js
function foo() {
function bar(){};
bar();
};I'm transpiling it to:
// file.js
function foo() {
const bar = require("react-native-worklets/generated/1111111.js").default;
bar();
}Creating respective file before manipulating the original AST:
// "react-native-worklets/generated/1111111.js"
export default function bar(){};Such flow causes Metro to fail to resolve "react-native-worklets/generated/1111111.js" because the watcher triggers too late. From my debugging the flow is as follows:
file.jsis picked up by Metro for Babel transpilation.- "react-native-worklets/generated/1111111.js" is created.
- AST is manipulated by Worklets Babel plugin.
- new AST is traversed by Babel,
require("react-native-worklets/generated/1111111.js")is discovered. - Metro attempts to resolve this file using this method. It wasn't present in its filesystem snapshot, so it fails to resolve it.
- Metro filesystem watcher kicks in here and adds an entry for "react-native-worklets/generated/1111111.js" using this method.
I understand this might be problematic to fix quickly since the issue spans towards the Watchman itself. I wonder if there's some elegant way to trigger the discovery event earlier so the resolution would succeed.
Metadata
Metadata
Assignees
Labels
No labels