vite-plugin-solid 2.11.10 → 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var babel = require('@babel/core');
4
6
  var solid = require('babel-preset-solid');
5
7
  var fs = require('fs');
6
8
  var mergeAnything = require('merge-anything');
7
9
  var module$1 = require('module');
8
10
  var solidRefresh = require('solid-refresh/babel');
11
+ var path = require('path');
9
12
  var vite = require('vite');
10
13
  var vitefu = require('vitefu');
11
14
 
@@ -29,6 +32,62 @@ function _interopNamespaceDefault(e) {
29
32
 
30
33
  var babel__namespace = /*#__PURE__*/_interopNamespaceDefault(babel);
31
34
 
35
+ const LAZY_PLACEHOLDER_PREFIX = '__SOLID_LAZY_MODULE__:';
36
+
37
+ /**
38
+ * Detects whether a CallExpression argument is `() => import("specifier")`
39
+ * and returns the specifier string if so.
40
+ */
41
+ function extractDynamicImportSpecifier(node) {
42
+ if (node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression') return null;
43
+ let callExpr = null;
44
+ if (node.body.type === 'CallExpression') {
45
+ callExpr = node.body;
46
+ } else if (node.body.type === 'BlockStatement' && node.body.body.length === 1 && node.body.body[0].type === 'ReturnStatement' && node.body.body[0].argument?.type === 'CallExpression') {
47
+ callExpr = node.body.body[0].argument;
48
+ }
49
+ if (!callExpr) return null;
50
+ if (callExpr.callee.type !== 'Import') return null;
51
+ if (callExpr.arguments.length !== 1) return null;
52
+ const arg = callExpr.arguments[0];
53
+ if (arg.type !== 'StringLiteral') return null;
54
+ return arg.value;
55
+ }
56
+
57
+ /**
58
+ * Babel plugin that detects `lazy(() => import("specifier"))` calls
59
+ * and injects a placeholder as the second argument. The placeholder
60
+ * is resolved to a real path by the Vite transform hook using this.resolve().
61
+ */
62
+ function lazyModuleUrlPlugin() {
63
+ return {
64
+ name: 'solid-lazy-module-url',
65
+ visitor: {
66
+ CallExpression(nodePath, state) {
67
+ if (!state.filename) return;
68
+ const {
69
+ node
70
+ } = nodePath;
71
+ if (node.callee.type !== 'Identifier' || node.callee.name !== 'lazy') return;
72
+ const binding = nodePath.scope.getBinding('lazy');
73
+ if (!binding || binding.kind !== 'module') return;
74
+ const bindingPath = binding.path;
75
+ if (bindingPath.type !== 'ImportSpecifier' || bindingPath.parent.type !== 'ImportDeclaration') return;
76
+ const source = bindingPath.parent.source.value;
77
+ if (source !== 'solid-js') return;
78
+ if (node.arguments.length >= 2) return;
79
+ if (node.arguments.length !== 1) return;
80
+ const specifier = extractDynamicImportSpecifier(node.arguments[0]);
81
+ if (!specifier) return;
82
+ node.arguments.push({
83
+ type: 'StringLiteral',
84
+ value: LAZY_PLACEHOLDER_PREFIX + specifier
85
+ });
86
+ }
87
+ }
88
+ };
89
+ }
90
+
32
91
  const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
33
92
  const runtimePublicPath = '/@solid-refresh';
34
93
  const runtimeFilePath = require$1.resolve('solid-refresh/dist/solid-refresh.mjs');
@@ -77,7 +136,7 @@ function solidPlugin(options = {}) {
77
136
  }) {
78
137
  // We inject the dev mode only if the user explicitly wants it or if we are in dev (serve) mode
79
138
  replaceDev = options.dev === true || options.dev !== false && command === 'serve';
80
- projectRoot = userConfig.root;
139
+ projectRoot = userConfig.root || projectRoot;
81
140
  isTestMode = userConfig.mode === 'test';
82
141
  if (!userConfig.resolve) userConfig.resolve = {};
83
142
  userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
@@ -91,7 +150,7 @@ function solidPlugin(options = {}) {
91
150
  });
92
151
 
93
152
  // fix for bundling dev in production
94
- const nestedDeps = replaceDev ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] : [];
153
+ const nestedDeps = replaceDev ? ['solid-js', '@solidjs/web'] : [];
95
154
  const userTest = userConfig.test ?? {};
96
155
  const test = {};
97
156
  if (userConfig.mode === 'test') {
@@ -170,7 +229,7 @@ function solidPlugin(options = {}) {
170
229
  }
171
230
  },
172
231
  configResolved(config) {
173
- needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;
232
+ needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false && !options.refresh?.disabled;
174
233
  },
175
234
  resolveId(id) {
176
235
  if (id === runtimePublicPath) return id;
@@ -222,7 +281,7 @@ function solidPlugin(options = {}) {
222
281
  if (extensionName !== currentFileExtension) return false;
223
282
  return extensionOptions.typescript;
224
283
  });
225
- const plugins = ['jsx'];
284
+ const plugins = ['jsx', 'decorators'];
226
285
  if (shouldBeProcessedWithTypescript) {
227
286
  plugins.push('typescript');
228
287
  }
@@ -232,11 +291,18 @@ function solidPlugin(options = {}) {
232
291
  sourceFileName: id,
233
292
  presets: [[solid, {
234
293
  ...solidOptions,
294
+ dev: replaceDev,
235
295
  ...(options.solid || {})
236
296
  }]],
237
- plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
238
- bundler: 'vite'
239
- }]] : [],
297
+ plugins: [[lazyModuleUrlPlugin], ...(needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
298
+ ...(options.refresh || {}),
299
+ bundler: 'vite',
300
+ fixRender: true,
301
+ // TODO unfortunately, even with SSR enabled for refresh
302
+ // it still doesn't work, so now we have to disable
303
+ // this config
304
+ jsx: false
305
+ }]] : [])],
240
306
  ast: false,
241
307
  sourceMaps: true,
242
308
  configFile: false,
@@ -250,20 +316,43 @@ function solidPlugin(options = {}) {
250
316
  let babelUserOptions = {};
251
317
  if (options.babel) {
252
318
  if (typeof options.babel === 'function') {
253
- const babelOptions = options.babel(source, id, isSsr);
319
+ const babelOptions = options.babel(source, id, !!isSsr);
254
320
  babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
255
321
  } else {
256
322
  babelUserOptions = options.babel;
257
323
  }
258
324
  }
259
325
  const babelOptions = mergeAnything.mergeAndConcat(babelUserOptions, opts);
260
- const {
261
- code,
262
- map
263
- } = await babel__namespace.transformAsync(source, babelOptions);
326
+ const result = await babel__namespace.transformAsync(source, babelOptions);
327
+ if (!result) {
328
+ return undefined;
329
+ }
330
+ let code = result.code || '';
331
+
332
+ // Resolve lazy() moduleUrl placeholders using Vite's resolver
333
+ const placeholderRe = new RegExp('"' + LAZY_PLACEHOLDER_PREFIX + '([^"]+)"', 'g');
334
+ let match;
335
+ const resolutions = [];
336
+ while ((match = placeholderRe.exec(code)) !== null) {
337
+ const specifier = match[1];
338
+ const resolved = await this.resolve(specifier, id);
339
+ if (resolved) {
340
+ const cleanId = resolved.id.split('?')[0];
341
+ resolutions.push({
342
+ placeholder: match[0],
343
+ resolved: '"' + path.relative(projectRoot, cleanId) + '"'
344
+ });
345
+ }
346
+ }
347
+ for (const {
348
+ placeholder,
349
+ resolved
350
+ } of resolutions) {
351
+ code = code.replace(placeholder, resolved);
352
+ }
264
353
  return {
265
354
  code,
266
- map
355
+ map: result.map
267
356
  };
268
357
  }
269
358
  };
@@ -281,6 +370,35 @@ function normalizeAliases(alias = []) {
281
370
  replacement
282
371
  }));
283
372
  }
373
+ let _manifest;
374
+
375
+ /**
376
+ * Returns the Vite asset manifest for SSR.
377
+ * In production, reads and caches the manifest JSON from `manifestPath`.
378
+ * In development (file not found), returns a proxy that maps each moduleUrl
379
+ * to its dev server path, so lazy() asset resolution works without a build.
380
+ */
381
+ function getManifest(manifestPath) {
382
+ if (_manifest) return _manifest;
383
+ if (manifestPath) {
384
+ try {
385
+ _manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
386
+ return _manifest;
387
+ } catch {
388
+ // File doesn't exist — dev mode, fall through
389
+ }
390
+ }
391
+ _manifest = new Proxy({}, {
392
+ get(_, key) {
393
+ if (typeof key !== 'string') return undefined;
394
+ return {
395
+ file: '/' + key
396
+ };
397
+ }
398
+ });
399
+ return _manifest;
400
+ }
284
401
 
285
- module.exports = solidPlugin;
402
+ exports.default = solidPlugin;
403
+ exports.getManifest = getManifest;
286
404
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"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 isVite6 = +version.split('.')[0] >= 6;\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 },\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","isVite6","version","split","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","configEnvironment","opts","defaultClientConditions","defaultServerConditions","consumer","isSsrTargetWebworker","noExternal","Array","isArray","configResolved","hot","resolveId","id","load","transform","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,SAAO,CAACK,OAAO,CAAC,sCAAsC,CAAC;AAC/E,MAAMC,WAAW,GAAGC,eAAY,CAACH,eAAe,EAAE,OAAO,CAAC;AAE1D,MAAMI,OAAO,GAAG,CAACC,YAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;;AAE3C;;AAKA;;AA4IA,SAASC,YAAYA,CAACC,QAAgB,EAAU;AAC9C,EAAA,MAAMC,KAAK,GAAGD,QAAQ,CAACE,WAAW,CAAC,GAAG,CAAC;AACvC,EAAA,OAAOD,KAAK,GAAG,CAAC,GAAG,EAAE,GAAGD,QAAQ,CAACG,SAAS,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;AACxE;AACA,SAASC,kBAAkBA,CAACC,MAA2B,EAAE;AACvD,EAAA,M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AY,YAAYC,OAAO,GAAG,MAAMD,YAAY,GAAGA,YAAY;AACxF,SAAC,MAAM;UACLF,gBAAgB,GAAG1F,OAAO,CAAC2F,KAAK;AAClC;AACF;AAEA,MAAA,MAAMC,YAAY,GAAGE,4BAAc,CAACJ,gBAAgB,EAAE5C,IAAI,CAA2B;MAErF,MAAM;QAAEiD,IAAI;AAAE5B,QAAAA;OAAK,GAAG,MAAMwB,gBAAK,CAACK,cAAc,CAACpC,MAAM,EAAEgC,YAAY,CAAC;MAEtE,OAAO;QAAEG,IAAI;AAAE5B,QAAAA;OAAK;AACtB;GACD;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS9C,gBAAgBA,CAACD,KAAmB,GAAG,EAAE,EAAW;EAC3D,OAAOgC,KAAK,CAACC,OAAO,CAACjC,KAAK,CAAC,GACvBA,KAAK,GACLjC,MAAM,CAAC8G,OAAO,CAAC7E,KAAK,CAAC,CAAC+C,GAAG,CAAC,CAAC,CAACtE,IAAI,EAAE8C,WAAW,CAAC,MAAM;IAAE9C,IAAI;AAAE8C,IAAAA;AAAY,GAAC,CAAC,CAAC;AACjF;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/lazy-module-url.ts","../../src/index.ts"],"sourcesContent":["import type { PluginObj, types as t } from '@babel/core';\n\nexport const LAZY_PLACEHOLDER_PREFIX = '__SOLID_LAZY_MODULE__:';\n\n/**\n * Detects whether a CallExpression argument is `() => import(\"specifier\")`\n * and returns the specifier string if so.\n */\nfunction extractDynamicImportSpecifier(node: t.Node): string | null {\n if (node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression') return null;\n\n let callExpr: t.CallExpression | null = null;\n if (node.body.type === 'CallExpression') {\n callExpr = node.body;\n } else if (\n node.body.type === 'BlockStatement' &&\n node.body.body.length === 1 &&\n node.body.body[0].type === 'ReturnStatement' &&\n node.body.body[0].argument?.type === 'CallExpression'\n ) {\n callExpr = node.body.body[0].argument;\n }\n if (!callExpr) return null;\n\n if (callExpr.callee.type !== 'Import') return null;\n if (callExpr.arguments.length !== 1) return null;\n\n const arg = callExpr.arguments[0];\n if (arg.type !== 'StringLiteral') return null;\n\n return arg.value;\n}\n\n/**\n * Babel plugin that detects `lazy(() => import(\"specifier\"))` calls\n * and injects a placeholder as the second argument. The placeholder\n * is resolved to a real path by the Vite transform hook using this.resolve().\n */\nexport default function lazyModuleUrlPlugin(): PluginObj {\n return {\n name: 'solid-lazy-module-url',\n visitor: {\n CallExpression(nodePath, state) {\n if (!state.filename) return;\n const { node } = nodePath;\n\n if (node.callee.type !== 'Identifier' || node.callee.name !== 'lazy') return;\n\n const binding = nodePath.scope.getBinding('lazy');\n if (!binding || binding.kind !== 'module') return;\n const bindingPath = binding.path;\n if (\n bindingPath.type !== 'ImportSpecifier' ||\n bindingPath.parent.type !== 'ImportDeclaration'\n )\n return;\n const source = (bindingPath.parent as t.ImportDeclaration).source.value;\n if (source !== 'solid-js') return;\n\n if (node.arguments.length >= 2) return;\n if (node.arguments.length !== 1) return;\n\n const specifier = extractDynamicImportSpecifier(node.arguments[0] as t.Node);\n if (!specifier) return;\n\n node.arguments.push({\n type: 'StringLiteral',\n value: LAZY_PLACEHOLDER_PREFIX + specifier,\n } as t.StringLiteral);\n },\n },\n };\n}\n","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';\n// TODO use proper path\nimport type { Options as RefreshOptions } from 'solid-refresh/babel';\nimport lazyModuleUrl, { LAZY_PLACEHOLDER_PREFIX } from './lazy-module-url.js';\nimport path from 'path';\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 isVite6 = +version.split('.')[0] >= 6;\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 * @deprecated use `refresh` instead\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 * Enable dev-mode compilation output. When true, the compiler emits\n * additional runtime checks (e.g. hydration mismatch assertions).\n * Automatically set to true during `vite dev` — override here to\n * force on or off.\n *\n * @default auto (true in dev, false in build)\n */\n dev?: boolean;\n };\n\n\n refresh: Omit<RefreshOptions & { disabled: boolean }, 'bundler' | 'fixRender' | 'jsx'>;\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 || projectRoot;\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', '@solidjs/web']\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 },\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 && !options.refresh?.disabled);\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 'decorators',\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, dev: replaceDev, ...(options.solid || {}) }]],\n plugins: [\n [lazyModuleUrl],\n ...(needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {\n ...(options.refresh || {}),\n bundler: 'vite',\n fixRender: true,\n // TODO unfortunately, even with SSR enabled for refresh\n // it still doesn't work, so now we have to disable\n // this config\n jsx: false,\n }]] : []),\n ],\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 result = await babel.transformAsync(source, babelOptions);\n if (!result) {\n return undefined;\n }\n\n let code = result.code || '';\n\n // Resolve lazy() moduleUrl placeholders using Vite's resolver\n const placeholderRe = new RegExp(\n '\"' + LAZY_PLACEHOLDER_PREFIX + '([^\"]+)\"',\n 'g',\n );\n let match;\n const resolutions: Array<{ placeholder: string; resolved: string }> = [];\n while ((match = placeholderRe.exec(code)) !== null) {\n const specifier = match[1];\n const resolved = await this.resolve(specifier, id);\n if (resolved) {\n const cleanId = resolved.id.split('?')[0];\n resolutions.push({\n placeholder: match[0],\n resolved: '\"' + path.relative(projectRoot, cleanId) + '\"',\n });\n }\n }\n for (const { placeholder, resolved } of resolutions) {\n code = code.replace(placeholder, resolved);\n }\n\n return { code, map: result.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\nexport type ViteManifest = Record<\n string,\n {\n file: string;\n css?: string[];\n isEntry?: boolean;\n isDynamicEntry?: boolean;\n imports?: string[];\n }\n>;\n\nlet _manifest: ViteManifest | undefined;\n\n/**\n * Returns the Vite asset manifest for SSR.\n * In production, reads and caches the manifest JSON from `manifestPath`.\n * In development (file not found), returns a proxy that maps each moduleUrl\n * to its dev server path, so lazy() asset resolution works without a build.\n */\nexport function getManifest(manifestPath?: string): ViteManifest {\n if (_manifest) return _manifest;\n if (manifestPath) {\n try {\n _manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n return _manifest!;\n } catch {\n // File doesn't exist — dev mode, fall through\n }\n }\n _manifest = new Proxy(\n {},\n {\n get(_, key) {\n if (typeof key !== 'string') return undefined;\n return { file: '/' + key };\n },\n },\n ) as ViteManifest;\n return _manifest;\n}\n"],"names":["LAZY_PLACEHOLDER_PREFIX","extractDynamicImportSpecifier","node","type","callExpr","body","length","argument","callee","arguments","arg","value","lazyModuleUrlPlugin","name","visitor","CallExpression","nodePath","state","filename","binding","scope","getBinding","kind","bindingPath","path","parent","source","specifier","push","require","createRequire","import","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","isVite6","version","split","getExtension","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","key","getJestDomExport","setupFiles","some","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","isTestMode","solidPkgsConfig","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","configEnvironment","opts","defaultClientConditions","defaultServerConditions","consumer","isSsrTargetWebworker","noExternal","Array","isArray","configResolved","hot","refresh","disabled","resolveId","id","load","transform","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","plugins","sourceFileName","presets","solid","lazyModuleUrl","solidRefresh","bundler","fixRender","jsx","ast","sourceMaps","configFile","babelrc","parserOpts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","result","transformAsync","code","placeholderRe","RegExp","match","resolutions","exec","resolved","cleanId","placeholder","relative","entries","_manifest","getManifest","manifestPath","JSON","parse","Proxy","get","_","file"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,uBAAuB,GAAG,wBAAwB;;AAE/D;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAACC,IAAY,EAAiB;AAClE,EAAA,IAAIA,IAAI,CAACC,IAAI,KAAK,yBAAyB,IAAID,IAAI,CAACC,IAAI,KAAK,oBAAoB,EAAE,OAAO,IAAI;EAE9F,IAAIC,QAAiC,GAAG,IAAI;AAC5C,EAAA,IAAIF,IAAI,CAACG,IAAI,CAACF,IAAI,KAAK,gBAAgB,EAAE;IACvCC,QAAQ,GAAGF,IAAI,CAACG,IAAI;GACrB,MAAM,IACLH,IAAI,CAACG,IAAI,CAACF,IAAI,KAAK,gBAAgB,IACnCD,IAAI,CAACG,IAAI,CAACA,IAAI,CAACC,MAAM,KAAK,CAAC,IAC3BJ,IAAI,CAACG,IAAI,CAACA,IAAI,CAAC,CAAC,CAAC,CAACF,IAAI,KAAK,iBAAiB,IAC5CD,IAAI,CAACG,IAAI,CAACA,IAAI,CAAC,CAAC,CAAC,CAACE,QAAQ,EAAEJ,IAAI,KAAK,gBAAgB,EACrD;IACAC,QAAQ,GAAGF,IAAI,CAACG,IAAI,CAACA,IAAI,CAAC,CAAC,CAAC,CAACE,QAAQ;AACvC;AACA,EAAA,IAAI,CAACH,QAAQ,EAAE,OAAO,IAAI;EAE1B,IAAIA,QAAQ,CAACI,MAAM,CAACL,IAAI,KAAK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AGA,IAAI,CAAClH,OAAO,CAAC0H,WAAW,EAAEF,QAAQ,CAAC;AAC5C;MAEA,OAAO;QAAEN,IAAI;QAAEhC,GAAG,EAAE8B,MAAM,CAAC9B;OAAK;AAClC;GACD;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS/C,gBAAgBA,CAACD,KAAmB,GAAG,EAAE,EAAW;EAC3D,OAAOgC,KAAK,CAACC,OAAO,CAACjC,KAAK,CAAC,GACvBA,KAAK,GACL9B,MAAM,CAACwH,OAAO,CAAC1F,KAAK,CAAC,CAACgD,GAAG,CAAC,CAAC,CAACtE,IAAI,EAAE6C,WAAW,CAAC,MAAM;IAAE7C,IAAI;AAAE6C,IAAAA;AAAY,GAAC,CAAC,CAAC;AACjF;AAaA,IAAIoE,SAAmC;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAACC,YAAqB,EAAgB;EAC/D,IAAIF,SAAS,EAAE,OAAOA,SAAS;AAC/B,EAAA,IAAIE,YAAY,EAAE;IAChB,IAAI;MACFF,SAAS,GAAGG,IAAI,CAACC,KAAK,CAACzI,eAAY,CAACuI,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3D,MAAA,OAAOF,SAAS;AAClB,KAAC,CAAC,MAAM;AACN;AAAA;AAEJ;AACAA,EAAAA,SAAS,GAAG,IAAIK,KAAK,CACnB,EAAE,EACF;AACEC,IAAAA,GAAGA,CAACC,CAAC,EAAE9H,GAAG,EAAE;AACV,MAAA,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE,OAAOK,SAAS;MAC7C,OAAO;QAAE0H,IAAI,EAAE,GAAG,GAAG/H;OAAK;AAC5B;AACF,GACF,CAAiB;AACjB,EAAA,OAAOuH,SAAS;AAClB;;;;;"}
@@ -4,9 +4,66 @@ import { readFileSync } from 'fs';
4
4
  import { mergeAndConcat } from 'merge-anything';
5
5
  import { createRequire } from 'module';
6
6
  import solidRefresh from 'solid-refresh/babel';
7
+ import path from 'path';
7
8
  import { version, createFilter } from 'vite';
8
9
  import { crawlFrameworkPkgs } from 'vitefu';
9
10
 
11
+ const LAZY_PLACEHOLDER_PREFIX = '__SOLID_LAZY_MODULE__:';
12
+
13
+ /**
14
+ * Detects whether a CallExpression argument is `() => import("specifier")`
15
+ * and returns the specifier string if so.
16
+ */
17
+ function extractDynamicImportSpecifier(node) {
18
+ if (node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression') return null;
19
+ let callExpr = null;
20
+ if (node.body.type === 'CallExpression') {
21
+ callExpr = node.body;
22
+ } else if (node.body.type === 'BlockStatement' && node.body.body.length === 1 && node.body.body[0].type === 'ReturnStatement' && node.body.body[0].argument?.type === 'CallExpression') {
23
+ callExpr = node.body.body[0].argument;
24
+ }
25
+ if (!callExpr) return null;
26
+ if (callExpr.callee.type !== 'Import') return null;
27
+ if (callExpr.arguments.length !== 1) return null;
28
+ const arg = callExpr.arguments[0];
29
+ if (arg.type !== 'StringLiteral') return null;
30
+ return arg.value;
31
+ }
32
+
33
+ /**
34
+ * Babel plugin that detects `lazy(() => import("specifier"))` calls
35
+ * and injects a placeholder as the second argument. The placeholder
36
+ * is resolved to a real path by the Vite transform hook using this.resolve().
37
+ */
38
+ function lazyModuleUrlPlugin() {
39
+ return {
40
+ name: 'solid-lazy-module-url',
41
+ visitor: {
42
+ CallExpression(nodePath, state) {
43
+ if (!state.filename) return;
44
+ const {
45
+ node
46
+ } = nodePath;
47
+ if (node.callee.type !== 'Identifier' || node.callee.name !== 'lazy') return;
48
+ const binding = nodePath.scope.getBinding('lazy');
49
+ if (!binding || binding.kind !== 'module') return;
50
+ const bindingPath = binding.path;
51
+ if (bindingPath.type !== 'ImportSpecifier' || bindingPath.parent.type !== 'ImportDeclaration') return;
52
+ const source = bindingPath.parent.source.value;
53
+ if (source !== 'solid-js') return;
54
+ if (node.arguments.length >= 2) return;
55
+ if (node.arguments.length !== 1) return;
56
+ const specifier = extractDynamicImportSpecifier(node.arguments[0]);
57
+ if (!specifier) return;
58
+ node.arguments.push({
59
+ type: 'StringLiteral',
60
+ value: LAZY_PLACEHOLDER_PREFIX + specifier
61
+ });
62
+ }
63
+ }
64
+ };
65
+ }
66
+
10
67
  const require = createRequire(import.meta.url);
11
68
  const runtimePublicPath = '/@solid-refresh';
12
69
  const runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');
@@ -55,7 +112,7 @@ function solidPlugin(options = {}) {
55
112
  }) {
56
113
  // We inject the dev mode only if the user explicitly wants it or if we are in dev (serve) mode
57
114
  replaceDev = options.dev === true || options.dev !== false && command === 'serve';
58
- projectRoot = userConfig.root;
115
+ projectRoot = userConfig.root || projectRoot;
59
116
  isTestMode = userConfig.mode === 'test';
60
117
  if (!userConfig.resolve) userConfig.resolve = {};
61
118
  userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
@@ -69,7 +126,7 @@ function solidPlugin(options = {}) {
69
126
  });
70
127
 
71
128
  // fix for bundling dev in production
72
- const nestedDeps = replaceDev ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] : [];
129
+ const nestedDeps = replaceDev ? ['solid-js', '@solidjs/web'] : [];
73
130
  const userTest = userConfig.test ?? {};
74
131
  const test = {};
75
132
  if (userConfig.mode === 'test') {
@@ -148,7 +205,7 @@ function solidPlugin(options = {}) {
148
205
  }
149
206
  },
150
207
  configResolved(config) {
151
- needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;
208
+ needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false && !options.refresh?.disabled;
152
209
  },
153
210
  resolveId(id) {
154
211
  if (id === runtimePublicPath) return id;
@@ -200,7 +257,7 @@ function solidPlugin(options = {}) {
200
257
  if (extensionName !== currentFileExtension) return false;
201
258
  return extensionOptions.typescript;
202
259
  });
203
- const plugins = ['jsx'];
260
+ const plugins = ['jsx', 'decorators'];
204
261
  if (shouldBeProcessedWithTypescript) {
205
262
  plugins.push('typescript');
206
263
  }
@@ -210,11 +267,18 @@ function solidPlugin(options = {}) {
210
267
  sourceFileName: id,
211
268
  presets: [[solid, {
212
269
  ...solidOptions,
270
+ dev: replaceDev,
213
271
  ...(options.solid || {})
214
272
  }]],
215
- plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
216
- bundler: 'vite'
217
- }]] : [],
273
+ plugins: [[lazyModuleUrlPlugin], ...(needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
274
+ ...(options.refresh || {}),
275
+ bundler: 'vite',
276
+ fixRender: true,
277
+ // TODO unfortunately, even with SSR enabled for refresh
278
+ // it still doesn't work, so now we have to disable
279
+ // this config
280
+ jsx: false
281
+ }]] : [])],
218
282
  ast: false,
219
283
  sourceMaps: true,
220
284
  configFile: false,
@@ -228,20 +292,43 @@ function solidPlugin(options = {}) {
228
292
  let babelUserOptions = {};
229
293
  if (options.babel) {
230
294
  if (typeof options.babel === 'function') {
231
- const babelOptions = options.babel(source, id, isSsr);
295
+ const babelOptions = options.babel(source, id, !!isSsr);
232
296
  babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
233
297
  } else {
234
298
  babelUserOptions = options.babel;
235
299
  }
236
300
  }
237
301
  const babelOptions = mergeAndConcat(babelUserOptions, opts);
238
- const {
239
- code,
240
- map
241
- } = await babel.transformAsync(source, babelOptions);
302
+ const result = await babel.transformAsync(source, babelOptions);
303
+ if (!result) {
304
+ return undefined;
305
+ }
306
+ let code = result.code || '';
307
+
308
+ // Resolve lazy() moduleUrl placeholders using Vite's resolver
309
+ const placeholderRe = new RegExp('"' + LAZY_PLACEHOLDER_PREFIX + '([^"]+)"', 'g');
310
+ let match;
311
+ const resolutions = [];
312
+ while ((match = placeholderRe.exec(code)) !== null) {
313
+ const specifier = match[1];
314
+ const resolved = await this.resolve(specifier, id);
315
+ if (resolved) {
316
+ const cleanId = resolved.id.split('?')[0];
317
+ resolutions.push({
318
+ placeholder: match[0],
319
+ resolved: '"' + path.relative(projectRoot, cleanId) + '"'
320
+ });
321
+ }
322
+ }
323
+ for (const {
324
+ placeholder,
325
+ resolved
326
+ } of resolutions) {
327
+ code = code.replace(placeholder, resolved);
328
+ }
242
329
  return {
243
330
  code,
244
- map
331
+ map: result.map
245
332
  };
246
333
  }
