esifycss icon indicating copy to clipboard operation
esifycss copied to clipboard

TypeError at ast.js:6:43

Open donmanguno opened this issue 10 months ago • 0 comments

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).

donmanguno avatar Mar 10 '25 20:03 donmanguno