How to use the tsconfig-paths.register function in tsconfig-paths

To help you get started, we’ve selected a few tsconfig-paths 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 trimox / angular-mdc-web / gulpfile.js View on Github external
if (projectDir.includes(' ')) {
  console.error('Error: Cannot run the Angular MDC build tasks if the project is ' +
    'located in a directory with spaces in between. Please rename your project directory.');
  process.exit(1);
}

// Register TS compilation.
require('ts-node').register({
  project: tsconfigPath,
  transpileOnly: true
});

// The gulp tsconfig file maps specific imports to relative paths. In combination with ts-node
// this doesn't work because the JavaScript output will still refer to the imports instead of
// to the relative path. Tsconfig-paths can be used to support path mapping inside of Node.
require('tsconfig-paths').register({
  baseUrl: path.dirname(tsconfigPath),
  paths: tsconfig.compilerOptions.paths
});

require('./tools/gulp/gulpfile');
github siggame / Cerveau / src / core / setup-thread.ts View on Github external
export function setupThread(): void {
    // yes read in sync. We don't want async stuff running without having their
    // tsconfig paths setup, or they will probably break.
    const file = readFileSync("tsconfig.json");
    const tsconfig = parse(file.toString()) as Tsconfig;

    if (!tsconfig.compilerOptions || !tsconfig.compilerOptions.paths) {
        throw new Error("Cannot setup thread as tsconfig has no paths!");
    }

    register({
        baseUrl: "./",
        paths: tsconfig.compilerOptions.paths,
    });
}
github angular / flex-layout / gulpfile.js View on Github external
*/

const path = require('path');

const tsconfigPath = path.join(__dirname, 'tools/gulp/tsconfig.json');
const tsconfig = require(tsconfigPath);

// Register TS compilation.
require('ts-node').register({
  project: tsconfigPath
});

// The gulp tsconfig file maps specific imports to relative paths. In combination with ts-node
// this doesn't work because the JavaScript output will still refer to the imports instead of
// to the relative path. Tsconfig-paths can be used to support path mapping inside of Node.
require('tsconfig-paths').register({
  baseUrl: path.dirname(tsconfigPath),
  paths: tsconfig.compilerOptions.paths
});

require('./tools/gulp/gulpfile');
github penta-jelly / re-radio / server / src / radio.ts View on Github external
/* eslint-disable import/first */
/* eslint-disable import/no-unassigned-import */
require('tsconfig-paths').register({ baseUrl: 'lib', paths: {} });
require('source-map-support/register');
/* eslint-enable import/no-unassigned-import */
import Fs from 'fs';
import Path from 'path';
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { ConfigService } from 'core/config/config.service';
import { EnvVariables } from 'core/config/config.variables';
import { RadioModule } from 'radio/radio.module';

const RADIO_READY_STATE_FILE_PATH = Path.join(__dirname, 'radio.ready');
const REAL_TIME_RADIO_READY_STATE_FILE_PATH = Path.join(__dirname, 'real-time-radio.ready');
Fs.existsSync(RADIO_READY_STATE_FILE_PATH) && Fs.unlinkSync(RADIO_READY_STATE_FILE_PATH);

async function bootstrap() {
github penta-jelly / re-radio / server / src / real-time-radio.ts View on Github external
/* eslint-disable import/first */
/* eslint-disable import/no-unassigned-import */
require('tsconfig-paths').register({ baseUrl: 'lib', paths: {} });
require('source-map-support/register');
/* eslint-enable import/no-unassigned-import */
import Fs from 'fs';
import Path from 'path';
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { ConfigService } from 'core/config/config.service';
import { RealTimeRadioModule } from 'real-time-radio/real-time-radio.module';
import { EnvVariables } from 'core/config/config.variables';

const REAL_TIME_RADIO_READY_STATE_FILE_PATH = Path.join(__dirname, 'real-time-radio.ready');
Fs.existsSync(REAL_TIME_RADIO_READY_STATE_FILE_PATH) && Fs.unlinkSync(REAL_TIME_RADIO_READY_STATE_FILE_PATH);

async function bootstrap() {
  const logger = new Logger('RealTimeRadioService');
github penta-jelly / re-radio / server / src / workers.ts View on Github external
/* eslint-disable import/first */
/* eslint-disable import/no-unassigned-import */
require('tsconfig-paths').register({ baseUrl: 'lib', paths: {} });
require('source-map-support/register');
/* eslint-enable import/no-unassigned-import */
import Path from 'path';
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { DevSeederService } from 'workers/seeder/dev-seeder.service';
import { WorkersModule } from 'workers/workers.module';

const RADIO_READY_STATE_FILE_PATH = Path.join(__dirname, 'radio.ready');

async function bootstrap() {
  const logger = new Logger('Workers');

  logger.log(`Wait until Graphql service response.`);
  // eslint-disable-next-line @typescript-eslint/no-var-requires
  await require('wait-on')({ resources: [RADIO_READY_STATE_FILE_PATH], timeout: 30000 });
github dynatrace-oss / barista / gulpfile.js View on Github external
*/

const path = require('path');

const tsconfigPath = path.join(__dirname, 'tools/gulp/tsconfig.json');
const tsconfig = require(tsconfigPath);

// Register TS compilation.
require('ts-node').register({
  project: tsconfigPath,
});

// The gulp tsconfig file maps specific imports to relative paths. In combination with ts-node
// this doesn't work because the JavaScript output will still refer to the imports instead of
// to the relative path. Tsconfig-paths can be used to support path mapping inside of Node.
require('tsconfig-paths').register({
  baseUrl: path.dirname(tsconfigPath),
  paths: tsconfig.compilerOptions.paths,
});

require('./tools/gulp/gulpfile');
github sharpangles / platform / modules / bootstrap / src / platforms / server / commonjs_module_loader.ts View on Github external
const path = require('path');
            let paths: { [ key: string ]: string[] } = {};
            for (let tsconfigPath in tsconfigPaths) {
                let tsconfig = require(path.isAbsolute(tsconfigPath) ? tsconfigPath : path.resolve(baseUrl, tsconfigPath));
                let tsconfigPathSettings = tsconfig && tsconfig.compilerOptions && tsconfig.compilerOptions.paths;
                if (!tsconfigPathSettings) {
                    continue;
                }
                for (let attrname in tsconfigPathSettings) {
                    // For each path in the tsconfig, push its unique values in the array onto a new or existing array for that module.
                    let existing: string[] = paths.hasOwnProperty(attrname) ? paths[attrname] : (paths[attrname] = []);
                    existing = existing.concat(tsconfigPathSettings[attrname]).filter((val, ind, self) => self.indexOf(val) === ind);
                    paths[attrname] = tsconfigPathSettings[attrname];
                }
            }
            require('tsconfig-paths').register({ baseUrl, paths: paths });
        }
github darkreader / darkreader / tasks / bundle-html.js View on Github external
return message;
});
global.chrome.i18n.getUILanguage = global.chrome.i18n.getUILanguage || (() => 'en-US');

const tsConfig = require('../src/tsconfig.json');
require('ts-node').register({
    ...tsConfig,
    compilerOptions: {
        ...tsConfig.compilerOptions,
        module: 'commonjs',
    },
    ignore: [
        '/node_modules\/(?!malevic).*/',
    ]
});
require('tsconfig-paths').register({
    baseUrl: './',
    paths: {
        'malevic/*': ['node_modules/malevic/umd/*'],
        'malevic': ['node_modules/malevic/umd/index'],
    }
});
const Malevic = require('malevic/umd/index');
const MalevicString = require('malevic/umd/string');
const DevToolsBody = require('../src/ui/devtools/components/body').default;
const PopupBody = require('../src/ui/popup/components/body').default;
const CSSEditorBody = require('../src/ui/stylesheet-editor/components/body').default;
const {getMockData, getMockActiveTabInfo} = require('../src/ui/connect/mock');

async function bundlePopupHTML({dir}) {
    let html = await fs.readFile('src/ui/popup/index.html', 'utf8');
    const data = getMockData({isReady: false});

tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis