Install Rollup 2026 dependencies
Setting up the foundation for an enterprise bundle requires pinning the correct versions of Rollup and its plugins. Enterprise projects demand stability, so relying on the latest bleeding-edge releases can introduce breaking changes. Instead, we target the stable 4.x line of Rollup, which offers the performance improvements and tree-shaking capabilities needed for large-scale applications.
Create the rollup.config.js file
You need a central configuration file to tell Rollup how to bundle your enterprise application. This file acts as the entry point for your build process, defining where your code starts and where the final output should go. Without it, Rollup doesn't know how to package your modules.
Start by creating a file named rollup.config.js in your project root. This file must export a configuration object or an array of objects. Each object represents a distinct build step, allowing you to handle different entry points or output formats for the same codebase.
Define your entry point
The input property tells Rollup where your application begins. For most enterprise projects, this is the main entry file of your library or application, typically located in a src directory.
export default {
input: 'src/index.js',
// ... other options
};
If your project has multiple entry points, such as a library and a separate demo app, you can pass an object to input instead of a single string. This allows Rollup to build multiple bundles from a single configuration run.
Set the output destination
The output property determines where Rollup writes the bundled files. You must specify at least one output object. The most common property here is file, which sets the path and filename for the generated bundle.
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'esm',
},
};
You can also specify the format property to control the module system. Common values include 'esm' for modern browsers, 'cjs' for Node.js, and 'iife' for script tags. For enterprise bundles, you often need to support multiple formats, which is why output can also be an array of objects.
Handle multiple outputs
Enterprise applications often require different outputs for different environments. You might need an ES module for bundlers like Webpack or Vite, and a CommonJS bundle for legacy Node.js scripts. You can define both in the same config file.
export default {
input: 'src/index.js',
output: [
{ file: 'dist/esm.js', format: 'esm' },
{ file: 'dist/cjs.js', format: 'cjs' },
],
};
This approach keeps your build configuration centralized while ensuring compatibility across your entire stack. Each output object can have its own plugins and options, giving you fine-grained control over each bundle.
Add plugins for TypeScript and JSON
Enterprise applications rarely consist of plain JavaScript files. Modern stacks require TypeScript for type safety and JSON for configuration data. Rollup handles these formats through plugins, which act as pre-processors that transform source code before bundling.
Think of plugins as specialized workbenches on an assembly line. Without them, Rollup sees raw TypeScript syntax or JSON files as opaque blobs it cannot parse. The plugins teach Rollup how to read, transform, and include these files in the final bundle.
Install the required packages
Before configuring Rollup, you need the specific packages that provide the parsing logic. The official community maintains these tools, ensuring they stay compatible with the latest Rollup versions.
Run the following command in your project root to install the necessary dependencies:
npm install -D @rollup/plugin-typescript @rollup/plugin-json typescript
This command adds three packages to your devDependencies. @rollup/plugin-typescript handles the compilation from TypeScript to JavaScript. @rollup/plugin-json allows Rollup to import JSON files as module objects. typescript is required because the TypeScript plugin needs the compiler itself to perform the transpilation.
Configure the Rollup config
Open your rollup.config.js file and import the new plugins at the top of the file. You will then add them to the plugins array in your configuration object. The order matters: plugins execute from left to right.
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
export default {
input: 'src/main.ts',
output: {
file: 'dist/bundle.js',
format: 'es'
},
plugins: [
json(),
typescript({ tsconfig: './tsconfig.json' })
]
};
The json() plugin is placed first. This ensures that any JSON imports are resolved into JavaScript objects before the TypeScript compiler attempts to process the module graph. The typescript plugin follows, taking the resulting JavaScript and compiling it according to your tsconfig.json settings.
Verify the setup
Create a simple TypeScript file in your src directory to test the integration. Import a JSON configuration file and use a TypeScript interface to ensure type checking is active.
// src/main.ts
import config from './config.json';
interface AppConfig {
apiUrl: string;
debug: boolean;
}
const appConfig: AppConfig = config;
console.log(`Running on ${appConfig.apiUrl}`);
Run npm run build. If the configuration is correct, Rollup will output a single bundle.js file in the dist directory. Check the output to ensure no TypeScript syntax remains and that the JSON data is inlined correctly.
As an Amazon Associate, we may earn from qualifying purchases.
Optimize bundle size with tree shaking
Tree shaking is Rollup’s way of throwing away code you don’t use. It scans your dependencies and removes exports that never get imported. This process shrinks your final bundle significantly, which speeds up load times for your enterprise application.
To make this work, you must follow the ES module standard. Tree shaking only removes code if the module system is static. CommonJS (require) and dynamic imports break this chain. Rollup needs to see the import graph at build time to decide what to keep.
This configuration ensures your enterprise bundle contains only the code your users actually execute. Keep your dependencies clean and your imports specific to maintain this efficiency.
Run the build and verify output
With your enterprise bundle configured, it is time to execute the rollup. Run the build command in your terminal. Watch for compilation errors or warnings. If the process fails, the error log will point to the specific line or dependency causing the issue.
Once the build completes successfully, inspect the generated output directory. Check the bundle size to ensure it meets your performance targets. Large bundles can slow down application load times, so use tools like gzip or brotli to estimate real-world transfer sizes.
Common Rollup 2026 configuration errors
Even with a solid plan, small missteps can break the bundle or void eligibility. Here are the three most frequent configuration errors and how to fix them before you start.
1. Wrong plugin order or configuration
The build process relies on specific plugin execution orders. Using generic or outdated plugin versions often prevents the code from parsing correctly. Check that your plugins are compatible with Rollup 4.x and that your tsconfig.json settings align with the TypeScript plugin options. If the build fails to resolve modules, the plugin order is usually the culprit.
2. Missing side effects declaration
The 2026 campaign runs from February 23 to March 22. Configurations that extend beyond these dates or start early will not sync with the prize database. Double-check the start and end dates in your app settings or on the cup packaging. Participating restaurants must have the correct inventory of eligible cups.
3. Incorrect output format selection
Bundles often include multiple prize tiers (e.g., free coffee, merchandise, or cash). Selecting the wrong tier in the configuration can lead to redemption failures at the register. Verify the prize pool details in the official help center before finalizing your bundle. If you are unsure, stick to the standard free coffee tier for the smoothest experience.
Frequently asked questions about Rollup 2026
When does the Roll Up To Win 2026 campaign run? The contest runs from February 23 to March 22, 2026. You can play at participating Tim Hortons restaurants or through the Tims app during this window.
How many prizes are available this year? Tim Hortons is celebrating 40 years of the campaign with over one million prizes. The distribution includes everything from free beverages to major vehicle giveaways.
Can I play Roll Up To Win digitally? Yes. You can scan your cup code directly in the Tims app. This method ensures you never miss a chance to win even if you don't have physical access to a printed cup.




No comments yet. Be the first to share your thoughts!