FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

208
node_modules/vite-plugin-solid/README.md generated vendored Normal file
View File

@@ -0,0 +1,208 @@
<p>
<img width="100%" src="https://raw.githubusercontent.com/solidjs/vite-plugin-solid/master/banner.png" alt="Solid Vite Plugin">
</p>
# ⚡ vite-plugin-solid
A simple integration to run [solid-js](https://github.com/solidjs/solid) with [vite](https://github.com/vitejs/vite)
<img alt="HMR gif demonstrationdemodemodemo" src=".github/hmr.gif">
# Got a question? / Need help?
Join [solid discord](https://discord.com/invite/solidjs) and check the [troubleshooting section](#troubleshooting) to see if your question hasn't been already answered.
## Features
- HMR with no configuration needed
- Drop-in installation as a vite plugin
- Minimal bundle size
- Support typescript (`.tsx`) out of the box
- Support code splitting out of the box
## Requirements
This module 100% ESM compatible and requires NodeJS `14.18.0` or later.
You can check your current version of NodeJS by typing `node -v` in your terminal. If your version is below that one version I'd encourage you to either do an update globally or use a NodeJS version management tool such as [Volta](https://volta.sh/) or [nvm](https://github.com/nvm-sh/nvm).
## Quickstart
You can use the [vite-template-solid](https://github.com/solidjs/templates) starter templates similar to CRA:
```bash
$ npx degit solidjs/templates/js my-solid-project
$ cd my-solid-project
$ npm install # or pnpm install or yarn install
$ npm run start # starts dev-server with hot-module-reloading
$ npm run build # builds to /dist
```
## Installation
Install `vite`, `vite-plugin-solid` as dev dependencies.
Install `solid-js` as dependency.
You have to install those so that you are in control to which solid version is used to compile your code.
```bash
# with npm
$ npm install -D vite vite-plugin-solid
$ npm install solid-js
# with pnpm
$ pnpm add -D vite vite-plugin-solid
$ pnpm add solid-js
# with yarn
$ yarn add -D vite vite-plugin-solid
$ yarn add solid-js
```
Add it as plugin to `vite.config.js`
```js
// vite.config.ts
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
export default defineConfig({
plugins: [solidPlugin()],
});
```
## Run
Just use regular `vite` or `vite build` commands
```json
{
"scripts": {
"dev": "vite",
"build": "vite build"
}
}
```
## API
### options
- Type: Object
- Default: {}
#### options.include
- Type: (string | RegExp)[] | string | RegExp | null
- Default: undefined
A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files the plugin should operate on.
#### options.exclude
- Type: (string | RegExp)[] | string | RegExp | null
- Default: undefined
A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files to be ignored by the plugin.
#### options.dev
- Type: Boolean
- Default: true
This will inject `solid-js/dev` in place of `solid-js` in dev mode. Has no effect in prod.
If set to false, it won't inject it in dev.
This is useful for extra logs and debug.
#### options.hot
- Type: Boolean
- Default: true
This will inject HMR runtime in dev mode. Has no effect in prod.
If set to false, it won't inject the runtime in dev.
#### options.ssr
- Type: Boolean
- Default: false
This will force SSR code in the produced files.
#### options.babel
- Type: Babel.TransformOptions
- Default: {}
Pass any additional [babel transform options](https://babeljs.io/docs/en/options). Those will be merged with the transformations required by Solid.
#### options.solid
- Type: [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options)
- Default: {}
Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).
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).
#### options.typescript
- Type: [@babel/preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript)
- Default: {}
Pass any additional [@babel/preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript).
#### options.extensions
- Type: (string, [string, { typescript: boolean }])[]
- Default: []
An array of custom extension that will be passed through the solid compiler.
By default, the plugin only transform `jsx` and `tsx` files.
This is useful if you want to transform `mdx` files for example.
## Note on HMR
Starting from version `1.1.0`, this plugin handle automatic HMR via [solid-refresh](https://github.com/solidjs/solid-refresh).
At this stage it's still early work but provide basic HMR. In order to get the best out of it there are couple of things to keep in mind:
- When you modify a file every state below this component will be reset to default state (including the current file). The state in parent component is preserved.
- The entrypoint can't benefit from HMR yet and will force a hard reload of the entire app. This is still really fast thanks to browser caching.
If at least one of this point is blocking to you, you can revert to the old behavior by [opting out the automatic HMR](#options) and placing the following snippet in your entry point:
```jsx
const dispose = render(() => <App />, document.body);
if (import.meta.hot) {
import.meta.hot.accept();
import.meta.hot.dispose(dispose);
}
```
# Troubleshooting
- It appears that Webstorm generate some weird triggers when saving a file. In order to prevent that you can follow [this thread](https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000154544-I-m-having-a-huge-problem-with-Webstorm-and-react-hot-loader-) and disable the **"Safe Write"** option in **"Settings | Appearance & Behavior | System Settings"**.
- If one of your dependency spit out React code instead of Solid that means that they don't expose JSX properly. To get around it, you might want to manually exclude it from the [dependencies optimization](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude)
- If you are trying to make [directives](https://www.solidjs.com/docs/latest/api#use%3A___) work, and they somehow don't try setting the `options.typescript.onlyRemoveTypeImports` option to `true`
## Migration from v1
The master branch now target vite 2.
The main breaking change from previous version is that the package has been renamed from `@amoutonbrady/vite-plugin-solid` to `vite-plugin-solid`.
For other breaking changes, check [the migration guide of vite](https://vitejs.dev/guide/migration.html).
# Testing
If you are using [vitest](https://vitest.dev/), this plugin already injects the necessary configuration for you. It even automatically detects if you have `@testing-library/jest-dom` installed in your project and automatically adds it to the `setupFiles`. All you need to add (if you want) is `globals`, `coverage`, and other testing configuration of your choice. If you can live without those, enjoy using vitest without the need to configure it yourself.
# Credits
- [solid-js](https://github.com/solidjs/solid)
- [vite](https://github.com/vitejs/vite)

299
node_modules/vite-plugin-solid/dist/cjs/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,299 @@
'use strict';
var babel = require('@babel/core');
var solid = require('babel-preset-solid');
var fs = require('fs');
var mergeAnything = require('merge-anything');
var module$1 = require('module');
var solidRefresh = require('solid-refresh/babel');
var vite = require('vite');
var vitefu = require('vitefu');
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var babel__namespace = /*#__PURE__*/_interopNamespaceDefault(babel);
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)));
const runtimePublicPath = '/@solid-refresh';
const runtimeFilePath = require$1.resolve('solid-refresh/dist/solid-refresh.mjs');
const runtimeCode = fs.readFileSync(runtimeFilePath, 'utf-8');
const viteVersionMajor = +vite.version.split('.')[0];
const isVite6 = viteVersionMajor >= 6;
const isVite8 = viteVersionMajor >= 8;
/** Possible options for the extensions property */
/** Configuration options for vite-plugin-solid. */
function getExtension(filename) {
const index = filename.lastIndexOf('.');
return index < 0 ? '' : filename.substring(index).replace(/\?.+$/, '');
}
function containsSolidField(fields) {
const keys = Object.keys(fields);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (key === 'solid') return true;
if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key])) return true;
}
return false;
}
function getJestDomExport(setupFiles) {
return setupFiles?.some(path => /jest-dom/.test(path)) ? undefined : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(path => {
try {
require$1.resolve(path);
return true;
} catch (e) {
return false;
}
});
}
function solidPlugin(options = {}) {
const filter = vite.createFilter(options.include, options.exclude);
let needHmr = false;
let replaceDev = false;
let projectRoot = process.cwd();
let isTestMode = false;
let solidPkgsConfig;
return {
name: 'solid',
enforce: 'pre',
async config(userConfig, {
command
}) {
// We inject the dev mode only if the user explicitly wants it or if we are in dev (serve) mode
replaceDev = options.dev === true || options.dev !== false && command === 'serve';
projectRoot = userConfig.root;
isTestMode = userConfig.mode === 'test';
if (!userConfig.resolve) userConfig.resolve = {};
userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
solidPkgsConfig = await vitefu.crawlFrameworkPkgs({
viteUserConfig: userConfig,
root: projectRoot || process.cwd(),
isBuild: command === 'build',
isFrameworkPkgByJson(pkgJson) {
return containsSolidField(pkgJson.exports || {});
}
});
// fix for bundling dev in production
const nestedDeps = replaceDev ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] : [];
const userTest = userConfig.test ?? {};
const test = {};
if (userConfig.mode === 'test') {
// to simplify the processing of the config, we normalize the setupFiles to an array
const userSetupFiles = typeof userTest.setupFiles === 'string' ? [userTest.setupFiles] : userTest.setupFiles || [];
if (!userTest.environment && !options.ssr) {
test.environment = 'jsdom';
}
if (!userTest.server?.deps?.external?.find(item => /solid-js/.test(item.toString()))) {
test.server = {
deps: {
external: [/solid-js/]
}
};
}
if (!userTest.browser?.enabled) {
// vitest browser mode already has bundled jest-dom assertions
// https://main.vitest.dev/guide/browser/assertion-api.html#assertion-api
const jestDomImport = getJestDomExport(userSetupFiles);
if (jestDomImport) {
test.setupFiles = [jestDomImport];
}
}
}
return {
/**
* We only need esbuild on .ts or .js files.
* .tsx & .jsx files are handled by us
*/
// esbuild: { include: /\.ts$/ },
resolve: {
conditions: isVite6 ? undefined : ['solid', ...(replaceDev ? ['development'] : []), ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : [])],
dedupe: nestedDeps,
alias: [{
find: /^solid-refresh$/,
replacement: runtimePublicPath
}]
},
optimizeDeps: {
include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],
exclude: solidPkgsConfig.optimizeDeps.exclude,
// Vite 8+ uses Rolldown for dependency scanning. Rolldown defaults to
// React's automatic JSX runtime for .tsx files, injecting a
// react/jsx-dev-runtime import. Tell it to preserve JSX as-is since
// this plugin handles JSX transformation via babel-preset-solid.
...(isVite8 ? {
rolldownOptions: {
transform: {
jsx: 'preserve'
}
}
} : {})
},
...(!isVite6 ? {
ssr: solidPkgsConfig.ssr
} : {}),
...(test.server ? {
test
} : {})
};
},
// @ts-ignore This hook only works in Vite 6
async configEnvironment(name, config, opts) {
config.resolve ??= {};
// Emulate Vite default fallback for `resolve.conditions` if not set
if (config.resolve.conditions == null) {
// @ts-ignore These exports only exist in Vite 6
const {
defaultClientConditions,
defaultServerConditions
} = await import('vite');
if (config.consumer === 'client' || name === 'client' || opts.isSsrTargetWebworker) {
config.resolve.conditions = [...defaultClientConditions];
} else {
config.resolve.conditions = [...defaultServerConditions];
}
}
config.resolve.conditions = ['solid', ...(replaceDev ? ['development'] : []), ...(isTestMode && !opts.isSsrTargetWebworker && !options.ssr ? ['browser'] : []), ...config.resolve.conditions];
// Set resolve.noExternal and resolve.external for SSR environment (Vite 6+)
// Only set resolve.external if noExternal is not true (to avoid conflicts with plugins like Cloudflare)
if (isVite6 && name === 'ssr' && solidPkgsConfig) {
if (config.resolve.noExternal !== true) {
config.resolve.noExternal = [...(Array.isArray(config.resolve.noExternal) ? config.resolve.noExternal : []), ...solidPkgsConfig.ssr.noExternal];
config.resolve.external = [...(Array.isArray(config.resolve.external) ? config.resolve.external : []), ...solidPkgsConfig.ssr.external];
}
}
},
configResolved(config) {
needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;
},
resolveId(id) {
if (id === runtimePublicPath) return id;
},
load(id) {
if (id === runtimePublicPath) return runtimeCode;
},
async transform(source, id, transformOptions) {
const isSsr = transformOptions && transformOptions.ssr;
const currentFileExtension = getExtension(id);
const extensionsToWatch = options.extensions || [];
const allExtensions = extensionsToWatch.map(extension =>
// An extension can be a string or a tuple [extension, options]
typeof extension === 'string' ? extension : extension[0]);
if (!filter(id)) {
return null;
}
id = id.replace(/\?.*$/, '');
if (!(/\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {
return null;
}
const inNodeModules = /node_modules/.test(id);
let solidOptions;
if (options.ssr) {
if (isSsr) {
solidOptions = {
generate: 'ssr',
hydratable: true
};
} else {
solidOptions = {
generate: 'dom',
hydratable: true
};
}
} else {
solidOptions = {
generate: 'dom',
hydratable: false
};
}
// We need to know if the current file extension has a typescript options tied to it
const shouldBeProcessedWithTypescript = /\.[mc]?tsx$/i.test(id) || extensionsToWatch.some(extension => {
if (typeof extension === 'string') {
return extension.includes('tsx');
}
const [extensionName, extensionOptions] = extension;
if (extensionName !== currentFileExtension) return false;
return extensionOptions.typescript;
});
const plugins = ['jsx'];
if (shouldBeProcessedWithTypescript) {
plugins.push('typescript');
}
const opts = {
root: projectRoot,
filename: id,
sourceFileName: id,
presets: [[solid, {
...solidOptions,
...(options.solid || {})
}]],
plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
bundler: 'vite'
}]] : [],
ast: false,
sourceMaps: true,
configFile: false,
babelrc: false,
parserOpts: {
plugins
}
};
// Default value for babel user options
let babelUserOptions = {};
if (options.babel) {
if (typeof options.babel === 'function') {
const babelOptions = options.babel(source, id, isSsr);
babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
} else {
babelUserOptions = options.babel;
}
}
const babelOptions = mergeAnything.mergeAndConcat(babelUserOptions, opts);
const {
code,
map
} = await babel__namespace.transformAsync(source, babelOptions);
return {
code,
map
};
}
};
}
/**
* This basically normalize all aliases of the config into
* the array format of the alias.
*
* eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]
*/
function normalizeAliases(alias = []) {
return Array.isArray(alias) ? alias : Object.entries(alias).map(([find, replacement]) => ({
find,
replacement
}));
}
module.exports = solidPlugin;
//# sourceMappingURL=index.cjs.map

