Skip to content

TypeError at ast.js:6:43 #783

@donmanguno

Description

@donmanguno

I'm trying to build a project locally, a project I didn't write, and this is my first time using svelte, or rollup, or esifycss. I'm using esifycss via rollup-plugin-embed-css, on which step the build fails with the stacktrace below.

TypeError: Cannot read properties of null (reading 'type')
    at isObjectExpression (/.../node_modules/esifycss/lib/minifier/ast.js:6:43)
    at extractCSSFromArrayExpression (/.../node_modules/esifycss/lib/minifier/extractCSSFromArrayExpression.js:9:46)
    at ExpressionStatement (/.../node_modules/esifycss/lib/minifier/parseCSSModuleScript.js:24:102)
    at c (/.../node_modules/acorn-walk/dist/walk.js:30:20)
    at Object.skipThrough (/.../node_modules/acorn-walk/dist/walk.js:186:39)

I'm able to resolve it by simply editing /minifier/ast.js to use optional chaining:

const isObjectExpression = (node) => node?.type === 'ObjectExpression';

Would changing this behavior break something? Seems to me that if node is undefined or null isObjectExpression should be as well (as well as isProgramNode and isArrayExpression).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions