Skip to content

Bad state error when using meta.apply and compile with render #2151

@bluwy

Description

@bluwy

When using the deprecated render API to process sass files (Vite still uses it), and also using meta.apply, it fails with (raw log):

Error: Bad state: Can't access __parent outside of a module.
    at Object.wrapException (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:1252:43)
    at _EvaluateVisitor2._async_evaluate0$_assertInModule$1$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:80473:15)
    at _EvaluateVisitor2._async_evaluate0$_assertInModule$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:80476:19)
    at /Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:81047:34
    at _wrapJsFunctionForAsync_closure.$protected (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:4022:15)
    at _wrapJsFunctionForAsync_closure.call$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:33914:12)
    at _awaitOnObject_closure.call$1 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:33902:32)
    at Object._rootRunUnary (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:4408:18)
    at StaticClosure.<anonymous> (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:115526:16)
    at _CustomZone.runUnary$2$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:35338:39)

Using compileString works fine. I'm not sure if it is intentional that this new feature doesn't work with the deprecated render API, but if so I think that's fair and just checking here.

Here's a repro comparing compileString and render: https://stackblitz.com/edit/stackblitz-starters-tirkhu?file=index.js (run node index.js to see error)

This was originally reported at vitejs/vite#15443

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions