swc
swc copied to clipboard
Import/Export order of cjs
Describe the bug
Is not possible to export destructuring in nextjs with swc, it throw that reference is undefined.
Input code
import '.';
import emotionStyled from '@emotion/styled';
import { breakpoinstUtils } from '@eduzz/houston-tokens/variables/breakpoints';
export { keyframes, cx, cx as clsx } from '@emotion/css';
export interface IStyledProp {
className?: string;
}
export const breakpoints = breakpoinstUtils;
const styled = emotionStyled;
export default styled;
Config
{
"test": ".*\\.tsx?$",
"exclude": [".*.js$", ".*.map$", "node_modules", "build"],
"module": {
"type": "commonjs"
},
"jsc": {
"externalHelpers": true,
"target": "es5",
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": {
"runtime": "automatic"
}
},
"keepClassNames": true
}
}
Playground link
https://play.swc.rs/?version=1.2.172&code=H4sIAAAAAAAAA0utKMgvKlGoVkhUqFVIK8rPVVAvSS0uSVW3BgCgr0PxGgAAAA%3D%3D&config=H4sIAAAAAAAAA0WMSwrDMAxE76K1t93kDj2EcJXg4B8aBWqM714bUrKSmPdmOp3wtHWqrBBdH1o2%2FtJG4hPDa6hGbmoz2jlChiNjPcSWgtdksRTITR2lkMPe1pIvqaoAD%2BJ8xL855lAqn2sFnazVeVcllXyCxjN0lwPet216yfgBCKaI9boAAAA%3D
Expected behavior
The require imports should be before the exports.
Actual behavior
TypeError: undefined is not an object (evaluating '_css.keyframes')
Version
1.2.172
Additional context
"@swc/cli": "0.1.57" "@swc/core": "1.2.172" "@swc/helpers": "0.3.8"
Cannot reproduce this issue. Could you provide a minimal sample code?
It is helpful if there is no external package dependencies.
Closing as more information required. If this is still an issue, please open a new issue with required forms filled