247
334
  };
@@ -259,6 +346,34 @@ function normalizeAliases(alias = []) {
259
346
  replacement
260
347
  }));
261
348
  }
349
+ let _manifest;
350
+
351
+ /**
352
+ * Returns the Vite asset manifest for SSR.
353
+ * In production, reads and caches the manifest JSON from `manifestPath`.
354
+ * In development (file not found), returns a proxy that maps each moduleUrl
355
+ * to its dev server path, so lazy() asset resolution works without a build.
356
+ */
357
+ function getManifest(manifestPath) {
358
+ if (_manifest) return _manifest;
359
+ if (manifestPath) {
360
+ try {
361
+ _manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
362
+ return _manifest;
363
+ } catch {
364
+ // File doesn't exist — dev mode, fall through
365
+ }
366
+ }
367
+ _manifest = new Proxy({}, {
368
+ get(_, key) {
369
+ if (typeof key !== 'string') return undefined;
370
+ return {
371
+ file: '/' + key
372
+ };
373
+ }
374
+ });
375
+ return _manifest;
376
+ }
262
377
 
263
- export { solidPlugin as default };
378
+ export { solidPlugin as default, getManifest };
264
379
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","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 isVite6 = +version.split('.')[0] >= 6;\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 },\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","meta","url","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","isVite6","version","split","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","configEnvironment","opts","defaultClientConditions","defaultServerConditions","consumer","isSsrTargetWebworker","noExternal","Array","isArray","configResolved","hot","resolveId","id","load","transform","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,OAAO,GAAGC,aAAa,CAACC,M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AAI,EAAE8C,WAAW,CAAC,MAAM;IAAE9C,IAAI;AAAE8C,IAAAA;AAAY,GAAC,CAAC,CAAC;AACjF;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/lazy-module-url.ts","../../src/index.ts"],"sourcesContent":["import type { PluginObj, types as t } from '@babel/core';\n\nexport const LAZY_PLACEHOLDER_PREFIX = '__SOLID_LAZY_MODULE__:';\n\n/**\n * Detects whether a CallExpression argument is `() => import(\"specifier\")`\n * and returns the specifier string if so.\n */\nfunction extractDynamicImportSpecifier(node: t.Node): string | null {\n if (node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression') return null;\n\n let callExpr: t.CallExpression | null = null;\n if (node.body.type === 'CallExpression') {\n callExpr = node.body;\n } else if (\n node.body.type === 'BlockStatement' &&\n node.body.body.length === 1 &&\n node.body.body[0].type === 'ReturnStatement' &&\n node.body.body[0].argument?.type === 'CallExpression'\n ) {\n callExpr = node.body.body[0].argument;\n }\n if (!callExpr) return null;\n\n if (callExpr.callee.type !== 'Import') return null;\n if (callExpr.arguments.length !== 1) return null;\n\n const arg = callExpr.arguments[0];\n if (arg.type !== 'StringLiteral') return null;\n\n return arg.value;\n}\n\n/**\n * Babel plugin that detects `lazy(() => import(\"specifier\"))` calls\n * and injects a placeholder as the second argument. The placeholder\n * is resolved to a real path by the Vite transform hook using this.resolve().\n */\nexport default function lazyModuleUrlPlugin(): PluginObj {\n return {\n name: 'solid-lazy-module-url',\n visitor: {\n CallExpression(nodePath, state) {\n if (!state.filename) return;\n const { node } = nodePath;\n\n if (node.callee.type !== 'Identifier' || node.callee.name !== 'lazy') return;\n\n const binding = nodePath.scope.getBinding('lazy');\n if (!binding || binding.kind !== 'module') return;\n const bindingPath = binding.path;\n if (\n bindingPath.type !== 'ImportSpecifier' ||\n bindingPath.parent.type !== 'ImportDeclaration'\n )\n return;\n const source = (bindingPath.parent as t.ImportDeclaration).source.value;\n if (source !== 'solid-js') return;\n\n if (node.arguments.length >= 2) return;\n if (node.arguments.length !== 1) return;\n\n const specifier = extractDynamicImportSpecifier(node.arguments[0] as t.Node);\n if (!specifier) return;\n\n node.arguments.push({\n type: 'StringLiteral',\n value: LAZY_PLACEHOLDER_PREFIX + specifier,\n } as t.StringLiteral);\n },\n },\n };\n}\n","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';\n// TODO use proper path\nimport type { Options as RefreshOptions } from 'solid-refresh/babel';\nimport lazyModuleUrl, { LAZY_PLACEHOLDER_PREFIX } from './lazy-module-url.js';\nimport path from 'path';\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 isVite6 = +version.split('.')[0] >= 6;\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 * @deprecated use `refresh` instead\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 * Enable dev-mode compilation output. When true, the compiler emits\n * additional runtime checks (e.g. hydration mismatch assertions).\n * Automatically set to true during `vite dev` — override here to\n * force on or off.\n *\n * @default auto (true in dev, false in build)\n */\n dev?: boolean;\n };\n\n\n refresh: Omit<RefreshOptions & { disabled: boolean }, 'bundler' | 'fixRender' | 'jsx'>;\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 || projectRoot;\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', '@solidjs/web']\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 },\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 && !options.refresh?.disabled);\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 'decorators',\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, dev: replaceDev, ...(options.solid || {}) }]],\n plugins: [\n [lazyModuleUrl],\n ...(needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {\n ...(options.refresh || {}),\n bundler: 'vite',\n fixRender: true,\n // TODO unfortunately, even with SSR enabled for refresh\n // it still doesn't work, so now we have to disable\n // this config\n jsx: false,\n }]] : []),\n ],\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 result = await babel.transformAsync(source, babelOptions);\n if (!result) {\n return undefined;\n }\n\n let code = result.code || '';\n\n // Resolve lazy() moduleUrl placeholders using Vite's resolver\n const placeholderRe = new RegExp(\n '\"' + LAZY_PLACEHOLDER_PREFIX + '([^\"]+)\"',\n 'g',\n );\n let match;\n const resolutions: Array<{ placeholder: string; resolved: string }> = [];\n while ((match = placeholderRe.exec(code)) !== null) {\n const specifier = match[1];\n const resolved = await this.resolve(specifier, id);\n if (resolved) {\n const cleanId = resolved.id.split('?')[0];\n resolutions.push({\n placeholder: match[0],\n resolved: '\"' + path.relative(projectRoot, cleanId) + '\"',\n });\n }\n }\n for (const { placeholder, resolved } of resolutions) {\n code = code.replace(placeholder, resolved);\n }\n\n return { code, map: result.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\nexport type ViteManifest = Record<\n string,\n {\n file: string;\n css?: string[];\n isEntry?: boolean;\n isDynamicEntry?: boolean;\n imports?: string[];\n }\n>;\n\nlet _manifest: ViteManifest | undefined;\n\n/**\n * Returns the Vite asset manifest for SSR.\n * In production, reads and caches the manifest JSON from `manifestPath`.\n * In development (file not found), returns a proxy that maps each moduleUrl\n * to its dev server path, so lazy() asset resolution works without a build.\n */\nexport function getManifest(manifestPath?: string): ViteManifest {\n if (_manifest) return _manifest;\n if (manifestPath) {\n try {\n _manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n return _manifest!;\n } catch {\n // File doesn't exist — dev mode, fall through\n }\n }\n _manifest = new Proxy(\n {},\n {\n get(_, key) {\n if (typeof key !== 'string') return undefined;\n return { file: '/' + key };\n },\n },\n ) as ViteManifest;\n return _manifest;\n}\n"],"names":["LAZY_PLACEHOLDER_PREFIX","extractDynamicImportSpecifier","node","type","callExpr","body","length","argument","callee","arguments","arg","value","lazyModuleUrlPlugin","name","visitor","CallExpression","nodePath","state","filename","binding","scope","getBinding","kind","bindingPath","path","parent","source","specifier","push","require","createRequire","import","meta","url","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","isVite6","version","split","getExtension","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","key","getJestDomExport","setupFiles","some","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","isTestMode","solidPkgsConfig","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","configEnvironment","opts","defaultClientConditions","defaultServerConditions","consumer","isSsrTargetWebworker","noExternal","Array","isArray","configResolved","hot","refresh","disabled","resolveId","id","load","transform","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","plugins","sourceFileName","presets","solid","lazyModuleUrl","solidRefresh","bundler","fixRender","jsx","ast","sourceMaps","configFile","babelrc","parserOpts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","result","transformAsync","code","placeholderRe","RegExp","match","resolutions","exec","resolved","cleanId","placeholder","relative","entries","_manifest","getManifest","manifestPath","JSON","parse","Proxy","get","_","file"],"mappings":";;;;;;;;;;AAEO,MAAMA,uBAAuB,GAAG,wBAAwB;;AAE/D;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAACC,IAAY,EAAiB;AAClE,EAAA,IAAIA,IAAI,CAACC,IAAI,KAAK,yBAAyB,IAAID,IAAI,CAACC,IAAI,KAAK,oBAAoB,EAAE,OAAO,IAAI;EAE9F,IAAIC,QAAiC,GAAG,IAAI;AAC5C,EAAA,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,IAAIE,YAAY,EAAE;IAChB,IAAI;MACFF,SAAS,GAAGG,IAAI,CAACC,KAAK,CAACzI,YAAY,CAACuI,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3D,MAAA,OAAOF,SAAS;AAClB,KAAC,CAAC,MAAM;AACN;AAAA;AAEJ;AACAA,EAAAA,SAAS,GAAG,IAAIK,KAAK,CACnB,EAAE,EACF;AACEC,IAAAA,GAAGA,CAACC,CAAC,EAAE9H,GAAG,EAAE;AACV,MAAA,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE,OAAOK,SAAS;MAC7C,OAAO;QAAE0H,IAAI,EAAE,GAAG,GAAG/H;OAAK;AAC5B;AACF,GACF,CAAiB;AACjB,EAAA,OAAOuH,SAAS;AAClB;;;;"}
@@ -1,4 +1,5 @@
1
1
  import * as babel from '@babel/core';
2
+ import type { Options as RefreshOptions } from 'solid-refresh/babel';
2
3
  import type { FilterPattern, Plugin } from 'vite';
3
4
  /** Possible options for the extensions property */
4
5
  export interface ExtensionOptions {
@@ -35,6 +36,7 @@ export interface Options {
35
36
  * set to `false`, it won't inject the runtime in dev.
36
37
  *
37
38
  * @default true
39
+ * @deprecated use `refresh` instead
38
40
  */
39
41
  hot?: boolean;
40
42
  /**
@@ -128,6 +130,32 @@ export interface Options {
128
130
  * @default ["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"]
129
131
  */
130
132
  builtIns?: string[];
133
+ /**
134
+ * Enable dev-mode compilation output. When true, the compiler emits
135
+ * additional runtime checks (e.g. hydration mismatch assertions).
136
+ * Automatically set to true during `vite dev` — override here to
137
+ * force on or off.
138
+ *
139
+ * @default auto (true in dev, false in build)
140
+ */
141
+ dev?: boolean;
131
142
  };
143
+ refresh: Omit<RefreshOptions & {
144
+ disabled: boolean;
145
+ }, 'bundler' | 'fixRender' | 'jsx'>;
132
146
  }
133
147
  export default function solidPlugin(options?: Partial<Options>): Plugin;
148
+ export type ViteManifest = Record<string, {
149
+ file: string;
150
+ css?: string[];
151
+ isEntry?: boolean;
152
+ isDynamicEntry?: boolean;
153
+ imports?: string[];
154
+ }>;
155
+ /**
156
+ * Returns the Vite asset manifest for SSR.
157
+ * In production, reads and caches the manifest JSON from `manifestPath`.
158
+ * In development (file not found), returns a proxy that maps each moduleUrl
159
+ * to its dev server path, so lazy() asset resolution works without a build.
160
+ */
161
+ export declare function getManifest(manifestPath?: string): ViteManifest;
@@ -0,0 +1,8 @@
1
+ import type { PluginObj } from '@babel/core';
2
+ export declare const LAZY_PLACEHOLDER_PREFIX = "__SOLID_LAZY_MODULE__:";
3
+ /**
4
+ * Babel plugin that detects `lazy(() => import("specifier"))` calls
5
+ * and injects a placeholder as the second argument. The placeholder
6
+ * is resolved to a real path by the Vite transform hook using this.resolve().
7
+ */
8
+ export default function lazyModuleUrlPlugin(): PluginObj;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-solid",
3
- "version": "2.11.10",
4
- "description": "solid-js integration plugin for vite 3/4/5/6",
3
+ "version": "3.0.0-next.0",
4
+ "description": "solid-js integration plugin for vite 3/4/5/6/7",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -37,9 +37,9 @@
37
37
  "dependencies": {
38
38
  "@babel/core": "^7.23.3",
39
39
  "@types/babel__core": "^7.20.4",
40
- "babel-preset-solid": "^1.8.4",
40
+ "babel-preset-solid": "^2.0.0-beta",
41
41
  "merge-anything": "^5.1.7",
42
- "solid-refresh": "^0.6.3",
42
+ "solid-refresh": "^0.8.0-next.1",
43
43
  "vitefu": "^1.0.4"
44
44
  },
45
45
  "devDependencies": {
@@ -58,13 +58,13 @@
58
58
  "prettier": "^3.1.0",
59
59
  "rollup": "^4.5.0",
60
60
  "rollup-plugin-cleaner": "^1.0.0",
61
- "solid-js": "^1.9.3",
61
+ "solid-js": "^2.0.0-beta",
62
62
  "typescript": "^5.2.2",
63
- "vite": "^6.0.0"
63
+ "vite": "^7.0.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.*",
67
- "solid-js": "^1.7.2",
67
+ "solid-js": "^2.0.0-beta",
68
68
  "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
69
69
  },
70
70
  "peerDependenciesMeta": {