當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript resolve-from.default函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。