{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import * as babel from '@babel/core';\nimport solid from 'babel-preset-solid';\nimport { readFileSync } from 'fs';\nimport { mergeAndConcat } from 'merge-anything';\nimport { createRequire } from 'module';\nimport solidRefresh from 'solid-refresh/babel';\nimport type { Alias, AliasOptions, FilterPattern, Plugin } from 'vite';\nimport { createFilter, version } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nconst require = createRequire(import.meta.url);\n\nconst runtimePublicPath = '/@solid-refresh';\nconst runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');\nconst runtimeCode = readFileSync(runtimeFilePath, 'utf-8');\n\nconst viteVersionMajor = +version.split('.')[0];\nconst isVite6 = viteVersionMajor >= 6;\nconst isVite8 = viteVersionMajor >= 8;\n\n/** Possible options for the extensions property */\nexport interface ExtensionOptions {\n  typescript?: boolean;\n}\n\n/** Configuration options for vite-plugin-solid. */\nexport interface Options {\n  /**\n   * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n   * the plugin should operate on.\n   */\n  include?: FilterPattern;\n  /**\n   * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n   * to be ignored by the plugin.\n   */\n  exclude?: FilterPattern;\n  /**\n   * This will inject solid-js/dev in place of solid-js in dev mode. Has no\n   * effect in prod. If set to `false`, it won't inject it in dev. This is\n   * useful for extra logs and debugging.\n   *\n   * @default true\n   */\n  dev?: boolean;\n  /**\n   * This will force SSR code in the produced files.\n   *\n   * @default false\n   */\n  ssr?: boolean;\n\n  /**\n   * This will inject HMR runtime in dev mode. Has no effect in prod. If\n   * set to `false`, it won't inject the runtime in dev.\n   *\n   * @default true\n   */\n  hot?: boolean;\n  /**\n   * This registers additional extensions that should be processed by\n   * vite-plugin-solid.\n   *\n   * @default undefined\n   */\n  extensions?: (string | [string, ExtensionOptions])[];\n  /**\n   * Pass any additional babel transform options. They will be merged with\n   * the transformations required by Solid.\n   *\n   * @default {}\n   */\n  babel?:\n    | babel.TransformOptions\n    | ((source: string, id: string, ssr: boolean) => babel.TransformOptions)\n    | ((source: string, id: string, ssr: boolean) => Promise<babel.TransformOptions>);\n  /**\n   * Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).\n   * They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25).\n   *\n   * @default {}\n   */\n  solid?: {\n    /**\n     * Remove unnecessary closing tags from template strings. More info here:\n     * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates\n     *\n     * @default false\n     */\n    omitNestedClosingTags?: boolean;\n\n    /**\n     * Remove the last closing tag from template strings. Enabled by default even when `omitNestedClosingTags` is disabled.\n     * Can be disabled for compatibility for some browser-like environments.\n     *\n     * @default true\n     */\n    omitLastClosingTag?: boolean;\n\n    /**\n     * Remove unnecessary quotes from template strings.\n     * Can be disabled for compatibility for some browser-like environments.\n     *\n     * @default true\n     */\n    omitQuotes?: boolean;\n\n    /**\n     * The name of the runtime module to import the methods from.\n     *\n     * @default \"solid-js/web\"\n     */\n    moduleName?: string;\n\n    /**\n     * The output mode of the compiler.\n     * Can be:\n     * - \"dom\" is standard output\n     * - \"ssr\" is for server side rendering of strings.\n     * - \"universal\" is for using custom renderers from solid-js/universal\n     *\n     * @default \"dom\"\n     */\n    generate?: 'ssr' | 'dom' | 'universal';\n\n    /**\n     * Indicate whether the output should contain hydratable markers.\n     *\n     * @default false\n     */\n    hydratable?: boolean;\n\n    /**\n     * Boolean to indicate whether to enable automatic event delegation on camelCase.\n     *\n     * @default true\n     */\n    delegateEvents?: boolean;\n\n    /**\n     * Boolean indicates whether smart conditional detection should be used.\n     * This optimizes simple boolean expressions and ternaries in JSX.\n     *\n     * @default true\n     */\n    wrapConditionals?: boolean;\n\n    /**\n     * Boolean indicates whether to set current render context on Custom Elements and slots.\n     * Useful for seemless Context API with Web Components.\n     *\n     * @default true\n     */\n    contextToCustomElements?: boolean;\n\n    /**\n     * Array of Component exports from module, that aren't included by default with the library.\n     * This plugin will automatically import them if it comes across them in the JSX.\n     *\n     * @default [\"For\",\"Show\",\"Switch\",\"Match\",\"Suspense\",\"SuspenseList\",\"Portal\",\"Index\",\"Dynamic\",\"ErrorBoundary\"]\n     */\n    builtIns?: string[];\n  };\n}\n\nfunction getExtension(filename: string): string {\n  const index = filename.lastIndexOf('.');\n  return index < 0 ? '' : filename.substring(index).replace(/\\?.+$/, '');\n}\nfunction containsSolidField(fields: Record<string, any>) {\n  const keys = Object.keys(fields);\n  for (let i = 0; i < keys.length; i++) {\n    const key = keys[i];\n    if (key === 'solid') return true;\n    if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key]))\n      return true;\n  }\n  return false;\n}\n\nfunction getJestDomExport(setupFiles: string[]) {\n  return setupFiles?.some((path) => /jest-dom/.test(path))\n    ? undefined\n    : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(\n        (path) => {\n          try {\n            require.resolve(path);\n            return true;\n          } catch (e) {\n            return false;\n          }\n        },\n      );\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n  const filter = createFilter(options.include, options.exclude);\n\n  let needHmr = false;\n  let replaceDev = false;\n  let projectRoot = process.cwd();\n  let isTestMode = false;\n  let solidPkgsConfig: Awaited<ReturnType<typeof crawlFrameworkPkgs>>;\n\n  return {\n    name: 'solid',\n    enforce: 'pre',\n\n    async config(userConfig, { command }) {\n      // We inject the dev mode only if the user explicitly wants it or if we are in dev (serve) mode\n      replaceDev = options.dev === true || (options.dev !== false && command === 'serve');\n      projectRoot = userConfig.root;\n      isTestMode = userConfig.mode === 'test';\n\n      if (!userConfig.resolve) userConfig.resolve = {};\n      userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);\n\n      solidPkgsConfig = await crawlFrameworkPkgs({\n        viteUserConfig: userConfig,\n        root: projectRoot || process.cwd(),\n        isBuild: command === 'build',\n        isFrameworkPkgByJson(pkgJson) {\n          return containsSolidField(pkgJson.exports || {});\n        },\n      });\n\n      // fix for bundling dev in production\n      const nestedDeps = replaceDev\n        ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h']\n        : [];\n\n      const userTest = (userConfig as any).test ?? {};\n      const test = {} as any;\n      if (userConfig.mode === 'test') {\n        // to simplify the processing of the config, we normalize the setupFiles to an array\n        const userSetupFiles: string[] =\n          typeof userTest.setupFiles === 'string'\n            ? [userTest.setupFiles]\n            : userTest.setupFiles || [];\n\n        if (!userTest.environment && !options.ssr) {\n          test.environment = 'jsdom';\n        }\n\n        if (\n          !userTest.server?.deps?.external?.find((item: string | RegExp) =>\n            /solid-js/.test(item.toString()),\n          )\n        ) {\n          test.server = { deps: { external: [/solid-js/] } };\n        }\n        if (!userTest.browser?.enabled) {\n          // vitest browser mode already has bundled jest-dom assertions\n          // https://main.vitest.dev/guide/browser/assertion-api.html#assertion-api\n          const jestDomImport = getJestDomExport(userSetupFiles);\n          if (jestDomImport) {\n            test.setupFiles = [jestDomImport];\n          }\n        }\n      }\n\n      return {\n        /**\n         * We only need esbuild on .ts or .js files.\n         * .tsx & .jsx files are handled by us\n         */\n        // esbuild: { include: /\\.ts$/ },\n        resolve: {\n          conditions: isVite6\n            ? undefined\n            : [\n                'solid',\n                ...(replaceDev ? ['development'] : []),\n                ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []),\n              ],\n          dedupe: nestedDeps,\n          alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n        },\n        optimizeDeps: {\n          include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],\n          exclude: solidPkgsConfig.optimizeDeps.exclude,\n          // Vite 8+ uses Rolldown for dependency scanning. Rolldown defaults to\n          // React's automatic JSX runtime for .tsx files, injecting a\n          // react/jsx-dev-runtime import. Tell it to preserve JSX as-is since\n          // this plugin handles JSX transformation via babel-preset-solid.\n          ...(isVite8\n            ? { rolldownOptions: { transform: { jsx: 'preserve' as const } } }\n            : {}),\n        },\n        ...(!isVite6 ? { ssr: solidPkgsConfig.ssr } : {}),\n        ...(test.server ? { test } : {}),\n      };\n    },\n\n    // @ts-ignore This hook only works in Vite 6\n    async configEnvironment(name, config, opts) {\n      config.resolve ??= {};\n      // Emulate Vite default fallback for `resolve.conditions` if not set\n      if (config.resolve.conditions == null) {\n        // @ts-ignore These exports only exist in Vite 6\n        const { defaultClientConditions, defaultServerConditions } = await import('vite');\n        if (config.consumer === 'client' || name === 'client' || opts.isSsrTargetWebworker) {\n          config.resolve.conditions = [...defaultClientConditions];\n        } else {\n          config.resolve.conditions = [...defaultServerConditions];\n        }\n      }\n      config.resolve.conditions = [\n        'solid',\n        ...(replaceDev ? ['development'] : []),\n        ...(isTestMode && !opts.isSsrTargetWebworker && !options.ssr ? ['browser'] : []),\n        ...config.resolve.conditions,\n      ];\n\n      // Set resolve.noExternal and resolve.external for SSR environment (Vite 6+)\n      // Only set resolve.external if noExternal is not true (to avoid conflicts with plugins like Cloudflare)\n      if (isVite6 && name === 'ssr' && solidPkgsConfig) {\n        if (config.resolve.noExternal !== true) {\n          config.resolve.noExternal = [\n            ...(Array.isArray(config.resolve.noExternal) ? config.resolve.noExternal : []),\n            ...solidPkgsConfig.ssr.noExternal,\n          ];\n          config.resolve.external = [\n            ...(Array.isArray(config.resolve.external) ? config.resolve.external : []),\n            ...solidPkgsConfig.ssr.external,\n          ];\n        }\n      }\n    },\n\n    configResolved(config) {\n      needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;\n    },\n\n    resolveId(id) {\n      if (id === runtimePublicPath) return id;\n    },\n\n    load(id) {\n      if (id === runtimePublicPath) return runtimeCode;\n    },\n\n    async transform(source, id, transformOptions) {\n      const isSsr = transformOptions && transformOptions.ssr;\n      const currentFileExtension = getExtension(id);\n\n      const extensionsToWatch = options.extensions || [];\n      const allExtensions = extensionsToWatch.map((extension) =>\n        // An extension can be a string or a tuple [extension, options]\n        typeof extension === 'string' ? extension : extension[0],\n      );\n\n      if (!filter(id)) {\n        return null;\n      }\n\n      id = id.replace(/\\?.*$/, '');\n\n      if (!(/\\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {\n        return null;\n      }\n\n      const inNodeModules = /node_modules/.test(id);\n\n      let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n      if (options.ssr) {\n        if (isSsr) {\n          solidOptions = { generate: 'ssr', hydratable: true };\n        } else {\n          solidOptions = { generate: 'dom', hydratable: true };\n        }\n      } else {\n        solidOptions = { generate: 'dom', hydratable: false };\n      }\n\n      // We need to know if the current file extension has a typescript options tied to it\n      const shouldBeProcessedWithTypescript =\n        /\\.[mc]?tsx$/i.test(id) ||\n        extensionsToWatch.some((extension) => {\n          if (typeof extension === 'string') {\n            return extension.includes('tsx');\n          }\n\n          const [extensionName, extensionOptions] = extension;\n          if (extensionName !== currentFileExtension) return false;\n\n          return extensionOptions.typescript;\n        });\n      const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = [\n        'jsx',\n      ];\n\n      if (shouldBeProcessedWithTypescript) {\n        plugins.push('typescript');\n      }\n\n      const opts: babel.TransformOptions = {\n        root: projectRoot,\n        filename: id,\n        sourceFileName: id,\n        presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],\n        plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n        ast: false,\n        sourceMaps: true,\n        configFile: false,\n        babelrc: false,\n        parserOpts: {\n          plugins,\n        },\n      };\n\n      // Default value for babel user options\n      let babelUserOptions: babel.TransformOptions = {};\n\n      if (options.babel) {\n        if (typeof options.babel === 'function') {\n          const babelOptions = options.babel(source, id, isSsr);\n          babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;\n        } else {\n          babelUserOptions = options.babel;\n        }\n      }\n\n      const babelOptions = mergeAndConcat(babelUserOptions, opts) as babel.TransformOptions;\n\n      const { code, map } = await babel.transformAsync(source, babelOptions);\n\n      return { code, map };\n    },\n  };\n}\n\n/**\n * This basically normalize all aliases of the config into\n * the array format of the alias.\n *\n * eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]\n */\nfunction normalizeAliases(alias: AliasOptions = []): Alias[] {\n  return Array.isArray(alias)\n    ? alias\n    : Object.entries(alias).map(([find, replacement]) => ({ find, replacement }));\n}\n"],"names":["require","createRequire","import","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","viteVersionMajor","version","split","isVite6","isVite8","getExtension","filename","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","length","key","getJestDomExport","setupFiles","some","path","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","isTestMode","solidPkgsConfig","name","enforce","config","userConfig","command","dev","root","mode","alias","normalizeAliases","crawlFrameworkPkgs","viteUserConfig","isBuild","isFrameworkPkgByJson","pkgJson","exports","nestedDeps","userTest","userSetupFiles","environment","ssr","server","deps","external","item","toString","browser","enabled","jestDomImport","conditions","dedupe","replacement","optimizeDeps","rolldownOptions","transform","jsx","configEnvironment","opts","defaultClientConditions","defaultServerConditions","consumer","isSsrTargetWebworker","noExternal","Array","isArray","configResolved","hot","resolveId","id","load","source","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","plugins","push","sourceFileName","presets","solid","solidRefresh","bundler","ast","sourceMaps","configFile","babelrc","parserOpts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","entries"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAMA,SAAO,GAAGC,sBAAa,CAACC,2PAAe,CAAC;AAE9C,MAAMC,iBAAiB,GAAG,iBAAiB;AAC3C,MAAMC,eAAe,GAAGJ,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