Socket
Socket
Sign inDemoInstall

bundler.macro

Package Overview
Dependencies
186
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bundler.macro

Bundle local JavaScript and TypeScript files with parcel.js.


Version published
Weekly downloads
38
decreased by-17.39%
Maintainers
1
Install size
26.1 MB
Created
Weekly downloads
 

Readme

Source

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');

Keywords

FAQs

Last updated on 13 Feb 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc