New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

parcel-plugin-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-plugin-wrapper

Parcel plugin that wraps output files with custom text or code.

latest
Source
npmnpm
Version
0.2.3
Version published
Weekly downloads
75
120.59%
Maintainers
1
Weekly downloads
 
Created
Source

parcel-plugin-wrapper

Build Status codecov

Q:What is this thing solving?

Tiny Parcel plugin that wraps output files with custom text or code.

This plugins imitates pretty much what wrapper-webpack-plugin does.

Install

yarn add parcel-plugin-wrapper --dev

Usage

Create a .assetWrapper.js file in the root folder of your project.

Example 1, add some data coming from package.json:

const path = require('path')

const CWD = process.cwd()
const PACKAGE = require(path.join(CWD, 'package.json'))

const yourAssetProcess = async ({name, bundler}) => {
  // name = app.ere76r5e76r5e76r.js
  if (name.split('.').pop() === 'js' && bundler.options.production) {
    return {
      header: `/* ${PACKAGE.name} - ${PACKAGE.version} */`,
      footer: `// The End.`
    }
  }
}

module.exports = yourAssetProcess

Will output:

/* your-project - 3.4.56 */
parcelRequire=function(e,r,n,t){var i="function"==typeof parcelRequire.etc.etc.etc...
[...bla]
[...bla]
[...bla]
// The End

Example 2, Wraps bundle files with '.js' extension in a self invoking function and enables strict mode:

const path = require('path')

const yourAssetProcess = ({name, bundler}) => {
  if (name.split('.').pop() === 'js' && bundler.options.production) {
    return {
      header: '(function () { "use strict";\n',
      footer: '\n})();'
    }
  }
}

module.exports = yourAssetProcess

Maintainers

@albinotonnina

Contribute

PRs accepted.

License

MIT © 2018 Albino Tonnina

Keywords

parcel

FAQs

Package last updated on 02 Sep 2020

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