File diff suppressed because one or more lines are too long

277
node_modules/vite-plugin-solid/dist/esm/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,277 @@
import * as babel from '@babel/core';
import solid from 'babel-preset-solid';
import { readFileSync } from 'fs';
import { mergeAndConcat } from 'merge-anything';
import { createRequire } from 'module';
import solidRefresh from 'solid-refresh/babel';
import { version, createFilter } from 'vite';
import { crawlFrameworkPkgs } from 'vitefu';
const require = createRequire(import.meta.url);
const runtimePublicPath = '/@solid-refresh';
const runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');
const runtimeCode = readFileSync(runtimeFilePath, 'utf-8');
const viteVersionMajor = +version.split('.')[0];
const isVite6 = viteVersionMajor >= 6;
const isVite8 = viteVersionMajor >= 8;
/** Possible options for the extensions property */
/** Configuration options for vite-plugin-solid. */
function getExtension(filename) {
const index = filename.lastIndexOf('.');
return index < 0 ? '' : filename.substring(index).replace(/\?.+$/, '');
}
function containsSolidField(fields) {
const keys = Object.keys(fields);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (key === 'solid') return true;
if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key])) return true;
}
return false;
}
function getJestDomExport(setupFiles) {
return setupFiles?.some(path => /jest-dom/.test(path)) ? undefined : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(path => {
try {
require.resolve(path);
return true;
} catch (e) {
return false;
}
});
}
function solidPlugin(options = {}) {
const filter = createFilter(options.include, options.exclude);
let needHmr = false;
let replaceDev = false;
let projectRoot = process.cwd();
let isTestMode = false;
let solidPkgsConfig;
return {
name: 'solid',
enforce: 'pre',
async config(userConfig, {
command
}) {
// We inject the dev mode only if the user explicitly wants it or if we are in dev (serve) mode
replaceDev = options.dev === true || options.dev !== false && command === 'serve';
projectRoot = userConfig.root;
isTestMode = userConfig.mode === 'test';
if (!userConfig.resolve) userConfig.resolve = {};
userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
solidPkgsConfig = await crawlFrameworkPkgs({
viteUserConfig: userConfig,
root: projectRoot || process.cwd(),
isBuild: command === 'build',
isFrameworkPkgByJson(pkgJson) {
return containsSolidField(pkgJson.exports || {});
}
});
// fix for bundling dev in production
const nestedDeps = replaceDev ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] : [];
const userTest = userConfig.test ?? {};
const test = {};
if (userConfig.mode === 'test') {
// to simplify the processing of the config, we normalize the setupFiles to an array
const userSetupFiles = typeof userTest.setupFiles === 'string' ? [userTest.setupFiles] : userTest.setupFiles || [];
if (!userTest.environment && !options.ssr) {
test.environment = 'jsdom';
}
if (!userTest.server?.deps?.external?.find(item => /solid-js/.test(item.toString()))) {
test.server = {
deps: {
external: [/solid-js/]
}
};
}
if (!userTest.browser?.enabled) {
// vitest browser mode already has bundled jest-dom assertions
// https://main.vitest.dev/guide/browser/assertion-api.html#assertion-api
const jestDomImport = getJestDomExport(userSetupFiles);
if (jestDomImport) {
test.setupFiles = [jestDomImport];
}
}
}
return {
/**
* We only need esbuild on .ts or .js files.
* .tsx & .jsx files are handled by us
*/
// esbuild: { include: /\.ts$/ },
resolve: {
conditions: isVite6 ? undefined : ['solid', ...(replaceDev ? ['development'] : []), ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : [])],
dedupe: nestedDeps,
alias: [{
find: /^solid-refresh$/,
replacement: runtimePublicPath
}]
},
optimizeDeps: {
include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],
exclude: solidPkgsConfig.optimizeDeps.exclude,
// Vite 8+ uses Rolldown for dependency scanning. Rolldown defaults to
// React's automatic JSX runtime for .tsx files, injecting a
// react/jsx-dev-runtime import. Tell it to preserve JSX as-is since
// this plugin handles JSX transformation via babel-preset-solid.
...(isVite8 ? {
rolldownOptions: {
transform: {
jsx: 'preserve'
}
}
} : {})
},
...(!isVite6 ? {
ssr: solidPkgsConfig.ssr
} : {}),
...(test.server ? {
test
} : {})
};
},
// @ts-ignore This hook only works in Vite 6
async configEnvironment(name, config, opts) {
config.resolve ??= {};
// Emulate Vite default fallback for `resolve.conditions` if not set
if (config.resolve.conditions == null) {
// @ts-ignore These exports only exist in Vite 6
const {
defaultClientConditions,
defaultServerConditions
} = await import('vite');
if (config.consumer === 'client' || name === 'client' || opts.isSsrTargetWebworker) {
config.resolve.conditions = [...defaultClientConditions];
} else {
config.resolve.conditions = [...defaultServerConditions];
}
}
config.resolve.conditions = ['solid', ...(replaceDev ? ['development'] : []), ...(isTestMode && !opts.isSsrTargetWebworker && !options.ssr ? ['browser'] : []), ...config.resolve.conditions];
// Set resolve.noExternal and resolve.external for SSR environment (Vite 6+)
// Only set resolve.external if noExternal is not true (to avoid conflicts with plugins like Cloudflare)
if (isVite6 && name === 'ssr' && solidPkgsConfig) {
if (config.resolve.noExternal !== true) {
config.resolve.noExternal = [...(Array.isArray(config.resolve.noExternal) ? config.resolve.noExternal : []), ...solidPkgsConfig.ssr.noExternal];
config.resolve.external = [...(Array.isArray(config.resolve.external) ? config.resolve.external : []), ...solidPkgsConfig.ssr.external];
}
}
},
configResolved(config) {
needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;
},
resolveId(id) {
if (id === runtimePublicPath) return id;
},
load(id) {
if (id === runtimePublicPath) return runtimeCode;
},
async transform(source, id, transformOptions) {
const isSsr = transformOptions && transformOptions.ssr;
const currentFileExtension = getExtension(id);
const extensionsToWatch = options.extensions || [];
const allExtensions = extensionsToWatch.map(extension =>
// An extension can be a string or a tuple [extension, options]
typeof extension === 'string' ? extension : extension[0]);
if (!filter(id)) {
return null;
}
id = id.replace(/\?.*$/, '');
if (!(/\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {
return null;
}
const inNodeModules = /node_modules/.test(id);
let solidOptions;
if (options.ssr) {
if (isSsr) {
solidOptions = {
generate: 'ssr',
hydratable: true
};
} else {
solidOptions = {
generate: 'dom',
hydratable: true
};
}
} else {
solidOptions = {
generate: 'dom',
hydratable: false
};
}
// We need to know if the current file extension has a typescript options tied to it
const shouldBeProcessedWithTypescript = /\.[mc]?tsx$/i.test(id) || extensionsToWatch.some(extension => {
if (typeof extension === 'string') {
return extension.includes('tsx');
}
const [extensionName, extensionOptions] = extension;
if (extensionName !== currentFileExtension) return false;
return extensionOptions.typescript;
});
const plugins = ['jsx'];
if (shouldBeProcessedWithTypescript) {
plugins.push('typescript');
}
const opts = {
root: projectRoot,
filename: id,
sourceFileName: id,
presets: [[solid, {
...solidOptions,
...(options.solid || {})
}]],
plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
bundler: 'vite'
}]] : [],
ast: false,
sourceMaps: true,
configFile: false,
babelrc: false,
parserOpts: {
plugins
}
};
// Default value for babel user options
let babelUserOptions = {};
if (options.babel) {
if (typeof options.babel === 'function') {
const babelOptions = options.babel(source, id, isSsr);
babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
} else {
babelUserOptions = options.babel;
}
}
const babelOptions = mergeAndConcat(babelUserOptions, opts);
const {
code,
map
} = await babel.transformAsync(source, babelOptions);
return {
code,
map
};
}
};
}
/**
* This basically normalize all aliases of the config into
* the array format of the alias.
*
* eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]
*/
function normalizeAliases(alias = []) {
return Array.isArray(alias) ? alias : Object.entries(alias).map(([find, replacement]) => ({
find,
replacement
}));
}
export { solidPlugin as default };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,133 @@
import * as babel from '@babel/core';
import type { FilterPattern, Plugin } from 'vite';
/** Possible options for the extensions property */
export interface ExtensionOptions {
typescript?: boolean;
}
/** Configuration options for vite-plugin-solid. */
export interface Options {
/**
* A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files
* the plugin should operate on.
*/
include?: FilterPattern;
/**
* A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files
* to be ignored by the plugin.
*/
exclude?: FilterPattern;
/**
* This will inject solid-js/dev in place of solid-js in dev mode. Has no
* effect in prod. If set to `false`, it won't inject it in dev. This is
* useful for extra logs and debugging.
*
* @default true
*/
dev?: boolean;
/**
* This will force SSR code in the produced files.
*
* @default false
*/
ssr?: boolean;
/**
* This will inject HMR runtime in dev mode. Has no effect in prod. If
* set to `false`, it won't inject the runtime in dev.
*
* @default true
*/
hot?: boolean;
/**
* This registers additional extensions that should be processed by
* vite-plugin-solid.
*
* @default undefined
*/
extensions?: (string | [string, ExtensionOptions])[];
/**
* Pass any additional babel transform options. They will be merged with
* the transformations required by Solid.
*
* @default {}
*/
babel?: babel.TransformOptions | ((source: string, id: string, ssr: boolean) => babel.TransformOptions) | ((source: string, id: string, ssr: boolean) => Promise<babel.TransformOptions>);
/**
* Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).
* 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).
*
* @default {}
*/
solid?: {
/**
* Remove unnecessary closing tags from template strings. More info here:
* https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates
*
* @default false
*/
omitNestedClosingTags?: boolean;
/**
* Remove the last closing tag from template strings. Enabled by default even when `omitNestedClosingTags` is disabled.
* Can be disabled for compatibility for some browser-like environments.
*
* @default true
*/
omitLastClosingTag?: boolean;
/**
* Remove unnecessary quotes from template strings.
* Can be disabled for compatibility for some browser-like environments.
*
* @default true
*/
omitQuotes?: boolean;
/**
* The name of the runtime module to import the methods from.
*
* @default "solid-js/web"
*/
moduleName?: string;
/**
* The output mode of the compiler.
* Can be:
* - "dom" is standard output
* - "ssr" is for server side rendering of strings.
* - "universal" is for using custom renderers from solid-js/universal
*
* @default "dom"
*/
generate?: 'ssr' | 'dom' | 'universal';
/**
* Indicate whether the output should contain hydratable markers.
*
* @default false
*/
hydratable?: boolean;
/**
* Boolean to indicate whether to enable automatic event delegation on camelCase.
*
* @default true
*/
delegateEvents?: boolean;
/**
* Boolean indicates whether smart conditional detection should be used.
* This optimizes simple boolean expressions and ternaries in JSX.
*
* @default true
*/
wrapConditionals?: boolean;
/**
* Boolean indicates whether to set current render context on Custom Elements and slots.
* Useful for seemless Context API with Web Components.
*
* @default true
*/
contextToCustomElements?: boolean;
/**
* Array of Component exports from module, that aren't included by default with the library.
* This plugin will automatically import them if it comes across them in the JSX.
*
* @default ["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"]
*/
builtIns?: string[];
};
}
export default function solidPlugin(options?: Partial<Options>): Plugin;

