From cd00680b76e48f139c646da0c0149b1f6dfad909 Mon Sep 17 00:00:00 2001 From: yuyutaotao <167746126+yuyutaotao@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:53:11 +0800 Subject: [PATCH] fix: make puppeteer external in web-integration (#208) * fix: make puppeteer external in web-integration * fix: import path of yaml player * fix: import path of yaml player --- packages/cli/src/printer.ts | 2 +- packages/cli/src/yaml-runner.ts | 2 +- packages/web-integration/modern.config.ts | 2 +- packages/web-integration/src/puppeteer/agent-launcher.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/printer.ts b/packages/cli/src/printer.ts index c63a0aad..7ea6ce76 100644 --- a/packages/cli/src/printer.ts +++ b/packages/cli/src/printer.ts @@ -3,7 +3,7 @@ import type { ScriptPlayerStatusValue, ScriptPlayerTaskStatus, } from '@midscene/core'; -import { type ScriptPlayer, flowItemBrief } from '@midscene/web'; +import { type ScriptPlayer, flowItemBrief } from '@midscene/web/yaml'; import chalk from 'chalk'; export interface MidsceneYamlFileContext { diff --git a/packages/cli/src/yaml-runner.ts b/packages/cli/src/yaml-runner.ts index 0d3077a7..5e33cdf9 100644 --- a/packages/cli/src/yaml-runner.ts +++ b/packages/cli/src/yaml-runner.ts @@ -1,6 +1,6 @@ import { readFileSync } from 'node:fs'; import { basename, extname } from 'node:path'; -import { ScriptPlayer, parseYamlScript } from '@midscene/web'; +import { ScriptPlayer, parseYamlScript } from '@midscene/web/yaml'; import { createServer } from 'http-server'; import { type MidsceneYamlFileContext, diff --git a/packages/web-integration/modern.config.ts b/packages/web-integration/modern.config.ts index ec8e2a83..8f4377de 100644 --- a/packages/web-integration/modern.config.ts +++ b/packages/web-integration/modern.config.ts @@ -20,6 +20,6 @@ export default defineConfig({ yaml: 'src/yaml/index.ts', }, target: 'es2018', - externals: ['@midscene/core', '@midscene/shared'], + externals: ['@midscene/core', '@midscene/shared', 'puppeteer'], }, }); diff --git a/packages/web-integration/src/puppeteer/agent-launcher.ts b/packages/web-integration/src/puppeteer/agent-launcher.ts index 93f28fc0..1e6a8c5a 100644 --- a/packages/web-integration/src/puppeteer/agent-launcher.ts +++ b/packages/web-integration/src/puppeteer/agent-launcher.ts @@ -1,6 +1,5 @@ import assert from 'node:assert'; import { readFileSync } from 'node:fs'; -import puppeteer from 'puppeteer'; import { PuppeteerAgent } from '@/puppeteer'; import type { MidsceneYamlScriptEnv } from '@midscene/core'; @@ -72,6 +71,7 @@ export async function puppeteerAgentForTarget( 'you are probably running headed mode in CI, this will usually fail.', ); } + const puppeteer = await import('puppeteer'); const browser = await puppeteer.launch({ headless: !headed, args: [