'use strict'; const mlly = require('mlly'); const defu = require('defu'); const MagicString = require('magic-string'); var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const defu__default = /*#__PURE__*/_interopDefaultCompat(defu); const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString); const module$1 = { name: "nitro-applicationinsights", async setup(nitro) { if (!nitro.options.externals) { nitro.options.externals = {}; } nitro.options.externals.inline = nitro.options.externals.inline || []; nitro.options.externals.inline.push((id) => id.includes("nitro-applicationinsights/runtime/plugin") || id.includes("nitro-applicationinsights/dist/runtime/plugin")); nitro.options.plugins.push(await mlly.resolvePath("nitro-applicationinsights/runtime/plugin", { extensions: [".ts", ".mjs", ".js"], url: [(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))] })); nitro.options = defu__default(nitro.options, { externals: { traceInclude: [ // the main file doesn't seems to be traced await mlly.resolvePath("applicationinsights/out/applicationinsights.js") ] }, rollupConfig: { plugins: [ // add necessary global var for applicationinsights { name: "esm-shim", renderChunk(code, _chunk, opts) { if (opts.format !== "es" || code.includes("// transformed by esm-shim")) { return; } if (code.includes("__dirname") || code.includes("__filename")) { const s = new MagicString__default(code); s.prepend(` // transformed by esm-shim import { dirname as __pathDirname } from 'path'; import { fileURLToPath as __fileURLToPath } from 'url'; const __filename = __fileURLToPath(_import_meta_url_); const __dirname = __pathDirname(__filename);`); return { code: s.toString(), map: s.generateMap({ hires: true }) }; } } }, { name: "applicationinsights-loader", resolveId(id) { if (id === "applicationinsights") { return { id: "applicationinsights", moduleSideEffects: true, external: true }; } } } ] } }); } }; module.exports = module$1;