Registry / devops / bf6-portal-bundler

bf6-portal-bundler

JSON →
library1.3.0jsnpmunverified

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-bundler
INSTALL
IMPORT
SIG · BF6-PORTAL-BUNDLER
B
bf6-portal-bundler
devopsjavascriptv1.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bf6-portal-bundler (CLI command)
npm install -D bf6-portal-bundler
This package is primarily a command-line interface (CLI) tool and does not expose a programmatic API for direct import into JavaScript/TypeScript code. Its functionality is accessed via the 'bf6-portal-bundler' command after installation.

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.

{ "name": "my-bf6-mod", "version": "1.0.0", "description": "My awesome Battlefield 6 Portal mod.", "main": "./dist/bundle.ts", "scripts": { "build": "bf6-portal-bundler --entrypoint ./src/index.ts --outDir ./dist --minify" }, "devDependencies": { "bf6-portal-bundler": "^1.3.0", "typescript": "^5.0.0" } } // src/index.ts import { SomeHelper } from './utils/helper'; import strings from './strings.json'; const main = mod => { console.log(strings.greeting, SomeHelper.getName()); mod.onPlayerSpawned(player => { player.message(strings.welcome.replace('{player}', player.name)); }); }; // src/utils/helper.ts export class SomeHelper { static getName(): string { return "BF6 Mod"; } } // src/strings.json { "greeting": "Hello from my BF6 Portal mod!", "welcome": "Welcome, {player}!" }
bf6-portal-bundler --version
Debug
Known issues
gotchaBattlefield 6 Portal has strict runtime limitations: only a single TypeScript file, a single JSON strings file, no external npm dependencies (beyond the 'mod' namespace), and no runtime module resolution. This bundler solves these, but developers must understand these constraints for mod design.
fix
Design your mod's structure with these Portal runtime limitations in mind, leveraging the bundler for build-time resolution.
affects: >=1.0.0
breakingThe bundler requires Node.js version 23.0.0 or higher to run. Older Node.js versions will result in an error and prevent the bundler from executing.
fix
Update your Node.js installation to version 23.0.0 or newer. Use a version manager like nvm or fnm for easy switching.
affects: <1.3.0
gotchaThe `mod` namespace, which is provided by the Portal runtime, is explicitly ignored by the bundler during import resolution. This means explicit imports of 'mod' will not be processed by the bundler but rather remain untouched, as expected for external runtime APIs.
fix
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.
affects: >=1.0.0
gotchaThe `--minify` option provides only 'rudimentary size reduction' and is not a full-fledged minifier like Terser or esbuild. It primarily focuses on basic transformations (e.g., stripping comments and whitespace) rather than advanced code optimizations.
fix
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.
affects: >=1.0.0
gotchaWhile the bundler resolves `node_modules` dependencies at build time, these dependencies are flattened into your single `bundle.ts` file. Ensure that any third-party code you include is compatible with the Portal runtime's JavaScript environment and does not rely on browser-specific APIs or Node.js built-in modules that are not polyfilled.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Node.js version too old. Expected >=23.0.0
The installed Node.js version on your system is older than the minimum required by the `bf6-portal-bundler`.
fix
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.
Error: Entrypoint file not found: ./src/index.ts
The path provided to the `--entrypoint` argument does not point to an existing file or the path is incorrect relative to where the command is executed.
fix
Verify the `--entrypoint` path is correct and ensure the specified file exists. Use an absolute path or check your current working directory.
Error: Could not resolve import for module 'some-npm-package' in file '/path/to/my-mod/src/my-file.ts'
The bundler could not locate 'some-npm-package' in your project's `node_modules` directory during its dependency resolution phase.
fix
Ensure 'some-npm-package' is listed in your `package.json` dependencies (or devDependencies) and run `npm install` to install it.
SyntaxError: Unexpected token 'import' (or 'export') in bundle.ts when uploaded to Portal
This indicates that the Portal runtime encountered an `import` or `export` statement that the bundler should have removed, meaning the bundling process was incomplete or failed to correctly flatten the code.
fix
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.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
noderequiredRequired runtime environment for executing the bundler.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources