Open kjkent opened 4 months ago
Update: Using jsx-async-runtime
, as demonstrated in the JetBrains guide, works. However, using react-dom
as described in the docs gives the following error:
Edit 2: Now using v3.0.0-alpha.17
. With further experimentation, I've found that the docs config now works, with some changes:
react
and react-dom
are required as package.json
dependencies, even though only the latter is imported within eleventy.config.ts
. Omitting react
leads to an error like:
[11ty] Original error stack trace: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'react' imported from /path/to/project/src/index.11ty.tsx
It's worth noting that the above applies also to MDX templates; same error if react
is not installed.
"jsx": "react-jsx"
is required within tsconfig.json. Without it, Eleventy throws the following:
[11ty] Original error stack trace: ReferenceError: React is not defined
@zachleat it seems the errors from the issue and this comment (which I now realise are two different issues) are both docs-based; I'd be happy to put a PR together to address them if that's something you'd find helpful.
Operating system
Arch Linux
Eleventy
v3.0.0-alpha.14
Describe the bug
There has been plenty discussion and ongoing work around TypeScript support and pnpm support, (https://github.com/11ty/eleventy/issues/577, https://github.com/11ty/eleventy/issues/2876, https://github.com/11ty/eleventy/issues/2849) to name a few, the last of which is an intersection of the two! Not mentioned; however, is this issue I encountered trying to use TSX templates following the docs, the advice in https://github.com/11ty/eleventy/issues/577#issuecomment-1464868585, and the docs-linked guide on the JetBrains website.
When running
npx tsx node_modules/.bin/eleventy --config=eleventy.config.ts --serve
I get:I am uncertain if pnpm swaps out executables, or whether
node_modules/.bin/eleventy
is supposed to contain:As TypeScript is getting official support and PRs regarding pnpm have been merged, I thought it might be helpful to mention this error, as it's elicited by using the commands in the 11ty docs.
The workaround was to use the
cmd.cjs
file directly, as is done in the JetBrains-posted guide I link to above:npx tsx node_modules/@11ty/eleventy/cmd.cjs --config=eleventy.config.ts --serve
It was a quick fix and I hope by posting here, I can save someone a headache :)
Reproduction steps
Have the following project setup:
Please work, I beg you.
; }; ```Start the dev server with
npm start
Observe described error message in console
Replace
node_modules/.bin/eleventy
inpackage.json
withnode_modules/@11ty/eleventy/cmd.cjs
and rerunIt works!
Expected behavior
Eleventy compiles the TSX and runs the dev server.
Reproduction URL
No response
Screenshots
No response