From 0a2af81e8097264665c906206ed83a53bdc34579 Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Fri, 6 Jun 2025 18:55:00 -0500 Subject: [PATCH 1/2] feat: add solid 2.0 compatibility --- package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- src/index.ts | 38 +++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 3a5c2bb..f1ce940 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "@babel/core": "^7.23.3", "@types/babel__core": "^7.20.4", - "babel-preset-solid": "^1.8.4", + "babel-preset-solid": "2.0.0-experimental.5", "merge-anything": "^5.1.7", "solid-refresh": "^0.6.3", "vitefu": "^1.0.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0408bf4..b8f8ef4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,8 +24,8 @@ importers: specifier: ^7.20.4 version: 7.20.5 babel-preset-solid: - specifier: ^1.8.4 - version: 1.9.3(@babel/core@7.26.0) + specifier: 2.0.0-experimental.5 + version: 2.0.0-experimental.5(@babel/core@7.26.0) merge-anything: specifier: ^5.1.7 version: 5.1.7 @@ -1884,8 +1884,8 @@ packages: aws4@1.13.2: resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==} - babel-plugin-jsx-dom-expressions@0.39.3: - resolution: {integrity: sha512-6RzmSu21zYPlV2gNwzjGG9FgODtt9hIWnx7L//OIioIEuRcnpDZoY8Tr+I81Cy1SrH4qoDyKpwHHo6uAMAeyPA==} + babel-plugin-jsx-dom-expressions@0.40.0-next.9: + resolution: {integrity: sha512-S2NQjyTC0X2X0T0PmY8Xf6db0LFUT+1p/q4bujPJ40GmKIb17YqJrnTigpr+frWu8PC7UYd5zucW6u6EvQF2Sw==} peerDependencies: '@babel/core': ^7.20.12 @@ -1904,8 +1904,8 @@ packages: peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 - babel-preset-solid@1.9.3: - resolution: {integrity: sha512-jvlx5wDp8s+bEF9sGFw/84SInXOA51ttkUEroQziKMbxplXThVKt83qB6bDTa1HuLNatdU9FHpFOiQWs1tLQIg==} + babel-preset-solid@2.0.0-experimental.5: + resolution: {integrity: sha512-rr+5MbCQIx2QNDO5Mt+dkiBG5XjKPSFMFd4t6lvmwvW2MphZ2tKEYsxHmTat4CbMKqhDguOUBlklEJECptm6vQ==} peerDependencies: '@babel/core': ^7.0.0 @@ -5418,7 +5418,7 @@ snapshots: aws4@1.13.2: {} - babel-plugin-jsx-dom-expressions@0.39.3(@babel/core@7.26.0): + babel-plugin-jsx-dom-expressions@0.40.0-next.9(@babel/core@7.26.0): dependencies: '@babel/core': 7.26.0 '@babel/helper-module-imports': 7.18.6 @@ -5452,10 +5452,10 @@ snapshots: transitivePeerDependencies: - supports-color - babel-preset-solid@1.9.3(@babel/core@7.26.0): + babel-preset-solid@2.0.0-experimental.5(@babel/core@7.26.0): dependencies: '@babel/core': 7.26.0 - babel-plugin-jsx-dom-expressions: 0.39.3(@babel/core@7.26.0) + babel-plugin-jsx-dom-expressions: 0.40.0-next.9(@babel/core@7.26.0) balanced-match@1.0.2: {} diff --git a/src/index.ts b/src/index.ts index 17b71e6..feb15e5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ 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 solidRefresh from 'solid-refresh/babel'; import type { Alias, AliasOptions, FilterPattern, Plugin } from 'vite'; import { createFilter, version } from 'vite'; import { crawlFrameworkPkgs } from 'vitefu'; @@ -69,9 +69,9 @@ export interface Options { * @default {} */ babel?: - | babel.TransformOptions - | ((source: string, id: string, ssr: boolean) => babel.TransformOptions) - | ((source: string, id: string, ssr: boolean) => Promise); + | babel.TransformOptions + | ((source: string, id: string, ssr: boolean) => babel.TransformOptions) + | ((source: string, id: string, ssr: boolean) => Promise); /** * 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). @@ -164,15 +164,15 @@ function getJestDomExport(setupFiles: string[]) { 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; - } - }, - ); + (path) => { + try { + require.resolve(path); + return true; + } catch (e) { + return false; + } + }, + ); } export default function solidPlugin(options: Partial = {}): Plugin { @@ -207,7 +207,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { // fix for bundling dev in production const nestedDeps = replaceDev - ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] + ? ['solid-js'] : []; const userTest = (userConfig as any).test ?? {}; @@ -250,10 +250,10 @@ export default function solidPlugin(options: Partial = {}): Plugin { conditions: isVite6 ? undefined : [ - 'solid', - ...(replaceDev ? ['development'] : []), - ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []), - ], + 'solid', + ...(replaceDev ? ['development'] : []), + ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []), + ], dedupe: nestedDeps, alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }], }, @@ -359,7 +359,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { filename: id, sourceFileName: id, presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]], - plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [], + plugins: needHmr && !isSsr && !inNodeModules ? [] : [], ast: false, sourceMaps: true, configFile: false, From c88a577c30e59b5e5d3210883edb81f2bc47119e Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Thu, 4 Sep 2025 19:10:05 -0500 Subject: [PATCH 2/2] update babel-preset-solid --- package.json | 2 +- pnpm-lock.yaml | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index f1ce940..bb975e8 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "@babel/core": "^7.23.3", "@types/babel__core": "^7.20.4", - "babel-preset-solid": "2.0.0-experimental.5", + "babel-preset-solid": "2.0.0-experimental.7", "merge-anything": "^5.1.7", "solid-refresh": "^0.6.3", "vitefu": "^1.0.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8f8ef4..db45450 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,8 +24,8 @@ importers: specifier: ^7.20.4 version: 7.20.5 babel-preset-solid: - specifier: 2.0.0-experimental.5 - version: 2.0.0-experimental.5(@babel/core@7.26.0) + specifier: 2.0.0-experimental.7 + version: 2.0.0-experimental.7(@babel/core@7.26.0)(solid-js@1.9.4) merge-anything: specifier: ^5.1.7 version: 5.1.7 @@ -1884,8 +1884,8 @@ packages: aws4@1.13.2: resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==} - babel-plugin-jsx-dom-expressions@0.40.0-next.9: - resolution: {integrity: sha512-S2NQjyTC0X2X0T0PmY8Xf6db0LFUT+1p/q4bujPJ40GmKIb17YqJrnTigpr+frWu8PC7UYd5zucW6u6EvQF2Sw==} + babel-plugin-jsx-dom-expressions@0.41.0-next.0: + resolution: {integrity: sha512-8KULtd5IDfR06safQZpqa4xHCzUI/in5PS7nYv2v4o41XZxS6+VtA/68aXG5P81PmuVNO6KnjK8QJ1PD5mGyyg==} peerDependencies: '@babel/core': ^7.20.12 @@ -1904,10 +1904,14 @@ packages: peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 - babel-preset-solid@2.0.0-experimental.5: - resolution: {integrity: sha512-rr+5MbCQIx2QNDO5Mt+dkiBG5XjKPSFMFd4t6lvmwvW2MphZ2tKEYsxHmTat4CbMKqhDguOUBlklEJECptm6vQ==} + babel-preset-solid@2.0.0-experimental.7: + resolution: {integrity: sha512-MCvFG0+9H6tp9P6PIT4KMEeUia/UYnlqc+6j+SPgGciW8PEsemhmmVqc3iqvV5Nx1TbKuc2KVZKp+e0V8Vxuyw==} peerDependencies: '@babel/core': ^7.0.0 + solid-js: 2.0.0-experimental.7 + peerDependenciesMeta: + solid-js: + optional: true balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -5418,7 +5422,7 @@ snapshots: aws4@1.13.2: {} - babel-plugin-jsx-dom-expressions@0.40.0-next.9(@babel/core@7.26.0): + babel-plugin-jsx-dom-expressions@0.41.0-next.0(@babel/core@7.26.0): dependencies: '@babel/core': 7.26.0 '@babel/helper-module-imports': 7.18.6 @@ -5452,10 +5456,12 @@ snapshots: transitivePeerDependencies: - supports-color - babel-preset-solid@2.0.0-experimental.5(@babel/core@7.26.0): + babel-preset-solid@2.0.0-experimental.7(@babel/core@7.26.0)(solid-js@1.9.4): dependencies: '@babel/core': 7.26.0 - babel-plugin-jsx-dom-expressions: 0.40.0-next.9(@babel/core@7.26.0) + babel-plugin-jsx-dom-expressions: 0.41.0-next.0(@babel/core@7.26.0) + optionalDependencies: + solid-js: 1.9.4 balanced-match@1.0.2: {}