How to use unionfs - 10 common examples

To help you get started, we’ve selected a few unionfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saltyshiomix / react-ssr / packages / nestjs-express / lib / optimize.ts View on Github external
getPages,
  getPageId,
  readFileWithProps,
  gracefullyShutDown,
  sleep,
  Config,
} from '@react-ssr/core';

const cwd = process.cwd();
const env = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const ext = '.' + getEngine();
const codec = require('json-url')('lzw');

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

// onchange bundling
async function bundle(config: Config, ufs: any, memfs: any): Promise;

// initial bundling
async function bundle(config: Config, ufs: any, memfs: any, app: NestExpressApplication): Promise;

async function bundle(config: Config, ufs: any, memfs: any, app?: NestExpressApplication) {
  const entry: webpack.Entry = {};
  const entryPages = await getPages();
  const entryPath = path.resolve(require.resolve('@react-ssr/core'), '../webpack/entry.js');
  const template = fse.readFileSync(entryPath).toString();

  memfs.mkdirpSync(path.join(cwd, 'react-ssr-src'));

  for (let i = 0; i < entryPages.length; i++) {
github saltyshiomix / react-ssr / packages / nestjs-express / lib / optimize.ts View on Github external
getEngine,
  getPages,
  getPageId,
  readFileWithProps,
  // gracefullyShutDown,
  sleep,
} from '@react-ssr/core';

const cwd = process.cwd();
const env = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const ext = '.' + getEngine();
const codec = require('json-url')('lzw');

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

// onchange bundling
async function bundle(config: Config, ufs: any, memfs: any): Promise;

// initial bundling
async function bundle(config: Config, ufs: any, memfs: any, app: NestExpressApplication): Promise;

async function bundle(config: Config, ufs: any, memfs: any, app?: NestExpressApplication) {
  const entry: webpack.Entry = {};
  const [entryPages, otherPages] = await getPages(config);
  const entryPath = path.resolve(require.resolve('@react-ssr/core'), '../webpack/entry.js');
  const template = fse.readFileSync(entryPath).toString();

  for (let i = 0; i < entryPages.length; i++) {
    const page = entryPages[i];
    const pageId = getPageId(page, config, '/');
github saltyshiomix / react-ssr / packages / nestjs-express / lib / optimize.ts View on Github external
configureWebpack,
  getEngine,
  getPages,
  getPageId,
  readFileWithProps,
  gracefullyShutDown,
  sleep,
  Config,
} from '@react-ssr/core';

const cwd = process.cwd();
const env = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const ext = '.' + getEngine();
const codec = require('json-url')('lzw');

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

// onchange bundling
async function bundle(config: Config, ufs: any, memfs: any): Promise;

// initial bundling
async function bundle(config: Config, ufs: any, memfs: any, app: NestExpressApplication): Promise;

async function bundle(config: Config, ufs: any, memfs: any, app?: NestExpressApplication) {
  const entry: webpack.Entry = {};
  const entryPages = await getPages();
  const entryPath = path.resolve(require.resolve('@react-ssr/core'), '../webpack/entry.js');
  const template = fse.readFileSync(entryPath).toString();

  memfs.mkdirpSync(path.join(cwd, 'react-ssr-src'));
github saltyshiomix / react-ssr / packages / nestjs-express / lib / optimize.ts View on Github external
Config,
  configure,
  getEngine,
  getPages,
  getPageId,
  readFileWithProps,
  // gracefullyShutDown,
  sleep,
} from '@react-ssr/core';

const cwd = process.cwd();
const env = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const ext = '.' + getEngine();
const codec = require('json-url')('lzw');

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

// onchange bundling
async function bundle(config: Config, ufs: any, memfs: any): Promise;

// initial bundling
async function bundle(config: Config, ufs: any, memfs: any, app: NestExpressApplication): Promise;

async function bundle(config: Config, ufs: any, memfs: any, app?: NestExpressApplication) {
  const entry: webpack.Entry = {};
  const [entryPages, otherPages] = await getPages(config);
  const entryPath = path.resolve(require.resolve('@react-ssr/core'), '../webpack/entry.js');
  const template = fse.readFileSync(entryPath).toString();

  for (let i = 0; i < entryPages.length; i++) {
github PolymerLabs / html-modules-toolkit / src / html-module-transform / webpack-plugin.ts View on Github external
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.....)
github coderaiser / cloudcmd / test / rest / mv.js View on Github external
test('cloudcmd: rest: mv', async (t) => {
    const volume = {
        '/fixture/mv.txt': 'hello',
        '/fixture/tmp/a.txt': 'a',
    };
    
    const vol = Volume.fromJSON(volume, '/');
    
    const unionFS = ufs
        .use(vol)
        .use(fs);
    
    assign(unionFS, {
        promises: fs.promises,
    });
    mockRequire('fs', unionFS);
    
    reRequire('@cloudcmd/rename-files');
    reRequire('@cloudcmd/move-files');
    reRequire(restPath);
    
    const cloudcmd = reRequire(cloudcmdPath);
    const {createConfigManager} = cloudcmd;
    
    const configManager = createConfigManager();
github saltyshiomix / react-ssr / packages / core / src / optimize / production.ts View on Github external
import express from 'express';
import webpack from 'webpack';
import { configureWebpack } from './webpack.config';
import { getEntry } from './helpers';
import {
  getSsrConfig,
  getPageId,
  sleep,
} from '../helpers';

const cwd = process.cwd();
const config = getSsrConfig();

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

export default async (app: express.Application): Promise => {
  fse.removeSync(path.join(cwd, config.distDir));

  let compiled = false;
  const [entry, entryPages] = await getEntry(memfs);
  const webpackConfig: webpack.Configuration = configureWebpack(entry);
  const compiler: webpack.Compiler = webpack(webpackConfig);
  compiler.hooks.afterCompile.tap('finish', () => { compiled = true });
  compiler.inputFileSystem = ufs;
  compiler.run((err: Error, stats: webpack.Stats) => {
    err && console.error(err.stack || err);
    stats.hasErrors() && console.error(stats.toString());

    for (let i = 0; i < entryPages.length; i++) {
      const page = entryPages[i];
github saltyshiomix / react-ssr / packages / express-engine-jsx / src / render.tsx View on Github external
let html: string = '';

  const cwd: string = process.cwd();
  const distDir: string = config.distDir as string;
  const pagePath: string = getPagePath(file, config);

  const cache: string = resolve(cwd, distDir, pagePath.replace('.jsx', '.html'));
  if (existsSync(cache)) {
    return readFileSync(cache).toString();
  }

  const name: string = basename(pagePath).replace('.jsx', '');
  const compiler: webpack.Compiler = webpack(configure(name, distDir));
  const mfs = new MemoryFileSystem;
  const { ufs } = require('unionfs');
  ufs.use(mfs).use(fs);
  mfs.mkdirpSync(resolve(cwd, 'react-ssr-src'));
  mfs.writeFileSync(resolve(cwd, 'react-ssr-src/entry.js'), template(resolve(__dirname, 'page.jsx'), { props }));
  mfs.writeFileSync(resolve(cwd, 'react-ssr-src/page.js'), template(file, props));
  compiler.inputFileSystem = ufs;
  compiler.outputFileSystem = mfs;

  try {
    compiler.run((err: any) => {
      if (err) {
        console.error(err.stack || err);
        if (err.details) {
          console.error(err.details);
        }
        return;
      }
    });
github saltyshiomix / react-ssr / packages / static / src / optimize / production.ts View on Github external
import path from 'path';
import express from 'express';
import webpack from 'webpack';
import { configureWebpack } from './webpack.config';
import { getEntry } from './helpers';
import {
  getPageId,
  staticConfig,
  sleep,
} from '../helpers';

const cwd = process.cwd();

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

export default async (app: express.Application): Promise => {
  fse.removeSync(path.join(cwd, staticConfig.distDir));

  let compiled = false;
  const [entry, entryPages] = await getEntry(memfs);
  const webpackConfig: webpack.Configuration = configureWebpack(entry);
  const compiler: webpack.Compiler = webpack(webpackConfig);
  compiler.hooks.afterCompile.tap('finish', () => { compiled = true });
  compiler.inputFileSystem = ufs;
  compiler.run((err: Error, stats: webpack.Stats) => {
    err && console.error(err.stack || err);
    stats.hasErrors() && console.error(stats.toString());

    for (let i = 0; i < entryPages.length; i++) {
      const page = entryPages[i];
github saltyshiomix / react-ssr / packages / core / src / optimize / production.ts View on Github external
import MemoryFileSystem from 'memory-fs';
import path from 'path';
import express from 'express';
import webpack from 'webpack';
import { configureWebpack } from './webpack.config';
import { getEntry } from './helpers';
import {
  getSsrConfig,
  getPageId,
  sleep,
} from '../helpers';

const cwd = process.cwd();
const config = getSsrConfig();

const ufs = require('unionfs').ufs;
const memfs = new MemoryFileSystem();
ufs.use(fs).use(memfs);

export default async (app: express.Application): Promise => {
  fse.removeSync(path.join(cwd, config.distDir));

  let compiled = false;
  const [entry, entryPages] = await getEntry(memfs);
  const webpackConfig: webpack.Configuration = configureWebpack(entry);
  const compiler: webpack.Compiler = webpack(webpackConfig);
  compiler.hooks.afterCompile.tap('finish', () => { compiled = true });
  compiler.inputFileSystem = ufs;
  compiler.run((err: Error, stats: webpack.Stats) => {
    err && console.error(err.stack || err);
    stats.hasErrors() && console.error(stats.toString());

unionfs

Use multiple `fs` modules in a union.

Unlicense
Latest version published 29 days ago

Package Health Score

83 / 100
Full package analysis

Popular unionfs functions