Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as fs from 'fs';
import {Volume} from 'memfs';
import {dirname, join} from 'path';
import {Union} from 'unionfs';
import {promisify} from 'util';
import {compilation, Compiler} from 'webpack';
import {htmlModuleToJsModuleMap} from '../html-module-transform.js';
const readFile = promisify(fs.readFile);
const realpath = promisify(fs.realpath);
const ufs = new Union();
const vfs = new Volume();
ufs.use(fs).use(vfs);
const pluginName = 'HTML Modules Transform';
export interface HtmlModulesPluginOptions {
htmlModuleTest?: (options: WebpackModuleFactoryOptions) => boolean;
}
export interface WebpackModuleFactoryOptions {
contextInfo: {
// The absolute path to the source file of the importing module:
issuer: string
};
// The root directory of the compilation (I think.....)
private static buildFs(memFs: Volume, containerFs: ContainerFS): Volume {
const fs = new Union();
fs.use(memFs).use(containerFs);
return fs;
}
constructor() {
/**
* File System Setup
*/
let mfs = new MFS()
let ufs = new Union()
this.mfs = mfs
this.ufs = ufs
.use(mfs)
.use(fs)
this.cache = {}
this.mode = 'development'
this.template = (content, context, bundle) => (`
${ context.head ? context.head : '' }
${ context.renderResourceHints() }
${ context.renderStyles() }
Capsule.buildFs = function (memFs, containerFs) {
var fs = new unionfs_1.Union();
fs
.use(memFs)
.use(containerFs);
return fs;
};
Capsule.create = function (containerFactory, volume, initialState, console) {