How to use componentsjs - 2 common examples

To help you get started, we’ve selected a few componentsjs 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 comunica / comunica / packages / runner / bin / compile-config.ts View on Github external
const configStreamRaw: Stream = createReadStream(configPath, { encoding: 'utf8' });
let exportVariableName: string = 'urn:comunica:sparqlinit';
if (args.length > 1) {
  exportVariableName = args[1];
}

// Hack our require path so that compilation in a monorepo dev environment always works properly
// Otherwise, Components.js will think that we are running inside the 'runner' package,
// and it will use its node_modules.
require.main.paths = [];
const pathParts = mainModulePath.split(sep);
for (let i = pathParts.length; i > 0; i--) {
  require.main.paths.push(pathParts.slice(0, i).join(sep) + sep + 'node_modules');
}

compileConfig({ mainModulePath }, configPath, configStreamRaw, configResourceUri, exportVariableName)
  .then(console.log).catch((e) => {
    console.error(e);
    process.exit(1);
  });
github comunica / comunica / packages / runner / lib / Setup.ts View on Github external
public static async instantiateComponent(configResourceUrl: string, instanceUri: string,
                                           properties?: ISetupProperties): Promise {
    if (!Setup.preparedPromises) {
      Setup.preparedPromises = true;
      Setup.preparePromises();
    }

    // Handle optional arguments
    if (!properties) {
      properties = {};
    }
    require('lodash.defaults')(properties, { mainModulePath: process.cwd() });

    // Instantiate the given config file
    const loader = new Loader(properties);
    await loader.registerAvailableModuleResources();
    return await loader.instantiateFromUrl(instanceUri, configResourceUrl);
  }

componentsjs

A semantic dependency injection framework

MIT
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Popular componentsjs functions