Skip to content

Commit 26c1834

Browse files
authored
Merge pull request #392 from zh-lx/fix/umi-with-app
fix: compatible for umijs with app.ts
2 parents ad42745 + c7d7515 commit 26c1834

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/core/src/server/use-client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ if (typeof __dirname !== 'undefined') {
3737
export const clientJsPath = path.resolve(compatibleDirname, './client.umd.js');
3838
const jsClientCode = fs.readFileSync(clientJsPath, 'utf-8');
3939

40+
const iifeClientJsPath = path.resolve(compatibleDirname, './client.iife.js');
41+
const iifeClientJsCode = fs.readFileSync(iifeClientJsPath, 'utf-8');
42+
4043
const NextEmptyElementName = 'CodeInspectorEmptyElement';
4144
export function getInjectedCode(
4245
options: CodeOptions,
@@ -142,13 +145,14 @@ export function getWebComponentCode(options: CodeOptions, port: number) {
142145
autoToggle = true,
143146
behavior = {},
144147
ip = false,
148+
bundler,
145149
} = options || ({} as CodeOptions);
146150
const { locate = true, copy = false, target = '' } = behavior;
147151
return `
148152
;(function (){
149153
if (typeof window !== 'undefined') {
150154
if (!document.documentElement.querySelector('code-inspector-component')) {
151-
${jsClientCode};
155+
${bundler === 'mako' ? iifeClientJsCode : jsClientCode};
152156
153157
var inspector = document.createElement('code-inspector-component');
154158
inspector.port = ${port};

packages/core/vite.client.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
build: {
77
lib: {
88
entry: ['src/client/index.ts'],
9-
formats: ['umd'],
9+
formats: ['umd', 'iife'],
1010
fileName: 'client',
1111
name: 'vueInspectorClient',
1212
},
@@ -18,8 +18,8 @@ export default defineConfig({
1818
// @ts-ignore
1919
terser({
2020
format: {
21-
comments: false
22-
}
23-
})
21+
comments: false,
22+
},
23+
}),
2424
],
2525
});

0 commit comments

Comments
 (0)