本文整理汇总了TypeScript中resolve-from.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: loadDojoLoader
export default function loadDojoLoader ({ peerDependencies = {} }: any) {
const baseUrl = process.cwd();
const packages = [
{ name: 'src', location: '_build/src' }
];
for (const name in peerDependencies) {
if (/^dojo-/.test(name)) {
packages.push({ name, location: join('node_modules', name, 'dist', 'umd') });
}
else if (name === '@reactivex/rxjs') {
packages.push({ name: 'rxjs', location: join('node_modules', name, 'dist', 'amd') });
}
else if (name === 'maquette' || name === 'immutable') {
packages.push({ name, location: join('node_modules', name, 'dist') });
}
else {
packages.push({ name, location: join('node_modules', name) });
}
}
// Assume dojo-loader is installed in the parent project.
const r = require(resolveFrom(baseUrl, 'dojo-loader'));
r.config({
baseUrl,
packages
});
return {
baseUrl,
packages,
require: r
};
}
示例2: require
grunt.registerTask('repl', 'Bootstrap dojo-loader and start a Node.js REPL', function () {
this.async(); // Ensure Grunt doesn't exit the process.
const { baseUrl, packages, require: dojoRequire } = loadDojoLoader(packageJson);
const nodeRequire = function (mid: string) {
// Require relative to the baseUrl, not this module.
return require(resolveFrom(baseUrl, mid));
};
Object.defineProperty(nodeRequire, 'resolve', {
configurable: false,
enumerable: true,
value (mid: string) {
return resolveFrom(baseUrl, mid);
}
});
grunt.log.ok(`Available packages: ${packages.map(({ name }) => name).join(', ')}`);
grunt.log.ok('require() is now powered by dojo-loader');
grunt.log.ok('Node.js\' require() is available under nodeRequire()');
const { context } = repl.start();
Object.defineProperties(context, {
nodeRequire: {
configurable: false,
enumerable: true,
value: nodeRequire
},
require: {
configurable: false,
enumerable: true,
value: dojoRequire
}
});
});