Skip to content
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

jsx breaking when using <X.A /> and <A /> #7141

Closed
tony-g opened this issue Oct 20, 2021 · 1 comment
Closed

jsx breaking when using <X.A /> and <A /> #7141

tony-g opened this issue Oct 20, 2021 · 1 comment

Comments

@tony-g
Copy link

tony-g commented Oct 20, 2021

馃悰 bug report

Parcel appears to be breaking when I use both e.g. <Layout.WidgetRed> and <WidgetRed>

//////////////////////
// layout.jsx
//////////////////////
function WidgetRed({ children }) {
  return <div style={{ backgroundColor: 'red' }}>{children}</div>
}

export const Layout = { WidgetRed }

//////////////////////
// widget.jsx
//////////////////////
export function WidgetRed() {
  return (
    <div style={{ backgroundColor: 'white', color: 'red' }}>Something red</div>
  )
}

//////////////////////
// index.jsx
//////////////////////
import { render } from 'react-dom'
import { Layout } from './layout'
import { WidgetRed } from './widget'

render(
  <Layout.WidgetRed>
    <WidgetRed />
  </Layout.WidgetRed>,
  document.getElementById('root')
)

馃帥 Configuration (.babelrc, package.json, cli command)

  • No babelrc, or parcelrc
{
  "name": "parcel-jsx-import",
  "version": "1.0.0",
  "source": "src/index.html",
  "license": "MIT",
  "browserslist": "Chrome 88",
  "scripts": {
    "start": "parcel",
    "build": "parcel build",
    "clean": "rm -rf .parcel-cache dist"
  },
  "dependencies": {
    "parcel": "^2.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

馃 Expected Behavior

2.0.0-rc.0 produces:

var _jsxRuntime = require("react/jsx-runtime");
var _reactDom = require("react-dom");
var _layout = require("./layout");
var _widget = require("./widget");
_reactDom.render(/*#__PURE__*/ _jsxRuntime.jsx(_layout.Layout.WidgetRed,
...

馃槸 Current Behavior

2.0.0 produces:

var _jsxRuntime = require("react/jsx-runtime");
var _reactDom = require("react-dom");
var _layout = require("./layout");
var _widget = require("./widget");
_reactDom.render(/*#__PURE__*/ _jsxRuntime.jsx(_layout.Layout._widget.WidgetRed,
...

It seems to be inserting an extra _widget in _layout.Layout._widget.WidgetRed, which of course crashes:

馃拋 Possible Solution

Not sure? :)

馃敠 Context

  • Works as expected with 2.0.0-rc.0
  • I tried to try the nightly, but was getting an error about incompatible version between parcel and reporter-cli, and couldn't get it to run. (I tried installing the nightly of @parcel/reporter-cli, but that didn't seem to help.)
  • Appears to repro for both serve and build.

馃捇 Code Sample

Here's a repo that produces the snippets pasted above: https://github.com/tony-g/parcel-jsx-import

馃實 Your Environment

Software Version(s)
Parcel 2.0.0
Node 14.18.0
npm/Yarn 1.22.15
Operating System macOS 10.15.17
@mischnic
Copy link
Member

This is already fixed in the nightly version. Duplicate of #7094

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants