Skip to content

Commit 1552678

Browse files
committed
emergency temporary revert of solid-refresh
1 parent 0051fb0 commit 1552678

File tree

5 files changed

+21
-40
lines changed

5 files changed

+21
-40
lines changed

.changeset/five-mayflies-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vite-plugin-solid': patch
3+
---
4+
5+
emergency temporary revert of solid-refresh

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@types/babel__core": "^7.20.4",
4646
"babel-preset-solid": "^1.8.4",
4747
"merge-anything": "^5.1.7",
48-
"solid-refresh": "^0.7.4",
48+
"solid-refresh": "^0.6.3",
4949
"vitefu": "^0.2.5"
5050
},
5151
"devDependencies": {

pnpm-lock.yaml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import * as babel from '@babel/core';
2-
// @ts-ignore
32
import solid from 'babel-preset-solid';
43
import { readFileSync } from 'fs';
54
import { mergeAndConcat } from 'merge-anything';
65
import { createRequire } from 'module';
76
import solidRefresh from 'solid-refresh/babel';
8-
// TODO use proper path
9-
import type { Options as RefreshOptions } from 'solid-refresh/babel';
10-
import type { Alias, AliasOptions, FilterPattern, Plugin } from 'vite';
117
import { createFilter } from 'vite';
8+
import type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite';
129
import { crawlFrameworkPkgs } from 'vitefu';
1310

1411
const require = createRequire(import.meta.url);
@@ -54,7 +51,6 @@ export interface Options {
5451
* This will inject HMR runtime in dev mode. Has no effect in prod. If
5552
* set to `false`, it won't inject the runtime in dev.
5653
*
57-
* @deprecated use `refresh` instead
5854
* @default true
5955
*/
6056
hot: boolean;
@@ -146,8 +142,6 @@ export interface Options {
146142
*/
147143
builtIns?: string[];
148144
};
149-
150-
refresh: Omit<RefreshOptions & { disabled: boolean }, 'bundler' | 'fixRender'>;
151145
}
152146

153147
function getExtension(filename: string): string {
@@ -194,7 +188,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
194188
async config(userConfig, { command }) {
195189
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
196190
replaceDev = options.dev === true || (options.dev !== false && command === 'serve');
197-
projectRoot = userConfig.root || projectRoot;
191+
projectRoot = userConfig.root;
198192

199193
if (!userConfig.resolve) userConfig.resolve = {};
200194
userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
@@ -261,7 +255,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
261255
},
262256

263257
configResolved(config) {
264-
needHmr = config.command === 'serve' && config.mode !== 'production' && (options.hot !== false && !options.refresh?.disabled);
258+
needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;
265259
},
266260

267261
resolveId(id) {
@@ -313,19 +307,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
313307

314308
return extensionOptions.typescript;
315309
});
316-
const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = [
317-
'jsx',
318-
// import { example } from 'example' with { example: true };
319-
'importAttributes',
320-
// () => throw example
321-
'throwExpressions',
322-
// You know what this is
323-
'decorators',
324-
// const { #example: example } = this;
325-
'destructuringPrivate',
326-
// using example = myExample()
327-
'explicitResourceManagement',
328-
];
310+
const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = ['jsx']
329311

330312
if (shouldBeProcessedWithTypescript) {
331313
plugins.push('typescript');
@@ -336,12 +318,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
336318
filename: id,
337319
sourceFileName: id,
338320
presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],
339-
plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
340-
bundler: 'vite',
341-
fixRender: true,
342-
imports: options.refresh?.imports,
343-
granular: options.refresh?.granular,
344-
}]] : [],
321+
plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],
345322
ast: false,
346323
sourceMaps: true,
347324
configFile: false,
@@ -356,7 +333,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
356333

357334
if (options.babel) {
358335
if (typeof options.babel === 'function') {
359-
const babelOptions = options.babel(source, id, !!isSsr);
336+
const babelOptions = options.babel(source, id, isSsr);
360337
babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
361338
} else {
362339
babelUserOptions = options.babel;
@@ -365,11 +342,9 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
365342

366343
const babelOptions = mergeAndConcat(babelUserOptions, opts) as babel.TransformOptions;
367344

368-
const result = await babel.transformAsync(source, babelOptions);
369-
if (!result) {
370-
return undefined;
371-
}
372-
return { code: result.code || '', map: result.map };
345+
const { code, map } = await babel.transformAsync(source, babelOptions);
346+
347+
return { code, map };
373348
},
374349
};
375350
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"target": "ESNext",
1010
"module": "ESNext",
1111
"moduleResolution": "node",
12-
"strict": true,
12+
"strict": false,
1313
"declaration": true,
1414
"noUnusedLocals": true,
1515
"skipLibCheck": true,

0 commit comments

Comments
 (0)