diff --git a/package.json b/package.json index 3a5c2bb..1405b82 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.15", "merge-anything": "^5.1.7", "solid-refresh": "^0.6.3", "vitefu": "^1.0.4" @@ -80,4 +80,4 @@ "optional": true } } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0408bf4..314af71 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.15 + version: 2.0.0-experimental.15(@babel/core@7.26.0)(solid-js@1.9.4) merge-anything: specifier: ^5.1.7 version: 5.1.7 @@ -1566,96 +1566,115 @@ packages: resolution: {integrity: sha512-9OwUnK/xKw6DyRlgx8UizeqRFOfi9mf5TYCw1uolDaJSbUmBxP85DE6T4ouCMoN6pXw8ZoTeZCSEfSaYo+/s1w==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-gnueabihf@4.34.8': resolution: {integrity: sha512-A4iphFGNkWRd+5m3VIGuqHnG3MVnqKe7Al57u9mwgbyZ2/xF9Jio72MaY7xxh+Y87VAHmGQr73qoKL9HPbXj1g==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.27.4': resolution: {integrity: sha512-Vgdo4fpuphS9V24WOV+KwkCVJ72u7idTgQaBoLRD0UxBAWTF9GWurJO9YD9yh00BzbkhpeXtm6na+MvJU7Z73A==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm-musleabihf@4.34.8': resolution: {integrity: sha512-S0lqKLfTm5u+QTxlFiAnb2J/2dgQqRy/XvziPtDd1rKZFXHTyYLoVL58M/XFwDI01AQCDIevGLbQrMAtdyanpA==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.27.4': resolution: {integrity: sha512-pleyNgyd1kkBkw2kOqlBx+0atfIIkkExOTiifoODo6qKDSpnc6WzUY5RhHdmTdIJXBdSnh6JknnYTtmQyobrVg==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-gnu@4.34.8': resolution: {integrity: sha512-jpz9YOuPiSkL4G4pqKrus0pn9aYwpImGkosRKwNi+sJSkz+WU3anZe6hi73StLOQdfXYXC7hUfsQlTnjMd3s1A==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.27.4': resolution: {integrity: sha512-caluiUXvUuVyCHr5DxL8ohaaFFzPGmgmMvwmqAITMpV/Q+tPoaHZ/PWa3t8B2WyoRcIIuu1hkaW5KkeTDNSnMA==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-musl@4.34.8': resolution: {integrity: sha512-KdSfaROOUJXgTVxJNAZ3KwkRc5nggDk+06P6lgi1HLv1hskgvxHUKZ4xtwHkVYJ1Rep4GNo+uEfycCRRxht7+Q==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-loongarch64-gnu@4.34.8': resolution: {integrity: sha512-NyF4gcxwkMFRjgXBM6g2lkT58OWztZvw5KkV2K0qqSnUEqCVcqdh2jN4gQrTn/YUpAcNKyFHfoOZEer9nwo6uQ==} cpu: [loong64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-powerpc64le-gnu@4.27.4': resolution: {integrity: sha512-FScrpHrO60hARyHh7s1zHE97u0KlT/RECzCKAdmI+LEoC1eDh/RDji9JgFqyO+wPDb86Oa/sXkily1+oi4FzJQ==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-powerpc64le-gnu@4.34.8': resolution: {integrity: sha512-LMJc999GkhGvktHU85zNTDImZVUCJ1z/MbAJTnviiWmmjyckP5aQsHtcujMjpNdMZPT2rQEDBlJfubhs3jsMfw==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.27.4': resolution: {integrity: sha512-qyyprhyGb7+RBfMPeww9FlHwKkCXdKHeGgSqmIXw9VSUtvyFZ6WZRtnxgbuz76FK7LyoN8t/eINRbPUcvXB5fw==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.34.8': resolution: {integrity: sha512-xAQCAHPj8nJq1PI3z8CIZzXuXCstquz7cIOL73HHdXiRcKk8Ywwqtx2wrIy23EcTn4aZ2fLJNBB8d0tQENPCmw==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.27.4': resolution: {integrity: sha512-PFz+y2kb6tbh7m3A7nA9++eInGcDVZUACulf/KzDtovvdTizHpZaJty7Gp0lFwSQcrnebHOqxF1MaKZd7psVRg==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.34.8': resolution: {integrity: sha512-DdePVk1NDEuc3fOe3dPPTb+rjMtuFw89gw6gVWxQFAuEqqSdDKnrwzZHrUYdac7A7dXl9Q2Vflxpme15gUWQFA==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.27.4': resolution: {integrity: sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.34.8': resolution: {integrity: sha512-8y7ED8gjxITUltTUEJLQdgpbPh1sUQ0kMTmufRF/Ns5tI9TNMNlhWtmPKKHCU0SilX+3MJkZ0zERYYGIVBYHIA==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.27.4': resolution: {integrity: sha512-5AeeAF1PB9TUzD+3cROzFTnAJAcVUGLuR8ng0E0WXGkYhp6RD6L+6szYVX+64Rs0r72019KHZS1ka1q+zU/wUw==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-linux-x64-musl@4.34.8': resolution: {integrity: sha512-SCXcP0ZpGFIe7Ge+McxY5zKxiEI5ra+GT3QRxL0pMMtxPfpyLAKleZODi1zdRHkz5/BhueUrYtYVgubqe9JBNQ==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.27.4': resolution: {integrity: sha512-yOpVsA4K5qVwu2CaS3hHxluWIK5HQTjNV4tWjQXluMiiiu4pJj4BN98CvxohNCpcjMeTXk/ZMJBRbgRg8HBB6A==} @@ -1884,8 +1903,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.41.0-next.6: + resolution: {integrity: sha512-BrbY3z2l96tlIRUTet9sx+H1k4g06xWWX3A1oJZaAAcSMfHNKNOAb7dV9AFh34s4Hz9dlr8jeAZxHgCGgAhozw==} peerDependencies: '@babel/core': ^7.20.12 @@ -1904,10 +1923,14 @@ 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.15: + resolution: {integrity: sha512-eOlCy2adwWlbE7+WtU2EsNGkPkL5Q+p35BUzy7sS1vvl3tUhh9gZbg5/R+MHAT4y3D+46BgHRSTZRjKNLFZGOw==} peerDependencies: '@babel/core': ^7.0.0 + solid-js: 2.0.0-experimental.15 + peerDependenciesMeta: + solid-js: + optional: true balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -3682,6 +3705,7 @@ packages: whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} + deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation whatwg-mimetype@4.0.0: resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} @@ -5418,7 +5442,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.41.0-next.6(@babel/core@7.26.0): dependencies: '@babel/core': 7.26.0 '@babel/helper-module-imports': 7.18.6 @@ -5452,10 +5476,12 @@ snapshots: transitivePeerDependencies: - supports-color - babel-preset-solid@1.9.3(@babel/core@7.26.0): + babel-preset-solid@2.0.0-experimental.15(@babel/core@7.26.0)(solid-js@1.9.4): 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.41.0-next.6(@babel/core@7.26.0) + optionalDependencies: + solid-js: 1.9.4 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,