bf6-portal-bundler is a specialized utility designed for developers creating mods for Battlefield 6 Portal. It addresses the restrictive nature of the Portal runtime environment, which mandates that mods be uploaded as a single TypeScript file and a single strings JSON file, lacking support for external npm dependencies, multiple file imports, or module resolution at runtime. The bundler, currently at version 1.3.0, processes your mod's source code by traversing the dependency graph, resolving both local and `node_modules` imports, flattening all TypeScript files into one, merging multiple `strings.json` files, and removing all import statements. This ensures the output is compatible with the Portal runtime. It's primarily a CLI tool, focusing on build-time transformation rather than runtime logic. While no official release cadence is specified, updates typically align with community needs or underlying game changes.
npm install bf6-portal-bundlerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates installing `bf6-portal-bundler` as a dev dependency and configuring an npm script to build a basic Battlefield 6 Portal mod. It includes an example `package.json` entry, a main TypeScript entry file (`src/index.ts`) that imports a helper and a strings file, and the referenced helper and strings. The build command will output `bundle.ts` and `bundle.strings.json` to the `./dist` directory, minified.
Design your mod's structure with these Portal runtime limitations in mind, leveraging the bundler for build-time resolution.
Update your Node.js installation to version 23.0.0 or newer. Use a version manager like nvm or fnm for easy switching.
Continue to use `mod` as a global or externally provided object within your Portal mod TypeScript code without attempting to import it as a standard module.
Do not expect advanced optimizations from the `--minify` flag. For more aggressive minification, consider piping the output through a separate minification step if that is compatible with the Portal environment.
Thoroughly test bundled third-party libraries within the Portal environment. Prefer libraries with minimal external dependencies or those explicitly designed for highly constrained JavaScript runtimes.
Upgrade Node.js to version 23.0.0 or higher. You can use a version manager like `nvm` (`nvm install 23 && nvm use 23`) or `fnm` for easy management.
Verify the `--entrypoint` path is correct and ensure the specified file exists. Use an absolute path or check your current working directory.
Ensure 'some-npm-package' is listed in your `package.json` dependencies (or devDependencies) and run `npm install` to install it.
Verify that the bundler ran successfully without errors. Ensure all `import` and `export` statements are correctly processed by the bundler. If the issue persists, report it as a bug with the bundler, providing your configuration and source files.