Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(electron): use esm instead of iife to load script #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/guide/standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ Then import it directly in your app:
import { devtools } from '@vue/devtools'
```

:::tip Important
Make sure you import devtools before Vue, otherwise it might not work as expected.
:::

And connect to host:

```ts
if (process.env.NODE_ENV === 'development')
devtools.connect(/* host, port */)
```

:::tip Important
Make sure to invoke devtools connect function before creating Vue App, otherwise it might not work as expected.
:::

**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`).

**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.
Expand Down
3 changes: 2 additions & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"scripts": {
"build": "tsx scripts/build.ts",
"dev": "tsx scripts/build.ts --watch",
"prepare:type": "tsup src/index.ts --dts-only --format cjs,esm"
"prepare:type": "tsup src/index.ts --dts-only --format cjs,esm",
"stub": "pnpm dev"
},
"dependencies": {
"@vue/devtools-core": "workspace:^",
Expand Down
8 changes: 2 additions & 6 deletions packages/electron/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { isBrowser, target } from '@vue/devtools-shared'
import { target } from '@vue/devtools-shared'
import { devtools } from '../../devtools-kit/src/index'

export async function connect(host: string, port: number) {
devtools.init()
target.__VUE_DEVTOOLS_HOST__ = host
target.__VUE_DEVTOOLS_PORT__ = port
if (isBrowser)
import('./user-app.js')

else
// @ts-expect-error skip
import('./user-app.mjs')
import('./user-app.mjs')
}