bundler.macro
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

bundler.macro

Bundle local JavaScript and TypeScript files with parcel.js.

Version Weekly Downloads Typed Codebase MIT License


Installation

bundler.macro is designed to be used with babel-plugin-macros to bundle or transpile files during your build step.

First, install the plugin and it's peer dependency (babel-plugin-macros). Since the macro is compiled away during the build, it should be installed as a devDependency to prevent bloating the dependency tree of the consumers of your package.

# yarn
yarn add bundler.macro babel-plugin-macros

# pnpm
pnpm add bundler.macro babel-plugin-macros

# npm
npm install bundler.macro babel-plugin-macros

Once installed make sure to add the 'babel-plugin-macros' to your babel.config.js (or .babelrc) file.

.babelrc

{
  "plugins": [
+   "macros",
    "other",
    "plugins"
  ]
}

babel.config.js

module.exports = {
  // rest of config...,
  plugins: [
+   'macros',
    ...otherPlugins,
  ]
}

Usage


Code Example

Bundle files using esbuild.

import { esbuildBundler } from 'bundler.macro';

// The file is bundled with `esbuild` and the output is provided as a string.
const bundledOutput: string = esbuildBundler('./main.ts');

Bundle files using rollup.

import { rollupBundler } from 'bundler.macro';

// The file is bundled with `rollup` and the output is provided as a string.
const bundledOutput: string = rollupBundler('./main.ts');

Transpile a file using babel

This should be used when you want to get the string output from a file, in a format that can be

import { transpileFile } from 'bundler.macro';

// The file is transpiled as a single file with babel.
const output: string = transpileFile('./simple.js');

Readme

Keywords

Package Sidebar

Install

npm i bundler.macro

Weekly Downloads

36

Version

0.3.0

License

MIT

Unpacked Size

31.9 kB

Total Files

17

Last publish

Collaborators

  • ifiokjr