A quick 'n dirty module to compile one or more bundles using webpack and load those compiled bundles as node modules -- all in memory!
This module exports a single function which takes a webpack compiler
configured according to the webpack Node Node API (note: you can ignore
the section on compiling to memory, this module takes care of that for you). The
most important things to configure are the
'node') and the
'commonjs2'). The exported function returns a
resolves with an object mapping output filenames to compiled node modules.
const webpack = ;const load = ;;
All output is placed in an in-memory filesystem. Node doesn't read from
this filesystem directly, so if you create multiple bundles that depend on each
other your modules will fail to load (except in a few edge cases). If you have a
setup such as this it is probably better to just compile out to the real
filesystem ahead of time and
import the modules as normal.