Skip to content

Commit fb1b261

Browse files
authored
fix(electron): use esm instead of iife to load script (#157)
1 parent 4246a25 commit fb1b261

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

docs/guide/standalone.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ Then import it directly in your app:
101101
import { devtools } from '@vue/devtools'
102102
```
103103

104-
:::tip Important
105-
Make sure you import devtools before Vue, otherwise it might not work as expected.
106-
:::
107-
108104
And connect to host:
109105

110106
```ts
111107
if (process.env.NODE_ENV === 'development')
112108
devtools.connect(/* host, port */)
113109
```
114110

111+
:::tip Important
112+
Make sure to invoke devtools connect function before creating Vue App, otherwise it might not work as expected.
113+
:::
114+
115115
**host** - is an optional argument that tells your application where devtools middleware server is running, if you debug your app on your computer you don't have to set this (the default is `http://localhost`), but if you want to debug your app on mobile devices, you might want to pass your local IP (e.g. `http://192.168.1.12`).
116116

117117
**port** - is an optional argument that tells your application on what port devtools middleware server is running. If you use proxy server, you might want to set it to `null` so the port won't be added to connection URL.

packages/electron/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"scripts": {
2828
"build": "tsx scripts/build.ts",
2929
"dev": "tsx scripts/build.ts --watch",
30-
"prepare:type": "tsup src/index.ts --dts-only --format cjs,esm"
30+
"prepare:type": "tsup src/index.ts --dts-only --format cjs,esm",
31+
"stub": "pnpm dev"
3132
},
3233
"dependencies": {
3334
"@vue/devtools-core": "workspace:^",

packages/electron/src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { isBrowser, target } from '@vue/devtools-shared'
1+
import { target } from '@vue/devtools-shared'
22
import { devtools } from '../../devtools-kit/src/index'
33

44
export async function connect(host: string, port: number) {
55
devtools.init()
66
target.__VUE_DEVTOOLS_HOST__ = host
77
target.__VUE_DEVTOOLS_PORT__ = port
8-
if (isBrowser)
9-
import('./user-app.js')
10-
11-
else
128
// @ts-expect-error skip
13-
import('./user-app.mjs')
9+
import('./user-app.mjs')
1410
}

0 commit comments

Comments
 (0)