🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@brixtol/rollup-config

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brixtol/rollup-config

Shared Rollup configuration interface used within the Brixtol Textiles monorepo.

latest
Source
npmnpm
Version
1.5.5
Version published
Maintainers
1
Created
Source

@brixtol/rollup-config

Shareable rollup configuration used within the Brixtol Textiles monorepo. The module acts as an interface, exporting an instance of Rollup and several plugins that are frequently used by packages contained across the workspace. Each plugin is wrapped as a getter which helps negate exposing unused plugins on the export.

Why

We operate atop of a cloud driven serverless architecture. This module assists in the processes relating to our cloud builds, serverless apis, open/closed sourced package and applications using Lambdas or edge handlers. It provides us a single dependency import for bundling with Rollup and single source for version controlling all plugins we leverage.

Rollup + ESBuild

Bundles are generated using ESBuild together will Rollup. TypeScript and JavaScript modules are processed with esbuild using rollup-plugin-esbuild.

Install

This module can be installed and leveraged by projects that are outside of our organization.

pnpm

pnpm add @brixtol/rollup-config -save-dev

Brixtol Monorepo

If you are working within the Brixtol Textiles monorepo then please note that this module is installed at root, so for development on private modules it does not need to be installed. If a project is public facing or consumed in build images elsewhere then you will need to explicitly install it.

Use workspace:* for version definition to ensure packages are always using the latest.

Usage

This is an ESM module, your rollup config file must use a .mjs extension (rollup.config.mjs) or else Node will complain depending on your project presets. The rollup() export is totally optional, its a re-export of defineConfig and used to provide type completions.

import { rollup, env, plugin } from "@brixtol/rollup-config";

export default rollup(
  {
    input: "src/file.ts",
    output: {
      format: 'cjs',
      dir: 'package',
      sourcemap: env.is('dev', 'inline'), // Inline sourcemap in development else false
      interop: 'default'
    },
    plugins: env.if('div')(
      [
        plugin.esbuild(options: {}),
        // etc etc
      ]
    )(
      [
        plugin.terser()
      ]
    )
  }
);

Types are re-exported and provided for all plugins which support them. Rollup configuration files within our workspace.

What is the env.if() method?

This module provides exports from @brixtol/rollup-utils. The env.if() allows us to use single file for development and production bundles. When an --environment flag is passed with a of value of prod the plugins are concatenated, so first curried parameter is combined with the second curried parameter, which should both be an array list of plugins[].

The dev is default, so running rollup -c -w results in:

env.if('dev')([ plugin.commonjs(), plugin.ts() ])([ plugin.terser() ])
// => [ commonjs(), ts() ]

If you run rollup -c --environment prod it results in:

env.if('dev')([ plugin.commonjs(), plugin.ts() ])([ plugin.terser() ])
// => [ commonjs(), ts(), terser() ]

Plugins

All plugins are available via the named plugin export. In addition to the plugins rollup's defineConfig function is exported as rollup namespace so configuration options have typings on the default export. Below is the complete list of included plugins:

ExportPlugin
plugin.alias@rollup/plugin-alias
plugin.beep@rollup/plugin-beep
plugin.bsrollup-plugin-browsersync
plugin.copyrollup-plugin-copy
plugin.commonjs@rollup/plugin-commonjs
plugin.delrollup-plugin-delete
plugin.esbuildrollup-plugin-esbuild
plugin.filesizerollup-plugin-filesize
plugin.html@brixtol/rollup-html
plugin.json@rollup/plugin-json
plugin.livereloadrollup-plugin-livereload
plugin.multi@rollup/plugin-multi-entry
plugin.polyfillsrollup-plugin-node-polyfills
plugin.resolve@rollup/plugin-node-resolve
plugin.postcssrollup-plugin-postcss
plugin.replace@rollup/plugin-replace
plugin.dtsrollup-plugin-dts
plugin.serverollup-plugin-serve
plugin.terserrollup-plugin-terser

Optional Dependencies

The module includes several optional dependencies, one being Rollup itself. Ensure that if you are using a plugin you install any optional it might require.

License

Licensed under MIT.

We ♡ open source!

Keywords

rollup

FAQs

Package last updated on 14 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts