Fixes solid (#1634)

* Fixes solid

* Rename the test

* Rebase with next

* Skip solid test for now
This commit is contained in:
Matthew Phillips 2021-10-22 15:45:56 -04:00 committed by Drew Powers
parent 06562af124
commit 8206421ffa
6 changed files with 52 additions and 7 deletions

View file

@ -141,12 +141,8 @@ async function viteSSRDeps(deps: string[]): Promise<{ external: Set<string>; noE
return;
}
// if ESM, try noExternal
if (packageJSON.type === 'module') {
noExternal.add(spec);
}
// otherwise, assume external by default
else {
if (packageJSON.type !== 'module') {
external.add(spec);
}

View file

@ -0,0 +1,11 @@
import { createSignal } from 'solid-js';
export default function Counter() {
const [count] = createSignal(0);
return (
<>
<div class="hello">Hello world - {count}</div>
</>
);
}

View file

@ -0,0 +1,9 @@
---
import Hello from '../components/Hello.jsx';
---
<html>
<head><title>Solid</title></head>
<body>
<div><Hello /></div>
</body>
</html>

View file

@ -0,0 +1,23 @@
import { expect } from 'chai';
import cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
describe.skip('Solid component', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
projectRoot: './fixtures/solid-component/',
renderers: ['@astrojs/renderer-solid'],
});
await fixture.build();
});
it('Can load a component', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
// test 1: Works
expect($('.hello')).to.have.lengthOf(1);
});
});

View file

@ -4,6 +4,10 @@ import StaticHtml from './static-html.js';
const reactTypeof = Symbol.for('react.element');
function errorIsComingFromPreactComponent(err) {
return err.message && err.message.startsWith("Cannot read property '__H'");
}
function check(Component, props, children) {
if (typeof Component !== 'function') return false;
@ -20,7 +24,9 @@ function check(Component, props, children) {
isReactComponent = true;
}
} catch (err) {
error = err;
if(!errorIsComingFromPreactComponent(err)) {
error = err;
}
}
return React.createElement('div');

View file

@ -6,7 +6,7 @@ export default {
jsxTransformOptions: async ({ ssr }) => {
const [{ default: solid }] = await Promise.all([import('babel-preset-solid')]);
const options = {
presets: [solid({}, { generate: isSSR ? 'ssr' : 'dom', hydratable: true })],
presets: [solid({}, { generate: ssr ? 'ssr' : 'dom', hydratable: true })],
plugins: [],
};