turbo
b9e5e6d7 - feat(turbopack-ecmascript): accept transform plugin in moduleoptioncontext (#4721)

Commit
2 years ago
feat(turbopack-ecmascript): accept transform plugin in moduleoptioncontext (#4721) ### Description - Relates with WEB-955, WEB-848. This PR is a part of implementing WEB-848, supporting relay graphql transform in next.js. Historically we've been expanding `ModuleOptionContext` to have each own config (`enable_mdx`, `enable_emotion`...) but with new CustomTransformPlugin we can pass actual transforms instead, what WEB-955 aims. PR introduces new config option `custom_ecma_transform_plugins` to the ModuleOptionContext to support it. `custom_ecma_transform_plugins` is a struct have two fields, `before` / `after` which allows to specify order of custom transforms if it should be invoked _before_ any core transform kicks in, or otherwise. This effectively deprecates existing options, notably `custom_ecmascript_transforms` and `custom_ecmascript_app_transforms`. It is currently not actively being used (next-swc have 2 places utilizing `custom_ecmascript_transforms`), we can consolidate to the new option instead. One another notable change is customtransformer's transform is now async fn. It is due to `TransformContext` have couple of `Vc` properties, that cannot be accessed in a sync transform fn. Refer counterpart next.js PR (https://github.com/vercel/next.js/pull/48899/files#diff-c0df3b5a390436575f35365774b078cb5303ef395b064b8992dfdd7dba8f3691) as ref.
Author
Parents
Loading