Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
release
  • Loading branch information
hemengke1997 committed Apr 26, 2024
1 parent 639d522 commit bd0c73d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
3 changes: 1 addition & 2 deletions packages/vite-plugin-istanbul-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
},
"scripts": {
"dev": "tsup --watch",
"build": "tsup",
"lib": "tsup --config tsup.config.lib.ts"
"build": "tsup"
},
"dependencies": {
"@minko-fe/lodash-pro": "^0.2.4",
Expand Down
14 changes: 8 additions & 6 deletions packages/vite-plugin-istanbul-widget/src/astro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
name: 'vite:plugin-istanbul-widget:astro',
enforce: 'pre',
transform(code, id) {
if (id === 'astro:scripts/page.js') {
code = /*js*/ `${resolveInlineScript('esm', opts.istanbulWidgetConfig).script}
\n${code}`
if (opts.istanbulWidgetConfig !== false) {
if (id === 'astro:scripts/page.js') {
code = /*js*/ `${resolveInlineScript('esm', opts.istanbulWidgetConfig).script}
\n${code}`

return {
code,
map: { mappings: '' },
return {
code,
map: { mappings: '' },
}
}
}
},
Expand Down
39 changes: 21 additions & 18 deletions packages/vite-plugin-istanbul-widget/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,30 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
transformIndexHtml: {
order: 'pre',
handler(html) {
return {
html,
tags: [
{
tag: 'script',
attrs: {
type: 'module',
src: resolveInlineScript('min', istanbulWidgetConfig).src,
if (istanbulWidgetConfig !== false) {
return {
html,
tags: [
{
tag: 'script',
attrs: {
type: 'module',
src: resolveInlineScript('min', istanbulWidgetConfig).src,
},
injectTo: 'body',
},
injectTo: 'body',
},
{
tag: 'script',
attrs: {
type: 'module',
{
tag: 'script',
attrs: {
type: 'module',
},
injectTo: 'body',
children: resolveInlineScript('min', istanbulWidgetConfig).script,
},
injectTo: 'body',
children: resolveInlineScript('min', istanbulWidgetConfig).script,
},
],
],
}
}
return html
},
},
},
Expand Down

0 comments on commit bd0c73d

Please sign in to comment.