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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid import of variables in compiled code #763
Comments
I've tested it, and it seems like the dead code elimination pass considers |
Sure. What I see here is that consts.js // Many constants
export const RESOURCE_WEBSITE = 1
export const RESOURCE_FACEBOOK = 2
export const RESOURCE_INSTAGRAM = 3 websites.jsx import {
INSTAGRAM_CHECK_PATTERN,
RESOURCE_FACEBOOK,
RESOURCE_INSTAGRAM,
RESOURCE_WEBSITE,
} from '../../../../consts'
const resources = [
{
value: RESOURCE_WEBSITE,
label: 'Webové stránky',
},
{
value: RESOURCE_FACEBOOK,
label: 'Facebook',
},
{
value: RESOURCE_INSTAGRAM,
label: 'Instagram',
},
]
@i18n()
export default class Contacts extends Component {
renderWebsites = websites => {
return websites.map((website, idx) => (
<div>
{/* Some code */}
{resources.map(resource => (<option key={resource.value} value={resource.value}>{resource.label}</option>))}
<Input
type={website.type_id === RESOURCE_INSTAGRAM ? 'text' : 'url'}
label={website.type_id === RESOURCE_INSTAGRAM ? t('eventEntity.links.instagramLabel') : t('eventEntity.links.urlTitle')}
placeholder={website.type_id === RESOURCE_INSTAGRAM ? t('eventEntity.links.instagramPlaceholder') : t('eventEntity.links.urlPlaceholder')}
value={website.value || ''}
onChange={ev => this.updateField(idx, 'websites', 'value', ev.target.value)}
onBlur={ev => this.blurWebResource(idx, website.type_id, ev.target.value)}
maxLength="255"
pattern={website.type_id === RESOURCE_INSTAGRAM && INSTAGRAM_CHECK_PATTERN}
title={website.type_id === RESOURCE_INSTAGRAM && t('eventEntity.links.instagramTitle')}
/>
</div>
))
}
render = () => {
const { websites } = this.props
return (
<Fragment>
{websites && this.renderWebsites(websites)}
</Fragment>
)
}
} |
If you need anything else, tell me. However I don't want to share any implementation details since it's a company's closed source application |
@jansedlon It's enough. Thanks! |
I've failed to reproduce it. Log
I'll investigate further |
I'll try to reproduce it as well. |
@kdy1 I was able to reproduce it. You can find it here |
It's happening only if I import those constants. If I declare them in a same file, it's okay. |
@jansedlon Thanks a lot!! In my experience, finding a bug and creating minimal reproduction for it is really hard. |
@kdy1 Haha, yeah, that's, true. I feel bad for just issuing a bug and let you do all the work so I try to help you as much as I can 😅 |
I forgot to add there a |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
SWC incorrectly imports consts from file. That's interesting because one of them is imported and other two are not.
Input code
Compiled code
Definition of constants in compiled code
Config
Expected behavior
Import every variable in a same way. Or correct one.
Version
The version of @swc/core: v1.1.41
The text was updated successfully, but these errors were encountered: