Never Propel Marmalade

    @bahmutov/cypress-esbuild-preprocessor

    2.1.3 • Public • Published

    @bahmutov/cypress-esbuild-preprocessor

    cypress version esbuild version ci status

    Bundle Cypress specs using esbuild

    Install

    npm i -D cypress @bahmutov/cypress-esbuild-preprocessor esbuild
    # note: this plugin assumes the esbuild is peer dependency

    Use

    In your plugin file use this module as the preprocessor

    // cypress/plugins/index.js
    const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
    module.exports = (on, config) => {
      on('file:preprocessor', createBundler())
    }

    ESBuild options

    If you want to pass your own ESBuild options

    // cypress/plugins/index.js
    const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
    module.exports = (on, config) => {
      const bundler = createBundler({
        // any ESBuild options here
        // https://esbuild.github.io/api/
      })
      on('file:preprocessor', bundler)
    }

    Debugging

    Run with the environment variable DEBUG=cypress-esbuild-preprocessor

    But also if something is not working, check out the alternative package: cypress-esbuild-preprocessor

    Breaking changes

    v1 to v2

    • instead of the file preprocessor, exposes a constructor function to allow user options to ESBuild
    // v1
    const bundler = require('cypress-esbuild-preprocessor')
    module.exports = (on, config) => {
      on('file:preprocessor', bundler)
    }
    
    // v2
    const createBundler = require('cypress-esbuild-preprocessor')
    module.exports = (on, config) => {
      // pass ESBuild options to be applied to each spec file
      const bundler = createBundler({
        define: {
          "process.env.NODE_ENV": '"development"'
        }
      })
      on('file:preprocessor', bundler)
    }

    Install

    npm i @bahmutov/cypress-esbuild-preprocessor

    DownloadsWeekly Downloads

    16,538

    Version

    2.1.3

    License

    MIT

    Unpacked Size

    5 kB

    Total Files

    3

    Last publish

    Collaborators

    • bahmutov