Repository navigation
Experiment: Improving webpack Configuration with openDevin and Sonnet 3.5 200k
In this article, I document my journey to improve the webpack configuration of a React project. My goal was to enhance performance and maintainability, despite my lack of knowledge in JavaScript, TypeScript, React, and webpack. I leveraged openDevin and the Sonnet 3.5 200k language model to achieve this.
The project in question is the Digital Assistant Client. The original webpack configuration was functional but could benefit from best practices to improve modularity, performance, and maintainability.
While Sourcegraph Cody was an option, I decided to experiment with openDevin and the Sonnet 3.5 200k language model to assist in this task. To provide context, here are some details about my capabilities:
- I do not know JavaScript, TypeScript, React, or webpack.
- I am only familiar with the command
npm run startwhich Yuresh taught me. - I did not know what to ask in the initial prompt and used Cody(sonnet 3.5) to get suggestions for improving webpack.
To set up the experiment, I used the following tools and resources:
- The GitHub repository: Digital Assistant Client
- The original webpack configuration file: webpack.config.js
- openDevin for interaction with the Sonnet 3.5 200k language model
- Cody for initial suggestions
- To do a fair evaluation of openDevin, I accepted all its suggestions without modifications. i.e. I did not try to prompt it midway through the execution process.
Here is a step-by-step explanation of the experiment:
- Initial Prompt: I used Cody to get suggestions on how to improve the webpack configuration.
- Interaction with openDevin: Here is my prompt to openDevin: "Please analyse and refactor webpack.config.js and make it world class by implementing all best practices. Improve modularity and maintainability, performance, improvements like code-splitting, caching, tree-shaking, parallel processing, bundle analyser and similar improvements. You can even convert to typescript if it helps. Also remove redundant code and comments."
- Manual Confirmations: To understand the process better, I asked openDevin to seek my approval before every step. Despite the time spent copying the entire conversation to a text file, the refactor was completed in about 20 minutes. Without manual confirmations, it would have likely completed in 5 minutes.
- Challenges: During the process, openDevin went into a loop trying to eliminate duplicate content. I had to manually intervene to stop the loop and salvage the situation.
The Sonnet model suggested and implemented several improvements to the webpack configuration, including:
- Modularity: Breaking down the configuration into modular parts for better maintainability.
- Performance Enhancements: Implementing code-splitting, caching, and tree-shaking.
- Parallel Processing: Leveraging parallel processing to speed up the build process.
- Bundle Analysis: Integrating a bundle analyzer to visualize and optimize the bundle size.
Below are some key changes made to the webpack configuration:
- Original Configuration: The initial configuration was a single file with basic settings.
-
Improved Configuration: The improved configuration uses TypeScript, modularizes the settings, and includes plugins like
TerserPlugin,CssMinimizerPlugin, andBundleAnalyzerPlugin.
Todo:
- Upload the final file.
- Give a better summary of the improvements/changes
The resource usage statistics for the experiment are as follows:

- Total Tokens In: 270,235
- Total Tokens Out: 10,002
- Total Cost: $0.96
As you can see, the cost is trivial.
The refactored webpack configuration resulted in significant improvements in performance and maintainability. The key benefits observed include:
- Reduced bundle size due to tree-shaking and code-splitting.
- Faster build times with parallel processing.
- Better modularity and readability of the configuration file.
Despite my initial lack of knowledge, the use of AI tools like openDevin and Sonnet allowed for an efficient and effective refactor. The manual confirmations added time but provided valuable learning insights.
- I did similar exercises with Coding Assistants like SourceGraph Cody. I expected openDevin to test its output by trying to run the build. I would have expected it to try to build after every logical step or at least at the end. It did not try to build even once. Was it because I aborted it in between ?
- The other major issue I noticed is that it did not split the file into multiple files: 'common', 'dev' and 'prod' configurations. While it created different sections for these in the same file, I would have expected openDevin to create new files to separate out the logic. To be fair, I could have prompted for this midway but I wanted to see what it will produce without any intervention from me.
(Spoiler: openDevin did execute the above steps in subsequent experiments but with different prompting.)
Overall, for this particular scenario, I think that openDevin was only marginally better than a Coding Assistant. I will try to fix these issues with better prompting in the next iteration of this experiment.
This experiment demonstrates the power of leveraging AI tools to improve complex codebases, even with limited prior knowledge. The key findings and benefits include:
- openDevin (and Agentic approaches) too benefit from better prompting.
- It may take a few iterations to improve prompting.
- Recommendations for similar projects: leverage AI tools to implement performance best practices. A little bit of prior research and just asking for desired improvements in the prompts will ensure world-class outcomes.
Note: I realised that I could improve my prompting and also decided to have a plain javascript configs instead of typescript. I discarded the output and ran more experiments.
- Here is one experiment with a simplistic prompt: https://github.com/Digital-Assistant/Digital_Assistant_Client/wiki/Webpack-Configuration-Refactoring:-Testing-with-a-simple,-unsophisticated-prompt
- Will publish more as and when I find time.
- Full Conversation: The complete interaction with openDevin and the Sonnet model is available in the attached text file. openDevin-Sonnet-webpack-rewrite.txt
-
Relevant Links:
- GitHub Repository
- Original Webpack Configuration
- Here is the final output : openDevin_Sonnet3.5_webpack.config.zip