refactor(rollup): remove unnecessary async waits
This commit is contained in:
parent
93a1ed2b0d
commit
21f28a21d2
|
@ -47,16 +47,16 @@ export const DEFAULT_VARIABLE: Variable = {
|
||||||
* get the list of templates provided by this preset
|
* get the list of templates provided by this preset
|
||||||
* @returns list of preset templates
|
* @returns list of preset templates
|
||||||
*/
|
*/
|
||||||
export default async function (): Promise<PresetAsset> {
|
export default function (): PresetAsset {
|
||||||
return {
|
return {
|
||||||
template: {
|
template: {
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
'rollup.config.ts': async (context) => {
|
'rollup.config.ts': (context) => {
|
||||||
const content = loadFile(
|
const content = loadFile(
|
||||||
resolve(TEMPLATES, 'rollup.config.ts'),
|
resolve(TEMPLATES, 'rollup.config.ts'),
|
||||||
'text',
|
'text',
|
||||||
);
|
);
|
||||||
const variable = await getRollupParameter(context);
|
const variable = getRollupParameter(context);
|
||||||
|
|
||||||
return template(content, variable);
|
return template(content, variable);
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
/* eslint-enable @typescript-eslint/naming-convention */
|
||||||
|
|
|
@ -61,9 +61,9 @@ interface IntermediateRollupConfig {
|
||||||
* @param context context about the build environment
|
* @param context context about the build environment
|
||||||
* @returns template parameter related to rollup
|
* @returns template parameter related to rollup
|
||||||
*/
|
*/
|
||||||
export async function getRollupParameter(
|
export function getRollupParameter(
|
||||||
context: ResolvedPresetContext,
|
context: ResolvedPresetContext,
|
||||||
): Promise<Record<'rollupImport' | 'rollupExport', string>> {
|
): Record<'rollupImport' | 'rollupExport', string> {
|
||||||
const { config, variable } = context.custom;
|
const { config, variable } = context.custom;
|
||||||
|
|
||||||
const normalizedConfig = template(
|
const normalizedConfig = template(
|
||||||
|
|
|
@ -27,7 +27,7 @@ jest.mock('path', () => ({
|
||||||
|
|
||||||
describe('fn:getPresetAsset', () => {
|
describe('fn:getPresetAsset', () => {
|
||||||
it('use all templates', async () => {
|
it('use all templates', async () => {
|
||||||
const asset = await getPresetAsset();
|
const asset = getPresetAsset();
|
||||||
const context = await resolveContext({
|
const context = await resolveContext({
|
||||||
graph: [{ name: 'preset', asset, nodes: [] }],
|
graph: [{ name: 'preset', asset, nodes: [] }],
|
||||||
context: {
|
context: {
|
||||||
|
@ -41,9 +41,9 @@ describe('fn:getPresetAsset', () => {
|
||||||
await loadDynamicMap(asset.template, context);
|
await loadDynamicMap(asset.template, context);
|
||||||
|
|
||||||
const TEMPLATES = resolve(__dirname, '..', 'templates');
|
const TEMPLATES = resolve(__dirname, '..', 'templates');
|
||||||
const allTemplates = await readdirSync(TEMPLATES);
|
const allTemplates = readdirSync(TEMPLATES);
|
||||||
const CONFIGS = resolve(__dirname, '..', 'configs');
|
const CONFIGS = resolve(__dirname, '..', 'configs');
|
||||||
const supplementaryConfig = await readdirSync(CONFIGS);
|
const supplementaryConfig = readdirSync(CONFIGS);
|
||||||
|
|
||||||
for (const path of allTemplates) {
|
for (const path of allTemplates) {
|
||||||
expect(resolve).toBeCalledWith(TEMPLATES, path);
|
expect(resolve).toBeCalledWith(TEMPLATES, path);
|
||||||
|
|
Loading…
Reference in New Issue