Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including grunt-extract-required with all npm packages installed. Try it out:

grunt-extract-required lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("grunt-extract-required/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grunt-extract-required v0.1.1

Grunt task to extract required modules in src files

grunt-extract-required

Build Status

A grunt task to extract commonly required modules in src files, and genenrate a JS code to use as a loader.

Using extract-required inside.

Usage

A example grunt task in Gruntfile.js :


  ...

  extract_required: {
    lib: {
      files: {
        'output/core-require.js' : [ 'lib/core/**/*.js' ]
      },
      options: {
        baseDir: 'lib/',
        ignore: [ './submodule/**/*' ],
        exposeToGlobal: true
      }
    }
  },

  ...

Options

options.baseDir

Specify a base directory to canonicalize relatively loaded module paths.

options.ignore

Specify a glob pattern or name of modules to ignore from the output.

options.exposeToGlobal

If you want to expose the generated loader function to global, set true (or custom global function name; by default it use require). Otherwise the function will be opened as a CommonJS-style module.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free