Platform

Target runtime platforms

Platform

Packem does not have a literal platform option. Instead, the runtime platform a build targets is controlled by three real options on BuildOptions:

  • runtime?: Runtime — the runtime environment (Node, browser, edge, etc.)
  • environment?: Environment"production" or "development"
  • browserTargets?: string[] — browserslist queries used when transpiling for browsers

The option names on this page — runtime, environment, and browserTargets — are the real fields. There is no platform key.

runtime

runtime selects the target runtime. The accepted values of the Runtime type are:

type Runtime =
  | "browser"
  | "bun"
  | "deno"
  | "edge-light"
  | "electron"
  | "node"
  | "react-native"
  | "react-server"
  | "workerd"
  | undefined;
import { defineConfig } from '@visulima/packem/config'

export default defineConfig({
  runtime: 'node',
})

CLI flag

A --runtime flag exists on packem build, but it is narrower than the config option — it accepts only node or browser:

packem build --runtime node
packem build --runtime browser

Any other value is rejected. To target edge-light, workerd, deno, and the other runtimes, set runtime in your config file.

environment

environment selects the build environment. The Environment type is:

type Environment = "production" | "development" | undefined;

The environment also influences other defaults — for example, minification defaults to true in production and false otherwise. On the CLI, --production and --development (which conflict with each other) set the environment:

packem build --production
packem build --development

browserTargets

browserTargets is an array of browserslist queries used to drive transpilation for browser builds. It defaults to the resolved result of browserslist() (i.e. your .browserslistrc or package.json#browserslist).

export default defineConfig({
  runtime: 'browser',
  browserTargets: ['chrome 58', 'firefox 57'],
})

When the global runtime is "node", browserTargets is cleared, but the resolved value is preserved internally (resolvedBrowserTargets) so that individual browser-runtime entries in an otherwise Node package keep their intended targets.


  • Target - JavaScript language/feature targets
  • Transformers - The engine that performs transpilation
  • Bundler - Choose the bundler backend
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues