Unverified Commit f3d5c2fe authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

refactor(next-swc): turbopack_ecmascript_plugins (#48671)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change


### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

This PR is necessary changes to apply
https://github.com/vercel/turbo/pull/4662. Need turbopack bump to make
CI pass.

---------
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent b21fd966
This diff is collapsed.
...@@ -42,11 +42,11 @@ swc_relay = { version = "0.2.5" } ...@@ -42,11 +42,11 @@ swc_relay = { version = "0.2.5" }
testing = { version = "0.33.4" } testing = { version = "0.33.4" }
# Turbo crates # Turbo crates
turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.3" } turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.4" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.3" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.4" }
# [TODO]: need to refactor embed_directory! macro usage in next-core # [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.3" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.4" }
# General Deps # General Deps
......
...@@ -35,6 +35,7 @@ turbo-binding = { workspace = true, features = [ ...@@ -35,6 +35,7 @@ turbo-binding = { workspace = true, features = [
"__turbopack_dev", "__turbopack_dev",
"__turbopack_dev_server", "__turbopack_dev_server",
"__turbopack_ecmascript", "__turbopack_ecmascript",
"__turbopack_ecmascript_plugin",
"__turbopack_env", "__turbopack_env",
"__turbopack_static", "__turbopack_static",
"__turbopack_image", "__turbopack_image",
......
...@@ -47,5 +47,7 @@ pub fn register() { ...@@ -47,5 +47,7 @@ pub fn register() {
turbopack::node::register(); turbopack::node::register();
turbopack::turbopack::register(); turbopack::turbopack::register();
turbopack::image::register(); turbopack::image::register();
turbopack::ecmascript::register();
turbopack::ecmascript_plugin::register();
include!(concat!(env!("OUT_DIR"), "/register.rs")); include!(concat!(env!("OUT_DIR"), "/register.rs"));
} }
...@@ -23,6 +23,7 @@ use turbo_binding::{ ...@@ -23,6 +23,7 @@ use turbo_binding::{
ecmascript::{ ecmascript::{
EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc,
}, },
ecmascript_plugin::transform::emotion::EmotionTransformConfig,
node::{ node::{
evaluate::evaluate, evaluate::evaluate,
execution_context::{ExecutionContext, ExecutionContextVc}, execution_context::{ExecutionContext, ExecutionContextVc},
...@@ -30,7 +31,7 @@ use turbo_binding::{ ...@@ -30,7 +31,7 @@ use turbo_binding::{
}, },
turbopack::{ turbopack::{
evaluate_context::node_evaluate_asset_context, evaluate_context::node_evaluate_asset_context,
module_options::{EmotionTransformConfig, StyledComponentsTransformConfig}, module_options::StyledComponentsTransformConfig,
}, },
}, },
}; };
......
...@@ -19,8 +19,8 @@ use turbo_binding::{ ...@@ -19,8 +19,8 @@ use turbo_binding::{
turbopack::{ turbopack::{
core::reference_type::{ReferenceType, UrlReferenceSubType}, core::reference_type::{ReferenceType, UrlReferenceSubType},
ecmascript::{ ecmascript::{
CustomTransformVc, CustomTransformer, EcmascriptInputTransform, CustomTransformer, EcmascriptInputTransform, EcmascriptInputTransformsVc,
EcmascriptInputTransformsVc, TransformContext, TransformContext, TransformPluginVc,
}, },
turbopack::module_options::{ turbopack::module_options::{
ModuleRule, ModuleRuleCondition, ModuleRuleEffect, ModuleType, ModuleRule, ModuleRuleCondition, ModuleRuleEffect, ModuleType,
...@@ -38,7 +38,7 @@ pub async fn get_next_pages_transforms_rule( ...@@ -38,7 +38,7 @@ pub async fn get_next_pages_transforms_rule(
) -> Result<ModuleRule> { ) -> Result<ModuleRule> {
// Apply the Next SSG transform to all pages. // Apply the Next SSG transform to all pages.
let strip_transform = let strip_transform =
EcmascriptInputTransform::Custom(CustomTransformVc::cell(box NextJsStripPageExports { EcmascriptInputTransform::Plugin(TransformPluginVc::cell(box NextJsStripPageExports {
export_filter, export_filter,
})); }));
Ok(ModuleRule::new( Ok(ModuleRule::new(
...@@ -110,7 +110,7 @@ pub async fn get_next_dynamic_transform_rule( ...@@ -110,7 +110,7 @@ pub async fn get_next_dynamic_transform_rule(
pages_dir: Option<FileSystemPathVc>, pages_dir: Option<FileSystemPathVc>,
) -> Result<ModuleRule> { ) -> Result<ModuleRule> {
let dynamic_transform = let dynamic_transform =
EcmascriptInputTransform::Custom(CustomTransformVc::cell(box NextJsDynamic { EcmascriptInputTransform::Plugin(TransformPluginVc::cell(box NextJsDynamic {
is_development, is_development,
is_server, is_server,
is_server_components, is_server_components,
...@@ -159,7 +159,7 @@ pub fn get_next_font_transform_rule() -> ModuleRule { ...@@ -159,7 +159,7 @@ pub fn get_next_font_transform_rule() -> ModuleRule {
]; ];
let transformer = let transformer =
EcmascriptInputTransform::Custom(CustomTransformVc::cell(box NextJsFont { font_loaders })); EcmascriptInputTransform::Plugin(TransformPluginVc::cell(box NextJsFont { font_loaders }));
ModuleRule::new( ModuleRule::new(
// TODO: Only match in pages (not pages/api), app/, etc. // TODO: Only match in pages (not pages/api), app/, etc.
module_rule_match_js_no_url(), module_rule_match_js_no_url(),
...@@ -229,7 +229,7 @@ pub struct ModularizeImportPackageConfig { ...@@ -229,7 +229,7 @@ pub struct ModularizeImportPackageConfig {
pub fn get_next_modularize_imports_rule( pub fn get_next_modularize_imports_rule(
modularize_imports_config: &IndexMap<String, ModularizeImportPackageConfig>, modularize_imports_config: &IndexMap<String, ModularizeImportPackageConfig>,
) -> ModuleRule { ) -> ModuleRule {
let transformer = EcmascriptInputTransform::Custom(CustomTransformVc::cell(Box::new( let transformer = EcmascriptInputTransform::Plugin(TransformPluginVc::cell(Box::new(
ModularizeImportsTransformer::new(modularize_imports_config), ModularizeImportsTransformer::new(modularize_imports_config),
))); )));
ModuleRule::new( ModuleRule::new(
......
...@@ -6,10 +6,12 @@ use turbo_binding::turbopack::{ ...@@ -6,10 +6,12 @@ use turbo_binding::turbopack::{
source_asset::SourceAssetVc, source_asset::SourceAssetVc,
}, },
ecmascript::typescript::resolve::{read_from_tsconfigs, read_tsconfigs, tsconfig}, ecmascript::typescript::resolve::{read_from_tsconfigs, read_tsconfigs, tsconfig},
ecmascript_plugin::transform::emotion::{
EmotionTransformConfig, EmotionTransformConfigVc, OptionEmotionTransformConfigVc,
},
turbopack::module_options::{ turbopack::module_options::{
DecoratorsKind, DecoratorsOptions, DecoratorsOptionsVc, EmotionTransformConfig, DecoratorsKind, DecoratorsOptions, DecoratorsOptionsVc, JsxTransformOptions,
EmotionTransformConfigVc, JsxTransformOptions, JsxTransformOptionsVc, JsxTransformOptionsVc, OptionStyledComponentsTransformConfigVc,
OptionEmotionTransformConfigVc, OptionStyledComponentsTransformConfigVc,
StyledComponentsTransformConfig, TypescriptTransformOptions, TypescriptTransformOptionsVc, StyledComponentsTransformConfig, TypescriptTransformOptions, TypescriptTransformOptionsVc,
}, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment