Skip to content

Commit d984f50

Browse files
committed
chore: backward compact
1 parent a4348c6 commit d984f50

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/core/playground/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default defineConfig({
4747

4848
ctx.docks.register({
4949
type: 'action',
50-
import: ctx.utils.clientEntryFromSimpleFunction(() => {
50+
action: ctx.utils.clientEntryFromSimpleFunction(() => {
5151
// eslint-disable-next-line no-alert
5252
alert('Hello, world!')
5353
}),

packages/core/src/node/plugins/server.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,27 @@ export function DevToolsServer(): Plugin {
3636
for (const dock of docks) {
3737
const id = `${dock.type}:${dock.id}`
3838
if (dock.type === 'action') {
39-
map.set(id, dock.action)
39+
// TODO: backward compatibility, remove later
40+
// @ts-expect-error ignore
41+
map.set(id, dock.action || dock.import)
4042
}
4143
else if (dock.type === 'custom-render') {
4244
map.set(id, dock.renderer)
4345
}
4446
else if (dock.type === 'iframe' && dock.clientScript) {
4547
map.set(id, dock.clientScript)
4648
}
49+
else if ('import' in dock) {
50+
// TODO: backward compatibility, remove later
51+
// @ts-expect-error ignore
52+
map.set(id, dock.import)
53+
}
4754
}
4855
return [
4956
`export const importsMap = {`,
50-
...[...Object.entries(map)]
51-
.map(([id, { importFrom, importName }]) => ` ${JSON.stringify(id)}: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
57+
...[...map.entries()]
58+
.filter(([, entry]) => entry != null)
59+
.map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
5260
'}',
5361
].join('\n')
5462
}

0 commit comments

Comments
 (0)