next.js
c1262aa9 - Fix false-positive `"use cache"` misplacement error (#79151)

Commit
1 year ago
Fix false-positive `"use cache"` misplacement error (#79151) This fixes an error where we incorrectly showed the following compiler error when using Turbopack: ```sh Ecmascript file had an error > 1 | 'use cache' | ^^^^^^^^^^^ 2 | 3 | import { useStuff } from './client-module' 4 | The "use cache" directive must be at the top of the file. ``` The directive was regarded as not being at the top of the file, because the React transform (`EcmascriptInputTransform::React`) injects a variable declaration for React Refresh (e.g. `var _s = __turbopack_context__.k.signature`) at the top of the file, before the `"use cache"` directive. We can fix this by ensuring that the server action transform (should really be called "server _function_ transform") runs first. As a consequence, the transform now needs to be able to parse JSX AST nodes, which was already explicitly implemented. closes NAR-130
Author
Parents
Loading