[Question]: is it possible to run a task during the build time?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Do you want to request a feature or report a bug?
It's a question, I need a help :)
What is the current behavior?
I want to call a node function during the build time. What it does - parsing a json and stores the result into the application cache folder. The result of this function may be used then during the run time. This function also has a check inside it to determine whether it should perform parsing to avoid cyclic reloading of the application (storing/modifying a new file causes it).
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
What is the expected behavior?
My question is: am I right about using reporter to achieve this?
It works for me, but only on the first launch. Then I guess Metro uses a dependency graph to resolve whether a particular file was changed and should be included into re-compiled bundle. So the old file is used and I need to completely restart a bundler.
How can I handle it?
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
const MetroConfig = require('metro-config/src/defaults');
const defaultMetroConfig = MetroConfig.getDefaultValues();
module.exports = {
reporter: {
update: (event) => {
defaultMetroConfig.reporter.update(event);
if (event.type === 'bundle_build_started') {
myParseJsonFn();
}
},
},
};
Yarn 1.19.2
Metro from the master branch (I use it experimentally)
MacOS Catalina
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Metro configuration's reporter.update callback and the bundle_build_started event shown here. Investigate how Metro's dependency graph handles the generated cache file on later builds and whether a supported build-time hook exists. Done should mean a documented way to run the task repeatedly without requiring a full bundler restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100