next.js
775e8986 - feat(next-core): build time client|server-only assertion (#61732)

Commit
2 years ago
feat(next-core): build time client|server-only assertion (#61732) ### What This PR injects a build-time error for the turbopack if `client|server-only` is imported in incorrect context. The basic idea is using resolve plugin, so in resolve time if matching context (which alises erroneous import), raise a build time error. Unfortunately this won't fix all of the tests in `invalid-imports`, due to 1. resolveplugin does not have way to trace import from transformed, so not able to detect `styled-jsx` from using `<styled..` tags 2. webpack (in our implementation) and turbopack's resolveplugin have different order of transform / module trace chain, so enabling resolve plugin in some context raises build error instead of runtime error in rsc-build-error. Closes PACK-2397
Author
Parents
Loading