Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webpack Runtime Compiler

Webpack runtime compiler with support for strings and Buffer objects as virtual files in memory. This allows the application to create a string on the fly—or data like dynamic generated images—and require it within a Webpack bundle. In production envionment, the files are compiled during the first call and then cached on disk or in memory. In non-production environments, the files are stored in memory.

Install

$ npm install webpack-runtime-compiler

Use

Compile a Webpack bundle with entry file data retrieved from a string

const WebpackRuntimeCompiler = require('webpack-runtime-compiler');

let webpackOptions = {
    entry: '/path/to/entry.jsx',
    output: {
        path: '/path/to/output',
        filename: 'bundle.js',
    },
    module: {
        //...
    },
};

let customFiles = {
    '/path/to/entry.jsx': 'import react from "react"; //...',
};

let compiler = new WebpackRuntimeCompiler(webpackOptions, customFiles);

compiler.run().then(stats => {
    let fs = stats.outputFileSystem; // Use this instead of require('fs')
    fs.readFile('/path/to/output/bundle.js', (error, data) => {
        console.log(data); // Returns data from compiled Webpack bundle...
    });
});

Force in memory file system in production environment

const WebpackRuntimeCompiler = require('webpack-runtime-compiler');

//...

let compiler = new WebpackRuntimeCompiler(webpackOptions, customFiles, true); // Set forceInMemoryOutput to true

License

The MIT License

About

Webpack runtime compiler with support for strings and Buffer objects as virtual files in memory

Topics

Resources

Stars

4 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages