本文整理汇总了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
};
}
开发者ID:dylans,项目名称:grunt-dojo2,代码行数:34,代码来源:load-dojo-loader.ts
示例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
}
});
});
开发者ID:vansimke,项目名称:grunt-dojo2,代码行数:35,代码来源:repl.ts
注:本文中的resolve-from.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论