How to use the module-alias.addAliases function in module-alias

To help you get started, we’ve selected a few module-alias 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 uber / xviz / test / start.js View on Github external
/* global process */
require('@babel/register')({
  configFile: resolve(__dirname, '../babel.config.js')
});

const {BrowserTestDriver} = require('@probe.gl/test-utils');

const mode = process.argv.length >= 3 ? process.argv[2] : 'default';

require('source-map-support').install();

// Registers aliases for virtual packages in this module
if (mode !== 'dist') {
  const moduleAlias = require('module-alias');
  moduleAlias.addAliases(ALIASES);
}

// Update JSON list of examples
require('./modules/update-test-cases');

switch (mode) {
  case 'test':
  case 'src':
  case 'dist':
    require('./index');
    break;

  case 'bench':
    require('./bench');
    break;
github intuit / auto / packages / cli / src / bin / auto.ts View on Github external
#!/usr/bin/env node

import moduleAlias from 'module-alias';
import path from 'path';

try {
  // eslint-disable-next-line
  const json = require(path.join(__dirname, '../../package.json'));

  if (json.name.startsWith('@auto-canary')) {
    moduleAlias.addAliases({
      '@auto-it': (fromPath: string, request: string) =>
        request.startsWith('@auto-it') ? '@auto-canary' : '@auto-it'
    });
  }
} catch (error) {}

import chalk from 'chalk';
import parseArgs from '../parse-args';
import run from '../run';

const [command, args] = parseArgs();

if (command && args) {
  run(command, args).catch((e: Error) => {
    console.error(chalk.redBright('Error: '), e.message);
    process.exit(1);
github leidenglai / React-Koa2-SSR / server / server.dev.js View on Github external
generateScopedName: '[name]__[local]___[hash:base64:5]'
})

// Image require hook
require('asset-require-hook')({
  name: '/img/[name]-[hash:6].[ext]',
  extensions: ['jpg', 'jpeg', 'png', 'svg'],
  limit: 10240
})

const webpackConfig = require('../build/webpack.dev.conf')

// 配置别名
const moduleAlias = require('module-alias')

moduleAlias.addAliases(webpackConfig.resolve.alias)

const app = require('./app.js')
const convert = require('koa-convert')
const webpack = require('webpack')
const fs = require('fs')
const path = require('path')
const devMiddleware = require('koa-webpack-dev-middleware')
const hotMiddleware = require('koa-webpack-hot-middleware')
const views = require('koa-views')
const clientRoute = require('./middlewares/clientRoute')
const packBody = require('./middlewares/packBody')
const handle404 = require('./middlewares/handle404')
const router = require('./routes')

// mongo数据库
require('./middlewares/mongooseLog') // 打印 mongodb 查询日志
github ghondar / crassa / server / index.js View on Github external
presets: [ '@babel/env', '@babel/preset-react' ],
  plugins: [ [ '@babel/plugin-proposal-class-properties', { loose: true } ], '@babel/plugin-transform-flow-strip-types', 'babel-plugin-dynamic-import-node', '@loadable/babel-plugin' ]
})

require('regenerator-runtime/runtime')

const { appRootPath, appPackage, appDotEnv } = require('../src/paths')
const { _moduleAliases } = require(appPackage)

const aliases = {}

Object.keys(_moduleAliases).forEach(key => {
  aliases[key] = _moduleAliases[key].replace('.', appRootPath)
})

moduleAlias.addAliases(aliases)

require('dotenv').config({
  path: appDotEnv
})
// Now that the nonsense is over... load up the server entry point
require('./server')
github cssinjs / cssinjs / bin / build-html.js View on Github external
var fs = require('fs')
var path = require('path')

var babelConfigPath = path.join(process.cwd(), '.babelrc')
var babelConfig = JSON.parse(fs.readFileSync(babelConfigPath))

require('babel-register')(babelConfig)
require('ignore-styles')
require('module-alias').addAliases(require('../webpack.config.base').resolve.alias)

var render = require('../src/server').default
var nav = require('../src/utils/navigation')

// Make sure there are no duplicate routes.
function findDups(root, map = {}, dups = []) {
  for (var name in root) {
    const page = root[name]
    if (map[name]) dups.push(name)
    map[name] = true
    if (page.children) findDups(page.children, map, dups)
  }
  return dups
}
var dups = findDups(nav.tree)
github philmander / versatile / packages / server / server.js View on Github external
/* eslint-disable no-console */
require('module-alias').addAliases({
    'react'  : 'preact-compat',
    'react-dom': 'preact-compat',
    'create-react-class' : 'preact-compat/lib/create-react-class'
});

const path = require('path');
const express = require('express');
const lodash = require('lodash-express');
const clientView = require('versatile-client/lib/view/view').default;
const md5File = require('md5-file');
const favicon = require('serve-favicon');

const logging = require('./src/logging');
const renderPreactApp = require('./src/render-preact-app');
const createApi = require('./src/api/api');
const restApi = require('./src/api/rest');
github emotion-js / emotion / scripts / babel-plugin-emotion-test / src / index.js View on Github external
require('@babel/register')
let aliases = require('preconstruct').aliases.rollup()
delete aliases['emotion']
require('module-alias').addAliases(aliases)

module.exports = require('babel-plugin-emotion')
github owid / owid-grapher / js / misc / exportAll.ts View on Github external
const outputPath = `tmp/export/${slug}.svg`
    if (fs.existsSync(outputPath)) {
        next()
    } else {
        exportChart(`${rootUrl}/${slug}`, outputPath, next)
    }
}

require('isomorphic-fetch')

declare var global: any
global.Global = { rootUrl: rootUrl }
global.window = { location: { search: "" }}
global.App = { isEditor: false }

require('module-alias').addAliases({
    'react'  : 'preact-compat',
    'react-dom': 'preact-compat'
})

//import * as sharp from 'sharp'
import ChartConfig from '../charts/ChartConfig'
import {when} from 'mobx'

function exportChart(targetSrc: string, outputPath: string, callback: () => void) {
    const [configUrl, queryStr] = targetSrc.split(/\?/)
    fetch(configUrl + ".config.json").then(data => data.json()).then(jsonConfig => {
        const chart = new ChartConfig(jsonConfig, { queryStr: queryStr })
        chart.baseFontSize = 18
        console.log(`Rendering ${chart.props.slug}...`)
        when(() => chart.data.isReady, () => {
            setTimeout(() => {
github ghondar / crassa / start.ts View on Github external
import moduleAlias from 'module-alias'
import { packageRootPath } from './src/paths'

const { _moduleAliases } = require(packageRootPath + '/package.json')

const aliases = {}

Object.keys(_moduleAliases).forEach(key => {
  aliases[key] = _moduleAliases[key].replace('.', packageRootPath)
})

moduleAlias.addAliases(aliases)

require('react-app-rewired/scripts/start')

module-alias

Create aliases of directories and register custom module paths

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis