{"version":3,"sources":["../src/index.ts","../src/utils/log.ts","../src/handle-hot-update.ts","../src/utils/compile.ts","../src/utils/hash.ts","../src/utils/id.ts","../src/utils/options.ts","../src/utils/load-svelte-config.ts","../src/utils/constants.ts","../src/utils/dependencies.ts","../src/utils/esbuild.ts","../src/utils/error.ts","../src/utils/preprocess.ts","../src/utils/sourcemap.ts","../src/utils/vite-plugin-svelte-cache.ts","../src/utils/watch.ts","../src/utils/resolve.ts","../src/utils/optimizer.ts","../src/ui/inspector/plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport { HmrContext, ModuleNode, Plugin, ResolvedConfig, UserConfig } from 'vite';\nimport { handleHotUpdate } from './handle-hot-update';\nimport { log, logCompilerWarnings } from './utils/log';\nimport { CompileData, createCompileSvelte } from './utils/compile';\nimport { buildIdParser, IdParser, SvelteRequest } from './utils/id';\nimport {\n\tbuildExtraViteConfig,\n\tvalidateInlineOptions,\n\tOptions,\n\tResolvedOptions,\n\tresolveOptions,\n\tpatchResolvedViteConfig,\n\tpreResolveOptions\n} from './utils/options';\nimport { VitePluginSvelteCache } from './utils/vite-plugin-svelte-cache';\n\nimport { ensureWatchedFile, setupWatchers } from './utils/watch';\nimport { resolveViaPackageJsonSvelte } from './utils/resolve';\nimport { PartialResolvedId } from 'rollup';\nimport { toRollupError } from './utils/error';\nimport { saveSvelteMetadata } from './utils/optimizer';\nimport { svelteInspector } from './ui/inspector/plugin';\n\ninterface PluginAPI {\n\t/**\n\t * must not be modified, should not be used outside of vite-plugin-svelte repo\n\t * @internal\n\t * @experimental\n\t */\n\toptions?: ResolvedOptions;\n\t// TODO expose compile cache here so other utility plugins can use it\n}\n\nexport function svelte(inlineOptions?: Partial): Plugin[] {\n\tif (process.env.DEBUG != null) {\n\t\tlog.setLevel('debug');\n\t}\n\tvalidateInlineOptions(inlineOptions);\n\tconst cache = new VitePluginSvelteCache();\n\t// updated in configResolved hook\n\tlet requestParser: IdParser;\n\tlet options: ResolvedOptions;\n\tlet viteConfig: ResolvedConfig;\n\t/* eslint-disable no-unused-vars */\n\tlet compileSvelte: (\n\t\tsvelteRequest: SvelteRequest,\n\t\tcode: string,\n\t\toptions: Partial\n\t) => Promise;\n\t/* eslint-enable no-unused-vars */\n\n\tlet resolvedSvelteSSR: Promise;\n\tconst api: PluginAPI = {};\n\tconst plugins: Plugin[] = [\n\t\t{\n\t\t\tname: 'vite-plugin-svelte',\n\t\t\t// make sure our resolver runs before vite internal resolver to resolve svelte field correctly\n\t\t\tenforce: 'pre',\n\t\t\tapi,\n\t\t\tasync config(config, configEnv): Promise> {\n\t\t\t\t// setup logger\n\t\t\t\tif (process.env.DEBUG) {\n\t\t\t\t\tlog.setLevel('debug');\n\t\t\t\t} else if (config.logLevel) {\n\t\t\t\t\tlog.setLevel(config.logLevel);\n\t\t\t\t}\n\t\t\t\t// @ts-expect-error temporarily lend the options variable until fixed in configResolved\n\t\t\t\toptions = await preResolveOptions(inlineOptions, config, configEnv);\n\t\t\t\t// extra vite config\n\t\t\t\tconst extraViteConfig = buildExtraViteConfig(options, config);\n\t\t\t\tlog.debug('additional vite config', extraViteConfig);\n\t\t\t\treturn extraViteConfig;\n\t\t\t},\n\n\t\t\tasync configResolved(config) {\n\t\t\t\toptions = resolveOptions(options, config);\n\t\t\t\tpatchResolvedViteConfig(config, options);\n\t\t\t\trequestParser = buildIdParser(options);\n\t\t\t\tcompileSvelte = createCompileSvelte(options);\n\t\t\t\tviteConfig = config;\n\t\t\t\t// TODO deep clone to avoid mutability from outside?\n\t\t\t\tapi.options = options;\n\t\t\t\tlog.debug('resolved options', options);\n\t\t\t},\n\n\t\t\tasync buildStart() {\n\t\t\t\tif (!options.experimental?.prebundleSvelteLibraries) return;\n\t\t\t\tconst isSvelteMetadataChanged = await saveSvelteMetadata(viteConfig.cacheDir, options);\n\t\t\t\tif (isSvelteMetadataChanged) {\n\t\t\t\t\t// Force Vite to optimize again. Although we mutate the config here, it works because\n\t\t\t\t\t// Vite's optimizer runs after `buildStart()`.\n\t\t\t\t\tviteConfig.server.force = true;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tconfigureServer(server) {\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\toptions.server = server;\n\t\t\t\tsetupWatchers(options, cache, requestParser);\n\t\t\t},\n\n\t\t\tload(id, opts) {\n\t\t\t\t// @ts-expect-error anticipate vite changing second parameter as options object\n\t\t\t\t// see https://github.com/vitejs/vite/discussions/5109\n\t\t\t\tconst ssr: boolean = opts === true || opts?.ssr;\n\t\t\t\tconst svelteRequest = requestParser(id, !!ssr);\n\t\t\t\tif (svelteRequest) {\n\t\t\t\t\tconst { filename, query } = svelteRequest;\n\t\t\t\t\t// virtual css module\n\t\t\t\t\tif (query.svelte && query.type === 'style') {\n\t\t\t\t\t\tconst css = cache.getCSS(svelteRequest);\n\t\t\t\t\t\tif (css) {\n\t\t\t\t\t\t\tlog.debug(`load returns css for ${filename}`);\n\t\t\t\t\t\t\treturn css;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// prevent vite asset plugin from loading files as url that should be compiled in transform\n\t\t\t\t\tif (viteConfig.assetsInclude(filename)) {\n\t\t\t\t\t\tlog.debug(`load returns raw content for ${filename}`);\n\t\t\t\t\t\treturn fs.readFileSync(filename, 'utf-8');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tasync resolveId(importee, importer, opts) {\n\t\t\t\tconst ssr = !!opts?.ssr;\n\t\t\t\tconst svelteRequest = requestParser(importee, ssr);\n\t\t\t\tif (svelteRequest?.query.svelte) {\n\t\t\t\t\tif (svelteRequest.query.type === 'style') {\n\t\t\t\t\t\t// return cssId with root prefix so postcss pipeline of vite finds the directory correctly\n\t\t\t\t\t\t// see https://github.com/sveltejs/vite-plugin-svelte/issues/14\n\t\t\t\t\t\tlog.debug(`resolveId resolved virtual css module ${svelteRequest.cssId}`);\n\t\t\t\t\t\treturn svelteRequest.cssId;\n\t\t\t\t\t}\n\t\t\t\t\tlog.debug(`resolveId resolved ${importee}`);\n\t\t\t\t\treturn importee; // query with svelte tag, an id we generated, no need for further analysis\n\t\t\t\t}\n\n\t\t\t\tif (ssr && importee === 'svelte') {\n\t\t\t\t\tif (!resolvedSvelteSSR) {\n\t\t\t\t\t\tresolvedSvelteSSR = this.resolve('svelte/ssr', undefined, { skipSelf: true }).then(\n\t\t\t\t\t\t\t(svelteSSR) => {\n\t\t\t\t\t\t\t\tlog.debug('resolved svelte to svelte/ssr');\n\t\t\t\t\t\t\t\treturn svelteSSR;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(err) => {\n\t\t\t\t\t\t\t\tlog.debug(\n\t\t\t\t\t\t\t\t\t'failed to resolve svelte to svelte/ssr. Update svelte to a version that exports it',\n\t\t\t\t\t\t\t\t\terr\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn null; // returning null here leads to svelte getting resolved regularly\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn resolvedSvelteSSR;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst resolved = resolveViaPackageJsonSvelte(importee, importer, cache);\n\t\t\t\t\tif (resolved) {\n\t\t\t\t\t\tlog.debug(\n\t\t\t\t\t\t\t`resolveId resolved ${resolved} via package.json svelte field of ${importee}`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn resolved;\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlog.debug.once(\n\t\t\t\t\t\t`error trying to resolve ${importee} from ${importer} via package.json svelte field `,\n\t\t\t\t\t\te\n\t\t\t\t\t);\n\t\t\t\t\t// this error most likely happens due to non-svelte related importee/importers so swallow it here\n\t\t\t\t\t// in case it really way a svelte library, users will notice anyway. (lib not working due to failed resolve)\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tasync transform(code, id, opts) {\n\t\t\t\tconst ssr = !!opts?.ssr;\n\t\t\t\tconst svelteRequest = requestParser(id, ssr);\n\t\t\t\tif (!svelteRequest || svelteRequest.query.svelte) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet compileData;\n\t\t\t\ttry {\n\t\t\t\t\tcompileData = await compileSvelte(svelteRequest, code, options);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tcache.setError(svelteRequest, e);\n\t\t\t\t\tthrow toRollupError(e, options);\n\t\t\t\t}\n\t\t\t\tlogCompilerWarnings(svelteRequest, compileData.compiled.warnings, options);\n\t\t\t\tcache.update(compileData);\n\t\t\t\tif (compileData.dependencies?.length && options.server) {\n\t\t\t\t\tcompileData.dependencies.forEach((d) => {\n\t\t\t\t\t\tensureWatchedFile(options.server!.watcher, d, options.root);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tlog.debug(`transform returns compiled js for ${svelteRequest.filename}`);\n\t\t\t\treturn {\n\t\t\t\t\t...compileData.compiled.js,\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tvite: {\n\t\t\t\t\t\t\tlang: compileData.lang\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\n\t\t\thandleHotUpdate(ctx: HmrContext): void | Promise | void> {\n\t\t\t\tif (!options.hot || !options.emitCss) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst svelteRequest = requestParser(ctx.file, false, ctx.timestamp);\n\t\t\t\tif (svelteRequest) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn handleHotUpdate(compileSvelte, ctx, svelteRequest, cache, options);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tthrow toRollupError(e, options);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t];\n\tplugins.push(svelteInspector());\n\treturn plugins.filter(Boolean);\n}\n\nexport { loadSvelteConfig } from './utils/load-svelte-config';\n\nexport {\n\tOptions,\n\tPreprocessor,\n\tPreprocessorGroup,\n\tCompileOptions,\n\tCssHashGetter,\n\tArrayable,\n\tMarkupPreprocessor,\n\tModuleFormat,\n\tProcessed,\n\tWarning\n} from './utils/options';\n\nexport { SvelteWarningsMessage } from './utils/log';\n","/* eslint-disable no-unused-vars,no-console */\nimport { cyan, yellow, red } from 'kleur/colors';\nimport debug from 'debug';\nimport { ResolvedOptions, Warning } from './options';\nimport { SvelteRequest } from './id';\n\nconst levels: string[] = ['debug', 'info', 'warn', 'error', 'silent'];\nconst prefix = 'vite-plugin-svelte';\nconst loggers: { [key: string]: any } = {\n\tdebug: {\n\t\tlog: debug(`vite:${prefix}`),\n\t\tenabled: false,\n\t\tisDebug: true\n\t},\n\tinfo: {\n\t\tcolor: cyan,\n\t\tlog: console.log,\n\t\tenabled: true\n\t},\n\twarn: {\n\t\tcolor: yellow,\n\t\tlog: console.warn,\n\t\tenabled: true\n\t},\n\terror: {\n\t\tcolor: red,\n\t\tlog: console.error,\n\t\tenabled: true\n\t},\n\tsilent: {\n\t\tenabled: false\n\t}\n};\n\nlet _level: string = 'info';\nfunction setLevel(level: string) {\n\tif (level === _level) {\n\t\treturn;\n\t}\n\tconst levelIndex = levels.indexOf(level);\n\tif (levelIndex > -1) {\n\t\t_level = level;\n\t\tfor (let i = 0; i < levels.length; i++) {\n\t\t\tloggers[levels[i]].enabled = i >= levelIndex;\n\t\t}\n\t} else {\n\t\t_log(loggers.error, `invalid log level: ${level} `);\n\t}\n}\n\nfunction _log(logger: any, message: string, payload?: any) {\n\tif (!logger.enabled) {\n\t\treturn;\n\t}\n\tif (logger.isDebug) {\n\t\tpayload !== undefined ? logger.log(message, payload) : logger.log(message);\n\t} else {\n\t\tlogger.log(logger.color(`${new Date().toLocaleTimeString()} [${prefix}] ${message}`));\n\t\tif (payload) {\n\t\t\tlogger.log(payload);\n\t\t}\n\t}\n}\n\nexport interface LogFn {\n\t(message: string, payload?: any): void;\n\tenabled: boolean;\n\tonce: (message: string, payload?: any) => void;\n}\n\nfunction createLogger(level: string): LogFn {\n\tconst logger = loggers[level];\n\tconst logFn: LogFn = _log.bind(null, logger) as LogFn;\n\tconst logged = new Set();\n\tconst once = function (message: string, payload?: any) {\n\t\tif (logged.has(message)) {\n\t\t\treturn;\n\t\t}\n\t\tlogged.add(message);\n\t\tlogFn.apply(null, [message, payload]);\n\t};\n\tObject.defineProperty(logFn, 'enabled', {\n\t\tget() {\n\t\t\treturn logger.enabled;\n\t\t}\n\t});\n\tObject.defineProperty(logFn, 'once', {\n\t\tget() {\n\t\t\treturn once;\n\t\t}\n\t});\n\treturn logFn;\n}\n\nexport const log = {\n\tdebug: createLogger('debug'),\n\tinfo: createLogger('info'),\n\twarn: createLogger('warn'),\n\terror: createLogger('error'),\n\tsetLevel\n};\n\nexport type SvelteWarningsMessage = {\n\tid: string;\n\tfilename: string;\n\tnormalizedFilename: string;\n\ttimestamp: number;\n\twarnings: Warning[]; // allWarnings filtered by warnings where onwarn did not call the default handler\n\tallWarnings: Warning[]; // includes warnings filtered by onwarn and our extra vite plugin svelte warnings\n\trawWarnings: Warning[]; // raw compiler output\n};\n\nexport function logCompilerWarnings(\n\tsvelteRequest: SvelteRequest,\n\twarnings: Warning[],\n\toptions: ResolvedOptions\n) {\n\tconst { emitCss, onwarn, isBuild } = options;\n\tconst sendViaWS = !isBuild && options.experimental?.sendWarningsToBrowser;\n\tlet warn = isBuild ? warnBuild : warnDev;\n\tconst handledByDefaultWarn: Warning[] = [];\n\tconst notIgnored = warnings?.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss));\n\tconst extra = buildExtraWarnings(warnings, isBuild);\n\tconst allWarnings = [...notIgnored, ...extra];\n\tif (sendViaWS) {\n\t\tconst _warn = warn;\n\t\twarn = (w: Warning) => {\n\t\t\thandledByDefaultWarn.push(w);\n\t\t\t_warn(w);\n\t\t};\n\t}\n\tallWarnings.forEach((warning) => {\n\t\tif (onwarn) {\n\t\t\tonwarn(warning, warn);\n\t\t} else {\n\t\t\twarn(warning);\n\t\t}\n\t});\n\tif (sendViaWS) {\n\t\tconst message: SvelteWarningsMessage = {\n\t\t\tid: svelteRequest.id,\n\t\t\tfilename: svelteRequest.filename,\n\t\t\tnormalizedFilename: svelteRequest.normalizedFilename,\n\t\t\ttimestamp: svelteRequest.timestamp,\n\t\t\twarnings: handledByDefaultWarn, // allWarnings filtered by warnings where onwarn did not call the default handler\n\t\t\tallWarnings, // includes warnings filtered by onwarn and our extra vite plugin svelte warnings\n\t\t\trawWarnings: warnings // raw compiler output\n\t\t};\n\t\tlog.debug(`sending svelte:warnings message for ${svelteRequest.normalizedFilename}`);\n\t\toptions.server?.ws?.send('svelte:warnings', message);\n\t}\n}\n\nfunction ignoreCompilerWarning(\n\twarning: Warning,\n\tisBuild: boolean,\n\temitCss: boolean | undefined\n): boolean {\n\treturn (\n\t\t(!emitCss && warning.code === 'css-unused-selector') || // same as rollup-plugin-svelte\n\t\t(!isBuild && isNoScopableElementWarning(warning))\n\t);\n}\n\nfunction isNoScopableElementWarning(warning: Warning) {\n\t// see https://github.com/sveltejs/vite-plugin-svelte/issues/153\n\treturn warning.code === 'css-unused-selector' && warning.message.includes('\"*\"');\n}\n\nfunction buildExtraWarnings(warnings: Warning[], isBuild: boolean): Warning[] {\n\tconst extraWarnings = [];\n\tif (!isBuild) {\n\t\tconst noScopableElementWarnings = warnings.filter((w) => isNoScopableElementWarning(w));\n\t\tif (noScopableElementWarnings.length > 0) {\n\t\t\t// in case there are multiple, use last one as that is the one caused by our *{} rule\n\t\t\tconst noScopableElementWarning =\n\t\t\t\tnoScopableElementWarnings[noScopableElementWarnings.length - 1];\n\t\t\textraWarnings.push({\n\t\t\t\t...noScopableElementWarning,\n\t\t\t\tcode: 'vite-plugin-svelte-css-no-scopable-elements',\n\t\t\t\tmessage: `No scopable elements found in template. If you're using global styles in the style tag, you should move it into an external stylesheet file and import it in JS. See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#where-should-i-put-my-global-styles.`\n\t\t\t});\n\t\t}\n\t}\n\treturn extraWarnings;\n}\n\nfunction warnDev(w: Warning) {\n\tlog.info.enabled && log.info(buildExtendedLogMessage(w));\n}\n\nfunction warnBuild(w: Warning) {\n\tlog.warn.enabled && log.warn(buildExtendedLogMessage(w), w.frame);\n}\n\nexport function buildExtendedLogMessage(w: Warning) {\n\tconst parts = [];\n\tif (w.filename) {\n\t\tparts.push(w.filename);\n\t}\n\tif (w.start) {\n\t\tparts.push(':', w.start.line, ':', w.start.column);\n\t}\n\tif (w.message) {\n\t\tif (parts.length > 0) {\n\t\t\tparts.push(' ');\n\t\t}\n\t\tparts.push(w.message);\n\t}\n\treturn parts.join('');\n}\n","import { ModuleNode, HmrContext } from 'vite';\nimport { Code, CompileData } from './utils/compile';\nimport { log, logCompilerWarnings } from './utils/log';\nimport { SvelteRequest } from './utils/id';\nimport { VitePluginSvelteCache } from './utils/vite-plugin-svelte-cache';\nimport { ResolvedOptions } from './utils/options';\n\n/**\n * Vite-specific HMR handling\n */\nexport async function handleHotUpdate(\n\tcompileSvelte: Function,\n\tctx: HmrContext,\n\tsvelteRequest: SvelteRequest,\n\tcache: VitePluginSvelteCache,\n\toptions: ResolvedOptions\n): Promise {\n\tif (!cache.has(svelteRequest)) {\n\t\t// file hasn't been requested yet (e.g. async component)\n\t\tlog.debug(`handleHotUpdate called before initial transform for ${svelteRequest.id}`);\n\t\treturn;\n\t}\n\tconst { read, server } = ctx;\n\n\tconst cachedJS = cache.getJS(svelteRequest);\n\tconst cachedCss = cache.getCSS(svelteRequest);\n\n\tconst content = await read();\n\tlet compileData: CompileData;\n\ttry {\n\t\tcompileData = await compileSvelte(svelteRequest, content, options);\n\t\tcache.update(compileData);\n\t} catch (e) {\n\t\tcache.setError(svelteRequest, e);\n\t\tthrow e;\n\t}\n\n\tconst affectedModules = new Set();\n\n\tconst cssModule = server.moduleGraph.getModuleById(svelteRequest.cssId);\n\tconst mainModule = server.moduleGraph.getModuleById(svelteRequest.id);\n\tconst cssUpdated = cssModule && cssChanged(cachedCss, compileData.compiled.css);\n\tif (cssUpdated) {\n\t\tlog.debug(`handleHotUpdate css changed for ${svelteRequest.cssId}`);\n\t\taffectedModules.add(cssModule);\n\t}\n\tconst jsUpdated =\n\t\tmainModule && jsChanged(cachedJS, compileData.compiled.js, svelteRequest.filename);\n\tif (jsUpdated) {\n\t\tlog.debug(`handleHotUpdate js changed for ${svelteRequest.id}`);\n\t\taffectedModules.add(mainModule);\n\t}\n\n\tif (!jsUpdated) {\n\t\t// transform won't be called, log warnings here\n\t\tlogCompilerWarnings(svelteRequest, compileData.compiled.warnings, options);\n\t}\n\n\tconst result = [...affectedModules].filter(Boolean) as ModuleNode[];\n\n\t// TODO is this enough? see also: https://github.com/vitejs/vite/issues/2274\n\tconst ssrModulesToInvalidate = result.filter((m) => !!m.ssrTransformResult);\n\tif (ssrModulesToInvalidate.length > 0) {\n\t\tlog.debug(`invalidating modules ${ssrModulesToInvalidate.map((m) => m.id).join(', ')}`);\n\t\tssrModulesToInvalidate.forEach((moduleNode) => server.moduleGraph.invalidateModule(moduleNode));\n\t}\n\tif (result.length > 0) {\n\t\tlog.debug(\n\t\t\t`handleHotUpdate for ${svelteRequest.id} result: ${result.map((m) => m.id).join(', ')}`\n\t\t);\n\t}\n\treturn result;\n}\n\nfunction cssChanged(prev?: Code, next?: Code): boolean {\n\treturn !isCodeEqual(prev?.code, next?.code);\n}\n\nfunction jsChanged(prev?: Code, next?: Code, filename?: string): boolean {\n\tconst prevJs = prev?.code;\n\tconst nextJs = next?.code;\n\tconst isStrictEqual = isCodeEqual(prevJs, nextJs);\n\tif (isStrictEqual) {\n\t\treturn false;\n\t}\n\tconst isLooseEqual = isCodeEqual(normalizeJsCode(prevJs), normalizeJsCode(nextJs));\n\tif (!isStrictEqual && isLooseEqual) {\n\t\tlog.warn(\n\t\t\t`ignoring compiler output js change for ${filename} as it is equal to previous output after normalization`\n\t\t);\n\t}\n\treturn !isLooseEqual;\n}\n\nfunction isCodeEqual(prev?: string, next?: string): boolean {\n\tif (!prev && !next) {\n\t\treturn true;\n\t}\n\tif ((!prev && next) || (prev && !next)) {\n\t\treturn false;\n\t}\n\treturn prev === next;\n}\n\n/**\n * remove code that only changes metadata and does not require a js update for the component to keep working\n *\n * 1) add_location() calls. These add location metadata to elements, only useful for tooling like sapper studio\n * 2) ... maybe more (or less) in the future\n * @param code\n */\nfunction normalizeJsCode(code?: string): string | undefined {\n\tif (!code) {\n\t\treturn code;\n\t}\n\treturn code.replace(/\\s*\\badd_location\\s*\\([^)]*\\)\\s*;?/g, '');\n}\n","import { CompileOptions, ResolvedOptions } from './options';\nimport { compile, preprocess, walk } from 'svelte/compiler';\n// @ts-ignore\nimport { createMakeHot } from 'svelte-hmr';\nimport { SvelteRequest } from './id';\nimport { safeBase64Hash } from './hash';\nimport { log } from './log';\n\nconst scriptLangRE = /