New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoinstalling react: Unexpected token #2519
Comments
I think if it was |
@lustoykov this should also work with Sent with GitHawk |
For the protocol, using a normal import React from 'react';
import ReactDOM from 'react-dom';
const MyComponent = () => (
React.createElement('div', null, 'Hello')
);
ReactDOM.render(
React.createElement(MyComponent, null, null),
document.getElementById('root')
); |
I think babel is not even able to generate
So one possible (but pretty ugly) solution would be to add an additional check if the contents of the asset include This would enable Do you see some better options? |
Always using @babel/plugin-syntax-jsx ? |
Dependencies have been collected before transform runs, so in theory the jsx check could check if react or preact is a dependency and enable the correct babel plugin. This would probably even make the jsx extension check obsolete as react should be imported on every file using jsx afaik |
my bad, that's correct, however parcel fails on Here is what I see - an asset starts with
There we can see in order await this.pretransform(); // Fails, See (*)
await this.getDependencies(); // Only then parcel would collects dependencies
await this.transform();
|
@lustoykov you're right forgot for a second Babel can't create an ast with jsx by default. Than I'm not sure how to fix this, besides from catching errors and retrying after the install finished which parcel should kinda already though. Should be a fairly easy fix I think |
The PR added autoinstall (that part works), but on the invocation where react is installed, several similar errors are printed (console and server):
The path is somehow duplicated. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
馃悰 bug report
Autoinstalling react doesn't work in a "completely clean" project.
馃帥 Configuration (.babelrc, package.json, cli command)
No babelrc, no package.json
馃 Expected Behavior
Parcel should install react, react-dom and then bundle.
馃槸 Current Behavior
Parcel doesn't recognize the JSX syntax?
馃拋 Possible Solution
Workaround: install
react
as a dependency. Runningparcel index.html
will then corretly installreact-dom
and build successfully.馃捇 Code Sample
index.js
Command:
馃實 Your Environment
The text was updated successfully, but these errors were encountered: