From 155267831efbe01bf1015366bd790aa9c4f6aa5e Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Wed, 14 Feb 2024 10:14:05 -0800 Subject: [PATCH] emergency temporary revert of solid-refresh --- .changeset/five-mayflies-stare.md | 5 ++++ package.json | 2 +- pnpm-lock.yaml | 9 ++++--- src/index.ts | 43 +++++++------------------------ tsconfig.json | 2 +- 5 files changed, 21 insertions(+), 40 deletions(-) create mode 100644 .changeset/five-mayflies-stare.md diff --git a/.changeset/five-mayflies-stare.md b/.changeset/five-mayflies-stare.md new file mode 100644 index 0000000..92d90f4 --- /dev/null +++ b/.changeset/five-mayflies-stare.md @@ -0,0 +1,5 @@ +--- +'vite-plugin-solid': patch +--- + +emergency temporary revert of solid-refresh diff --git a/package.json b/package.json index e8d0362..af7cfc2 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@types/babel__core": "^7.20.4", "babel-preset-solid": "^1.8.4", "merge-anything": "^5.1.7", - "solid-refresh": "^0.7.4", + "solid-refresh": "^0.6.3", "vitefu": "^0.2.5" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bd20a17..8d6e28f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ dependencies: specifier: ^5.1.7 version: 5.1.7 solid-refresh: - specifier: ^0.7.4 - version: 0.7.4(solid-js@1.8.14) + specifier: ^0.6.3 + version: 0.6.3(solid-js@1.8.14) vitefu: specifier: ^0.2.5 version: 0.2.5(vite@5.1.1) @@ -3828,12 +3828,13 @@ packages: seroval: 1.0.4 seroval-plugins: 1.0.4(seroval@1.0.4) - /solid-refresh@0.7.4(solid-js@1.8.14): - resolution: {integrity: sha512-bYiIEAhsKb6IZbNR6RNr1dB8MrjR7nYW/57Ow3kyeEJ6mL/Q6XtORodffsdUIsSNyPI2KYH2aNNgsiHJy7vsHw==} + /solid-refresh@0.6.3(solid-js@1.8.14): + resolution: {integrity: sha512-F3aPsX6hVw9ttm5LYlth8Q15x6MlI/J3Dn+o3EQyRTtTxidepSTwAYdozt01/YA+7ObcciagGEyXIopGZzQtbA==} peerDependencies: solid-js: ^1.3 dependencies: '@babel/generator': 7.23.6 + '@babel/helper-module-imports': 7.22.15 '@babel/types': 7.23.6 solid-js: 1.8.14 dev: false diff --git a/src/index.ts b/src/index.ts index 1c197a5..03fe776 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,11 @@ import * as babel from '@babel/core'; -// @ts-ignore 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'; -// TODO use proper path -import type { Options as RefreshOptions } from 'solid-refresh/babel'; -import type { Alias, AliasOptions, FilterPattern, Plugin } from 'vite'; import { createFilter } from 'vite'; +import type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite'; import { crawlFrameworkPkgs } from 'vitefu'; const require = createRequire(import.meta.url); @@ -54,7 +51,6 @@ export interface Options { * 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. * - * @deprecated use `refresh` instead * @default true */ hot: boolean; @@ -146,8 +142,6 @@ export interface Options { */ builtIns?: string[]; }; - - refresh: Omit; } function getExtension(filename: string): string { @@ -194,7 +188,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { async config(userConfig, { command }) { // We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode replaceDev = options.dev === true || (options.dev !== false && command === 'serve'); - projectRoot = userConfig.root || projectRoot; + projectRoot = userConfig.root; if (!userConfig.resolve) userConfig.resolve = {}; userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias); @@ -261,7 +255,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { }, configResolved(config) { - needHmr = config.command === 'serve' && config.mode !== 'production' && (options.hot !== false && !options.refresh?.disabled); + needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false; }, resolveId(id) { @@ -313,19 +307,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { return extensionOptions.typescript; }); - const plugins: NonNullable['plugins']> = [ - 'jsx', - // import { example } from 'example' with { example: true }; - 'importAttributes', - // () => throw example - 'throwExpressions', - // You know what this is - 'decorators', - // const { #example: example } = this; - 'destructuringPrivate', - // using example = myExample() - 'explicitResourceManagement', - ]; + const plugins: NonNullable['plugins']> = ['jsx'] if (shouldBeProcessedWithTypescript) { plugins.push('typescript'); @@ -336,12 +318,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { filename: id, sourceFileName: id, presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]], - plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { - bundler: 'vite', - fixRender: true, - imports: options.refresh?.imports, - granular: options.refresh?.granular, - }]] : [], + plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [], ast: false, sourceMaps: true, configFile: false, @@ -356,7 +333,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { if (options.babel) { if (typeof options.babel === 'function') { - const babelOptions = options.babel(source, id, !!isSsr); + const babelOptions = options.babel(source, id, isSsr); babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions; } else { babelUserOptions = options.babel; @@ -365,11 +342,9 @@ export default function solidPlugin(options: Partial = {}): Plugin { const babelOptions = mergeAndConcat(babelUserOptions, opts) as babel.TransformOptions; - const result = await babel.transformAsync(source, babelOptions); - if (!result) { - return undefined; - } - return { code: result.code || '', map: result.map }; + const { code, map } = await babel.transformAsync(source, babelOptions); + + return { code, map }; }, }; } diff --git a/tsconfig.json b/tsconfig.json index 8553d37..6ba9e23 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "node", - "strict": true, + "strict": false, "declaration": true, "noUnusedLocals": true, "skipLibCheck": true,