npm.io
0.0.1-alpha.197 • Published 6 years ago

@excitare/require-fix-babel-plugin

Licence
MIT
Version
0.0.1-alpha.197
Deps
0
Size
9 kB
Vulns
0
Weekly
0

@excitare/require-fix-babel-plugin

npm (scoped)

This package contains a Babel plugin for converting require-statements inside functions into Webpack-compatible __non_webpack_require__ that is not compiled away during build-time.

This is required because Excitare builds Next.js server code with Webpack and Next.js uses dynamic require-statements to load code for serverside rendering.

Examples

The simplest example is:

function test() {
  require("some require");
}

compiles to:

function test() {
  __non_webpack_require__("some require");
}

The plugin doesn't touch require outside functions:

require("some first require");

function test() {
  require("some require");
}

compiles to:

require("some first require");

function test() {
  __non_webpack_require__("some require");
}

Keywords