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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shaker fails on export default of function with no name #1434

Open
orzechowskid opened this issue Feb 14, 2025 · 0 comments
Open

shaker fails on export default of function with no name #1434

orzechowskid opened this issue Feb 14, 2025 · 0 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@orzechowskid
Copy link

Environment

@linaria/[email protected]
@wyw-in-js/[email protected]
[email protected]
[email protected]
node.js @ 22.11.0

Description

I have some code which uses d3 to create a force-directed graph. this code appears to work just fine in vite's dev mode, but when building for production I encounter this error:

[wyw-in-js] /Users/<user>/repos/graph-test/frontend/node_modules/d3-force/src/simulation.js: Cannot read properties of null (reading 'name')
file: /Users/<user>/repos/graph-test/frontend/src/pages/Graph/components/GraphVisualization.tsx
error during build:
TypeError: /Users/<user>/repos/graph-test/frontend/node_modules/d3-force/src/simulation.js: Cannot read properties of null (reading 'name')
    at getBindingForExport (/Users/<user>/repos/graph-test/frontend/node_modules/@wyw-in-js/transform/lib/plugins/shaker.js:37:59)
    at PluginPass.pre (/Users/<user>/repos/graph-test/frontend/node_modules/@wyw-in-js/transform/lib/plugins/shaker.js:234:29)

the line of d3-force/src/simulation.js referenced in the stack trace is this:

export default function(nodes) {

i.e. a default export of type function with no name applied to it.

manually editing d3-force/src/simulation.js and providing a name to that function allows my build to succeed:

export default function foo(nodes) {

fwiw this bug is also present with linaria 5 + @linaria/shaker . I haven't checked older versions.

@orzechowskid orzechowskid added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Feb 14, 2025
@github-actions github-actions bot removed the needs: triage 🏷 Issue needs to be checked and prioritized label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

1 participant