diff --git a/package.json b/package.json index e98007a..38b5b6b 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "express": "^5.2.1", "http-proxy-middleware": "^3.0.5", "ipaddr.js": "^2.3.0", - "launch-editor": "^2.13.1", "p-retry": "^7.1.1", "serve-index": "^1.9.2", "webpack-dev-middleware": "^7.4.5", @@ -83,6 +82,7 @@ "css-loader": "^7.1.4", "hono": "^4.12.3", "http-proxy": "^1.18.1", + "launch-editor": "^2.13.1", "nano-staged": "^0.9.0", "open": "^11.0.0", "prettier": "3.8.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2ff9ec..ce20d9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,9 +38,6 @@ importers: ipaddr.js: specifier: ^2.3.0 version: 2.3.0 - launch-editor: - specifier: ^2.13.1 - version: 2.13.1 p-retry: specifier: ^7.1.1 version: 7.1.1 @@ -105,6 +102,9 @@ importers: http-proxy: specifier: ^1.18.1 version: 1.18.1(debug@4.4.3) + launch-editor: + specifier: ^2.13.1 + version: 2.13.1 nano-staged: specifier: ^0.9.0 version: 0.9.0 diff --git a/rslib.config.ts b/rslib.config.ts index 5273c32..2266e71 100644 --- a/rslib.config.ts +++ b/rslib.config.ts @@ -9,7 +9,6 @@ export default defineConfig({ output: { externals: { express: 'commonjs express', - 'launch-editor': 'commonjs launch-editor', 'connect-history-api-fallback': 'commonjs connect-history-api-fallback', 'webpack-dev-middleware': 'commonjs webpack-dev-middleware', diff --git a/src/server.ts b/src/server.ts index e6414ea..929c5b9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1678,7 +1678,7 @@ class Server< middlewares.push({ name: 'rspack-dev-server-open-editor', path: '/rspack-dev-server/open-editor', - middleware: (req: Request, res: Response, next: NextFunction) => { + middleware: async (req: Request, res: Response, next: NextFunction) => { if (req.method !== 'GET' && req.method !== 'HEAD') { next(); return; @@ -1694,8 +1694,9 @@ class Server< const fileName = params.get('fileName'); if (typeof fileName === 'string') { - const launchEditor = require('launch-editor'); - + const { default: launchEditor } = await import( + /* webpackChunkName: "launch-editor" */ 'launch-editor' + ); launchEditor(fileName); }