How to use the module._resolveFilename function in module

To help you get started, we’ve selected a few module 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 sebmarkbage / link.js / Source / Node / link.js View on Github external
function preloadImports(parsedModule, parent){
	for (var i = 0, l = parsedModule.imports.length; i < l; i++){
		var path = parsedModule.imports[i];
		if (!(path in aliases)){
			if (path in testObject)
				path = path + '.js'; // Resolve Node cache bug
			parsedModule.imports[i] = path = Module._resolveFilename(path, parent);
		}
		if (Path.extname(aliases[path] || path) == '.js' && !Object.prototype.hasOwnProperty.call(require.cache, path)){
			var mod = new Module(path, parent);
			mod.filename = path;
			preload(path, mod);
		}
	}
}
github angular / material-tools / lib / virtual_context / SandboxRequire.ts View on Github external
function resolve(moduleName) {
    let resolved = NodeModule._resolveFilename(moduleName, _parentModule);
    return (resolved instanceof Array) ? resolved[1] : resolved;
  }
github stanford-oval / thingengine-core / lib / devices / modules / base_js.js View on Github external
function resolve(mainModule) {
    if (!mainModule.startsWith('/'))
        throw new Error('Invalid relative module path');
    if (require.resolve)
        return require.resolve(mainModule);
    else
        return Module._resolveFilename(mainModule, module, false);
}

module

Generate the minimal skeleton/boilerplate for a new Node.js module.

MIT
Latest version published 9 years ago

Package Health Score

41 / 100
Full package analysis