Skip to content

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

@orzechowskid

Description

@orzechowskid

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions