Packager Docs
v0.1.9 | Pre-Alpha
Getting StartedConfigurationPackager OptionsBundle OptionsAPI Reference
Plugins
RoadmapREPL

Configuration

There are a few options that you can configure in Packager. However, it's important to know that there are 2 types of options - Packager Options and Bundle Options.

Packager Options are options which you set on an instance of Packager and these cannot be overwritten.

Bundle Options are options which you set when you are bundling your files and these indeed can be overwritten with subsequent builds.

Packager Options

type PackagerOptions = {
cache: boolean;
sourcemaps: boolean;
};

Package Options need to be registered on an instance of Packager like this:

const packagerOptions = {};
const packager = new Packager(packagerOptions);

cache

Turning off cache doesn't give you any benefits so it's safe to leave it as true and in return, it will give you faster builds.

  • Type
    boolean
  • Default
    true

sourcemaps

Sourcemaps allow you to show the code in the browser as it was when entering bundling process. It maintains the original look of the file by inlining a sourcemap per file.

  • Type
    boolean
  • Default
    false
Sourcemaps are inlined so when you enable this option, it will greatly increase the size of your bundle.

Bundle Options

type File = {
name: string;
path: string;
code: string;
entry?: boolean;
};
type BundleOptions = {
dependencies: { [moduleId: string]: string };
};

Bundle Options need to be registered when bundling files like this:

const files: File[] = [
{
name: "app.js",
path: "/src/app.js",
code: `console.log('hello world!');`,
entry: true
}
];
const bundleOptions: BundleOptions = {};
const packager = new Packager();
packager.bundle(files, bundleOptions);

dependencies

By default, when Packager recognises an imported NPM module, it will fetch the latest version of that module.
If you want to have control over this, dependencies is a Object with module name as keys and version as values.

  • Type
    { [moduleId: string]: string }
  • Default
    {}
  • Usage
const packager = new Packager();
const files = [];
const bundleOptions = {
dependencies: {
vue: "2.6.10",
react: "16.11.0"
}
};
packager.bundle(files, bundleOptions);