@resin/pinejs
Version:
Pine.js is a sophisticated rules-driven API engine that enables you to define rules in a structured subset of English. Those rules are used in order for Pine.js to generate a database schema and the associated [OData](http://www.odata.org/) API. This make
23 lines (20 loc) • 1.08 kB
text/typescript
import type * as Fs from 'fs';
if (!process.browser) {
if (typeof nodeRequire === 'undefined' || nodeRequire == null) {
// `nodeRequire` is a special variable we use to bypass webpack's resolving of `require`
// statements on build for the cases where we need to always use the nodejs require, eg
// in the config-loader which dynamically loads code at runtime, and for adding custom
// filetype handlers - it works by being replaced with `require` after the webpack build
// finishes.
// In the case of `nodeRequire` being undefined it means we're being run in a nodejs
// environment directly, without a webpack build, and have to manually create it as an
// alias for the nodejs require so that things continue to work.
// Alias require as nodeRequire for the config-loader hack.
global.nodeRequire = require;
}
// Register a .sbvr loader
// tslint:disable-next-line:no-var-requires
const fs: typeof Fs = require('fs');
nodeRequire.extensions['.sbvr'] = (module: NodeModule, filename: string) =>
(module.exports = fs.readFileSync(filename, 'utf8'));
}