82
node_modules/vite-plugin-solid/package.json generated vendored Normal file
View File

@@ -0,0 +1,82 @@
{
"name": "vite-plugin-solid",
"version": "2.11.12",
"description": "solid-js integration plugin for vite 3/4/5/6",
"type": "module",
"files": [
"dist"
],
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
"types": "dist/types/src/index.d.ts",
"exports": {
"types": "./dist/types/src/index.d.ts",
"import": "./dist/esm/index.mjs",
"node": "./dist/cjs/index.cjs",
"require": "./dist/cjs/index.cjs",
"default": "./dist/cjs/index.cjs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/solidjs/vite-plugin-solid.git"
},
"keywords": [
"vite",
"vite plugin",
"vitejs",
"vitejs plugin",
"vite-plugin",
"solid"
],
"author": "Alexandre Mouton-Brady <amoutonbrady@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/solidjs/vite-plugin-solid/issues"
},
"homepage": "https://github.com/solidjs/vite-plugin-solid#readme",
"dependencies": {
"@babel/core": "^7.23.3",
"@types/babel__core": "^7.20.4",
"babel-preset-solid": "^1.8.4",
"merge-anything": "^5.1.7",
"solid-refresh": "^0.6.3",
"vitefu": "^1.0.4"
},
"devDependencies": {
"@babel/preset-env": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@changesets/cli": "^2.27.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@skypack/package-check": "^0.2.2",
"@types/node": "^18.18.4",
"cypress": "^14.0.0",
"cypress-visual-regression": "^5.2.2",
"cypress-vite": "^1.6.0",
"cypress-wait-until": "^3.0.2",
"prettier": "^3.1.0",
"rollup": "^4.5.0",
"rollup-plugin-cleaner": "^1.0.0",
"solid-js": "^1.9.3",
"typescript": "^5.2.2",
"vite": "^6.0.0"
},
"peerDependencies": {
"@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.*",
"solid-js": "^1.7.2",
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"@testing-library/jest-dom": {
"optional": true
}
},
"scripts": {
"build": "rollup -c && tsc --emitDeclarationOnly",
"dev": "rollup -c -w",
"release": "pnpm build && changeset publish",
"check": "package-check",
"test": "node scripts/test-examples.ts"
}
}