Skip to content
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

fix: mark applicationinsights as external and side-effects #125

Merged
merged 3 commits into from
Nov 15, 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
7 changes: 0 additions & 7 deletions docs/content/1.guide/4.importing-applicationinsights.md

This file was deleted.

34 changes: 17 additions & 17 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ export default <NitroModule>{
if (!nitro.options.externals) {
nitro.options.externals = {}
}

nitro.options.alias['#applicationinsights'] = await resolvePath('nitro-applicationinsights/runtime/applicationinsights', {
extensions: ['.ts', '.mjs', '.js'],
url: [import.meta.url]
})

nitro.options.externals.inline = nitro.options.externals.inline || []
// force inline the plugin and the setup file
nitro.options.externals.inline.push((id) => (
Expand All @@ -28,17 +22,11 @@ export default <NitroModule>{
}))

nitro.options = defu(nitro.options, {
typescript: {
tsConfig: {
compilerOptions: {
paths: {
'#applicationinsights': [await resolvePath('nitro-applicationinsights/runtime/applicationinsights', {
extensions: ['.ts', '.mjs', '.js'],
url: [import.meta.url]
})]
}
}
}
externals: {
traceInclude: [
// the main file doesn't seems to be traced
await resolvePath('applicationinsights/out/applicationinsights.js')
]
},
rollupConfig: {
plugins: [
Expand All @@ -63,6 +51,18 @@ export default <NitroModule>{
};
}
}
},
{
name: 'applicationinsights-loader',
resolveId(id) {
if (id === 'applicationinsights') {
return {
id: 'applicationinsights',
moduleSideEffects: true,
external: true
}
}
},
}
]
}
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/applicationinsights.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { NitroApp, NitroAppPlugin } from 'nitropack'
import defu from 'defu'
import type { TNitroAppInsightsConfig } from '../types'
import { useRuntimeConfig } from '#imports'
import _Applicationinsights from '#applicationinsights'
import type { Contracts } from '#applicationinsights'
import _Applicationinsights from 'applicationinsights'
import type { Contracts } from 'applicationinsights'

const Applicationinsights = _Applicationinsights as typeof import('applicationinsights')
export default <NitroAppPlugin>(async (nitro) => {
Expand Down