Skip to content

Error minifying reactflow #10435

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

Open
isuro opened this issue May 5, 2025 · 2 comments
Open

Error minifying reactflow #10435

isuro opened this issue May 5, 2025 · 2 comments
Assignees
Labels
Milestone

Comments

@isuro
Copy link

isuro commented May 5, 2025

Describe the bug

Since SWC 1.11.9, the following fails:
node_modules/@reactflow/core/dist/esm/index.js (v11.6.0) looks like this:

...
const errorMessages = {
    '001': () => '[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001',
    '002': () => "It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",
    '003': (nodeType) => `Node type "${nodeType}" not found. Using fallback type "default".`,
    '004': () => 'The React Flow parent container needs a width and a height to render the graph.',
    '005': () => 'Only child nodes can use a parent extent.',
    '006': () => "Can't create edge. An edge needs a source and a target.",
    '007': (id) => `The old edge with id=${id} does not exist.`,
    '009': (type) => `Marker type "${type}" doesn't exist.`,
    '008': (sourceHandle, edge) => `Couldn't create edge for ${!sourceHandle ? 'source' : 'target'} handle id: "${!sourceHandle ? edge.sourceHandle : edge.targetHandle}", edge id: ${edge.id}.`,
    '010': () => 'Handle: No node id found. Make sure to only use a Handle inside a custom Node.',
    '011': (edgeType) => `Edge type "${edgeType}" not found. Using fallback type "default".`,
};

const zustandErrorMessage = errorMessages['001']();
...

However, when swc minifies it, errorMessages becomes an empty object, and attempts to call the methods inside it fail (TypeError: errorMessages['001'] is not a function).

Input code

Config

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.11.22&code=H4sIAAAAAAAAA0WOMQuDMBCFd3%2FFwykB0b3i2NUWOopIsKcNaE6S2EXy3xsl0Jvu3ffu7olpN6PXbCCogJY4MqCqkA85LBm1EjxDGfYfsri0WhxHtll67yNF%2B1dZDGhid5YQQqPBEWRnyvbR3vtTJQhsi%2FIT2%2FUGddEikSDP93UWJZUz%2BWfyxeV%2FRJkOpYDaYdXOaTNf05GN44XKhWcxdL70%2FPI2QiF7GQ2hzoIUsv4Bn3aC4PMAAAA%3D&config=H4sIAAAAAAAAA32UwZLbMAiG73mKjM8999AH6PTSZ9AoFnKUSsIjUDaenbx7sWM72Q32zebjBwkQn4fjsblQ2%2Fw6fsqn%2FPS2EJT1Xyw0ZLY3sTTQJkttCT03PxZ6oRF5Gwkm0%2F1BmohIsJDZlkIOfniN3WLqCxC92MRqS1cTZKav%2BpkV%2FBgBl%2FpqPyFGsHmHGEsmZIYOiha4xRhtT2CutihRxpPaEgi1FCOsDM70BXuVZxc4YJac79SBdaZFBwoKBVoOV9BkkktkmeR6yn0m7OBUu27q5zc1XG2slpWccJtaIqdVop4xEBtfs1bCB9yowQPOxf2uDN4U4Fryu%2B6CIW%2F05B%2BAVCBaomwTaHEnDy%2FztKX2u8qQvYwsDwqX%2BdZumaGTopoQvFLZsTJQOGjdLOBqC2NlW%2B04M94oHwUHBryXWVFC00fg9qwl5aEH9AqQ%2FlqvTdUDmPUVbvDxQezg33JL1gds9kiWz9uUhnTCuJMgAZ%2FR7ThIKxi3cZEtceu3ec0OZDTAqS6VJvC%2BBOQBMJoIrM2GPA%2BJaLqIp%2BeamB3u675NNnfP9%2F5l5cKNociK%2BQOxf9lxh9mjSejqJJ1X%2Fdj9aa3Tz%2BbptOzo9VpNoL%2BLcjl0A%2Fm6Bhq1h%2Ft%2F5JlPJEsGAAA%3D

SWC Info output

No response

Expected behavior

SWC should retain the contents of errorMessages when minifying, since it is used.

Actual behavior

errorMessages becomes an empty object.

Version

>1.11.8

Additional context

No response

@kdy1
Copy link
Member

kdy1 commented May 6, 2025

Can you provide a valid reproduction?

https://play.swc.rs/?version=1.11.24&code=H4sIAAAAAAAAA5VUXU%2FbMBR951fcdZUCEkph7DNTN02ICR5g0saeEBImvk28ur6R7VCg6n%2FftZ00pdrLoki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bgdF9LL%2FLsAoWSOeYzdWCctsWBgEIFS%2BEMkhnHYrOMnJ6Qz4QdHFrXTf38Zg1nE5shISZcppbwawWvxxKQtG9ZKuEMV2oww6W43y2D1xWo1fxsdyohr%2FTkHwBXIBrEbBJIficNz%2FO0Zu03LUP2PLI0CJznW8oyQ8dF1SF4obJjZaBSkLpZwTULY2Wt9JwFr5QPgwMN3vOsCK7xPZA9SkFp6KF4AXB%2FjZemagb6voUrfFyIDfzKWZI8YItGMnRcpzikQ4kbARLQsbgNBW4FlXVc%2BUpc%2BnXesgMeDXCiSsMJPB8BXgAqOgJJs8HrwR51F8vh80wsCtf7vU0md5%2F7%2FuXkwoWg8ol5g9g%2F3ThFvAVTYAX48vPll9otlioV1yaXy1%2FAOBWz3u8HpdvtvvtUAf%2FeLJdkdtf%2F3%2B3aklEGAAA%3D

Your repro link also does not seem to reproduce the error

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2025
@GiveMe-A-Name
Copy link
Collaborator

I found a valid reproduction. More detail see: swc playground demo
It seems a swc bug, i can try to fix it.

@kdy1 kdy1 reopened this May 7, 2025
@GiveMe-A-Name GiveMe-A-Name self-assigned this May 7, 2025
@kdy1 kdy1 modified the milestones: Planned, v1.11.26 May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants