Fix code from bad merge (#540)

* Fix code from bad merge

* Dont wrap the raw

* Wrap the expression in quotes

* remove react-dom just to test

* Add back react-dom as a known entrypoint

* Make startup time even longer
This commit is contained in:
Matthew Phillips 2021-06-25 09:29:57 -04:00 committed by GitHub
parent 56293499e8
commit 028d4e0114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View file

@ -201,7 +201,7 @@ async function compileExpression(node: Expression, state: CodegenState, compileO
}
}
const location = { start: node.start, end: node.end };
let code = transpileExpressionSafe(raw, { state, compileOptions, location });
let code = transpileExpressionSafe("(" + raw + ")", { state, compileOptions, location });
if (code === null) throw new Error(`Unable to compile expression`);
code = code.trim().replace(/\;$/, '');
return code;
@ -212,8 +212,6 @@ function transpileExpressionSafe(
raw: string,
{ state, compileOptions, location }: { state: CodegenState; compileOptions: CompileOptions; location: { start: number; end: number } }
): string | null {
// We have to wrap `raw` with parens to support primitives (objects, arrays)!
raw = `(${raw})`;
try {
let { code } = transformSync(raw, {
loader: 'tsx',
@ -457,7 +455,7 @@ const { ${props.join(', ')} } = Astro.props;\n`)
script = propsStatement + contentCode + babelGenerator(program).code;
const location = { start: module.start, end: module.end };
let transpiledScript = compileExpressionSafe(script, { state, compileOptions, location });
let transpiledScript = transpileExpressionSafe(script, { state, compileOptions, location });
if (transpiledScript === null) throw new Error(`Unable to compile script`);
script = transpiledScript;
}

View file

@ -6,7 +6,7 @@ import { loadConfig } from '#astro/config';
import execa from 'execa';
import del from 'del';
const MAX_STARTUP_TIME = 7000; // max time startup may take
const MAX_STARTUP_TIME = 14000; // max time startup may take
const MAX_TEST_TIME = 10000; // max time an individual test may take
const MAX_SHUTDOWN_TIME = 3000; // max time shutdown() may take

View file

@ -2,5 +2,5 @@ export default {
name: '@astrojs/renderer-react',
client: './client',
server: './server',
knownEntrypoints: ['react', 'react-dom/server'],
knownEntrypoints: ['react', 'react-dom', 'react-dom/server'],
};