npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cypress/browserify-preprocessor

v3.0.2

Published

Cypress preprocessor for bundling JavaScript via browserify

Downloads

1,779,031

Readme

Cypress Browserify Preprocessor CircleCI

Cypress preprocessor for bundling JavaScript via browserify.

Modifying the default options allows you to add support for things like:

  • TypeScript
  • Babel Plugins
  • ES Presets

Installation

Requires Node version 6.5.0 or above.

npm install --save-dev @cypress/browserify-preprocessor

Usage

In your project's plugins file:

const browserify = require('@cypress/browserify-preprocessor')

module.exports = (on) => {
  on('file:preprocessor', browserify())
}

Options

Pass in options as the second argument to browserify:

module.exports = (on) => {
  const options = {
    // options here
  }

  on('file:preprocessor', browserify(options))
}

browserifyOptions

Object of options passed to browserify.

// example
browserify({
  browserifyOptions: {
    extensions: ['.js', '.ts'],
    plugin: [
      ['tsify']
    ]
  }
})

If you pass one of the top-level options in (extensions, transform, etc), it will override the default. In the above example, browserify will process .js and .ts files, but not .jsx or .coffee. If you wish to add to or modify existing options, read about modifying the default options.

watchify is automatically configured as a plugin (as needed), so it's not necessary to manually specify it.

Source maps are always enabled unless explicitly disabled by specifying debug: false.

Default:

{
  extensions: ['.js', '.jsx', '.coffee'],
  transform: [
    [
      'coffeeify',
      {}
    ],
    [
      'babelify',
      {
        ast: false,
        babelrc: false,
        plugins: [
          '@babel/plugin-transform-modules-commonjs', 
          '@babel/plugin-proposal-class-properties',
          '@babel/plugin-proposal-object-rest-spread',
          '@babel/plugin-transform-runtime',
          ],
        presets: [
          '@babel/preset-env',
          '@babel/preset-react',
        ]
      },
    ]
  ],
  debug: true,
  plugin: [],
  cache: {},
  packageCache: {}
}

Note: cache and packageCache are always set to {} and cannot be overridden. Otherwise, file watching would not function correctly.

watchifyOptions

Object of options passed to watchify

// example
browserify({
  watchifyOptions: {
    delay: 500
  }
})

Default:

{
  ignoreWatch: [
    '**/.git/**',
    '**/.nyc_output/**',
    '**/.sass-cache/**',
    '**/bower_components/**',
    '**/coverage/**',
    '**/node_modules/**'
  ],
}

onBundle

A function that is called with the browserify instance. This allows you to specify external files and plugins. See the browserify docs for methods available.

// example
browserify({
  onBundle (bundle) {
    bundle.external('react')
    bundle.plugin('some-plugin')
    bundle.ignore('pg-native')
  }
})

typescript

When the path to the TypeScript package is given, Cypress will automatically transpile .ts spec, plugin, support files. Note that this DOES NOT check types.

browserify({
  typescript: require.resolve('typescript')
})

Default: undefined

Modifying default options

The default options are provided as browserify.defaultOptions so they can be more easily modified.

If, for example, you want to update the options for the babelify transform to turn on babelrc loading, you could do the following:

const browserify = require('@cypress/browserify-preprocessor')

module.exports = (on) => {
  const options = browserify.defaultOptions
  options.browserifyOptions.transform[1][1].babelrc = true

  on('file:preprocessor', browserify(options))
}

Debugging

Execute code with DEBUG=cypress:browserify environment variable.

Contributing

Run all tests once:

npm test

Run tests in watch mode:

npm run test-watch

License

This project is licensed under the terms of the MIT license.