Notoriously Pedantic Magistrate

    snowpack-plugin-selective-import-to-require

    0.3.0 • Public • Published

    snowpack-plugin-selective-import-to-require

    Selectively convert import calls into require calls. Useful for running snowpack with Electron.

    npm install --save-dev snowpack-plugin-selective-import-to-require
    
    // snowpack.config.json
    module.exports = {
      "plugins": [
        [
          "snowpack-plugin-selective-import-to-require",
          {
            "modules": ["os", "child_process"],
            "types": ['.js'],
          }
        ]
      ]
    }

    Plugin Options

    Name Type Description
    modules string[] An array of module names to match against, such as ['os', 'child_process'].
    types string[] (optional) By default, this plugin matches against ['.js']. Provide an array if you need to match other extensions.

    Match Built-in Node Modules

    It may be convenient to match all built-in node modules.

    npm install builtin-modules --save-dev
    
    // snowpack.config.json
    const builtinModules = require('builtin-modules')
    
    module.exports = {
      "plugins": [
        [
          "snowpack-plugin-selective-import-to-require",
          {
            "modules": builtinModules,
            "types": ['.js'],
          }
        ]
      ],
      "packageOptions": {
        "external": builtinModules
      },
    }

    Install

    npm i snowpack-plugin-selective-import-to-require

    DownloadsWeekly Downloads

    8

    Version

    0.3.0

    License

    MPL-2.0

    Unpacked Size

    20.4 kB

    Total Files

    4

    Last publish

    Collaborators

    • kettek