本文整理汇总了TypeScript中@core/feature/modules/exports.Module.cfg方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Module.cfg方法的具体用法?TypeScript Module.cfg怎么用?TypeScript Module.cfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@core/feature/modules/exports.Module
的用法示例。
在下文中一共展示了Module.cfg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: UTest
import { mask_config } from '@core/api/config';
import { Module } from '@core/feature/modules/exports';
import { renderer_renderAsync } from '@core/renderer/exports';
UTest({
$teardown () {
mask_config('getFile', null);
mask_config('getScript', null);
},
async 'should load script' () {
var Foo = {
get name () { return 'FooTest' }
};
Module
.cfg('prefixes.services', '/src/services/{0}.js')
.cfg('ext.script', 'js')
;
mask_config('getScript', assert.await(async path => {
has_(path, '/src/services/FooService.js');
return Foo;
}));
let dom = await renderer_renderAsync(`
import * as Foo from '@services/FooService';
h3 > '~[Foo.name]'
`);
return UTest.domtest(dom, `
find('h3') > text FooTest;
`);
示例2: UTest
import { mask_config } from '@core/api/config';
import { Module } from '@core/feature/modules/exports';
import { renderer_renderAsync } from '@core/renderer/exports';
import { listeners_on, listeners_off } from '@core/util/listeners';
UTest({
$before () {
// use default module loader
mask_config('modules', 'default');
Module.cfg('moduleResolution', 'node');
},
$after () {
Module.cfg('moduleResolution', 'classic');
listeners_off('error');
},
async 'should load default file in node_modules' () {
let dom = await renderer_renderAsync(`
import Foo from '/test/tmpl/npm/foo.mask';
Foo;
`);
return UTest.domtest(dom, `
find ('h4') > text ('EmptyPackage');
`);
},
async 'should fail loading' () {
var errors = [];
listeners_on('error', assert.await((error) => errors.push(error)));
示例3: mask_config
mask_config('getFile', assert.await(async path => {
has_(path, 'controls/Foo.mask');
var template = 'define Foo { h3 > "FooTest" }';
return template;
}));
let dom = await renderer_renderAsync(`
import Foo from controls is mask;
Foo;
`);
return UTest.domtest(dom, `
find('h3') > text FooTest;
`);
},
async 'should load script' () {
Module.cfg('ext.script', 'es6');
mask_config('getScript', assert.await(async path => {
has_(path, 'services/Foo.es6');
var service = {
getName () { return 'FooServiceTest' }
};
return service;
}));
let dom = await renderer_renderAsync(`
import Foo from services;
h5 > '~[Foo.getName()]';
`);
return UTest.domtest(dom, `