{"id":12884,"library":"bf6-portal-bundler","title":"Battlefield 6 Portal Mod Bundler","description":"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.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/deluca-mike/bf6-portal-bundler","tags":["javascript","battlefield","battlefield-6","bf6","portal","typescript","bundler"],"install":[{"cmd":"npm install bf6-portal-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add bf6-portal-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add bf6-portal-bundler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required runtime environment for executing the bundler.","package":"node","optional":false}],"imports":[{"note":"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.","symbol":"bf6-portal-bundler (CLI command)","correct":"npm install -D bf6-portal-bundler"}],"quickstart":{"code":"{\n  \"name\": \"my-bf6-mod\",\n  \"version\": \"1.0.0\",\n  \"description\": \"My awesome Battlefield 6 Portal mod.\",\n  \"main\": \"./dist/bundle.ts\",\n  \"scripts\": {\n    \"build\": \"bf6-portal-bundler --entrypoint ./src/index.ts --outDir ./dist --minify\"\n  },\n  \"devDependencies\": {\n    \"bf6-portal-bundler\": \"^1.3.0\",\n    \"typescript\": \"^5.0.0\"\n  }\n}\n\n// src/index.ts\nimport { SomeHelper } from './utils/helper';\nimport strings from './strings.json';\n\nconst main = mod => {\n  console.log(strings.greeting, SomeHelper.getName());\n  mod.onPlayerSpawned(player => {\n    player.message(strings.welcome.replace('{player}', player.name));\n  });\n};\n\n// src/utils/helper.ts\nexport class SomeHelper {\n  static getName(): string {\n    return \"BF6 Mod\";\n  }\n}\n\n// src/strings.json\n{\n  \"greeting\": \"Hello from my BF6 Portal mod!\",\n  \"welcome\": \"Welcome, {player}!\"\n}","lang":"typescript","description":"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."},"warnings":[{"fix":"Design your mod's structure with these Portal runtime limitations in mind, leveraging the bundler for build-time resolution.","message":"Battlefield 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update your Node.js installation to version 23.0.0 or newer. Use a version manager like nvm or fnm for easy switching.","message":"The 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.","severity":"breaking","affected_versions":"<1.3.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The `--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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"While 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"The installed Node.js version on your system is older than the minimum required by the `bf6-portal-bundler`.","error":"Error: Node.js version too old. Expected >=23.0.0"},{"fix":"Verify the `--entrypoint` path is correct and ensure the specified file exists. Use an absolute path or check your current working directory.","cause":"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.","error":"Error: Entrypoint file not found: ./src/index.ts"},{"fix":"Ensure 'some-npm-package' is listed in your `package.json` dependencies (or devDependencies) and run `npm install` to install it.","cause":"The bundler could not locate 'some-npm-package' in your project's `node_modules` directory during its dependency resolution phase.","error":"Error: Could not resolve import for module 'some-npm-package' in file '/path/to/my-mod/src/my-file.ts'"},{"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.","cause":"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.","error":"SyntaxError: Unexpected token 'import' (or 'export') in bundle.ts when uploaded to Portal"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"bf6-portal-bundler"}