Fixes solid (#1634)
* Fixes solid * Rename the test * Rebase with next * Skip solid test for now
This commit is contained in:
parent
06562af124
commit
8206421ffa
6 changed files with 52 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
11
packages/astro/test/fixtures/solid-component/src/components/Hello.jsx
vendored
Normal file
11
packages/astro/test/fixtures/solid-component/src/components/Hello.jsx
vendored
Normal 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>
|
||||
</>
|
||||
);
|
||||
}
|
9
packages/astro/test/fixtures/solid-component/src/pages/index.astro
vendored
Normal file
9
packages/astro/test/fixtures/solid-component/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
import Hello from '../components/Hello.jsx';
|
||||
---
|
||||
<html>
|
||||
<head><title>Solid</title></head>
|
||||
<body>
|
||||
<div><Hello /></div>
|
||||
</body>
|
||||
</html>
|
23
packages/astro/test/solid-component.test.js
Normal file
23
packages/astro/test/solid-component.test.js
Normal 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);
|
||||
});
|
||||
});
|
|
@ -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');
|
||||
|
|
|
@ -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: [],
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue