From 58fce340b917a252f3267af808c3677fe02e4694 Mon Sep 17 00:00:00 2001 From: Allen Zhang <37892968+zhangtao25@users.noreply.github.com> Date: Tue, 22 Oct 2024 23:34:22 +0800 Subject: [PATCH] chore(swc-plugin-canyon): update --- examples/next-swc/next.config.mjs | 4 +++- plugins/swc-plugin-canyon/src/lib.rs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/next-swc/next.config.mjs b/examples/next-swc/next.config.mjs index 0b21448e..aa797ab9 100644 --- a/examples/next-swc/next.config.mjs +++ b/examples/next-swc/next.config.mjs @@ -3,7 +3,9 @@ const nextConfig = { experimental: { swcPlugins: [ [ - 'swc-plugin-coverage-instrument', {}, + 'swc-plugin-coverage-instrument', { + ...process.env, + }, ], ], }, diff --git a/plugins/swc-plugin-canyon/src/lib.rs b/plugins/swc-plugin-canyon/src/lib.rs index 8c82e5ee..cb1e536e 100644 --- a/plugins/swc-plugin-canyon/src/lib.rs +++ b/plugins/swc-plugin-canyon/src/lib.rs @@ -99,6 +99,10 @@ impl VisitMut for TransformVisitor { } } +// https://github.com/swc-project/plugins/blob/main/packages/react-remove-properties/transform/src/lib.rs +// 暂时方案,先一股脑把环境变量都注入,例如CI_COMMIT_BRANCH、CI_COMMIT_SHA、CI_PROJECT_ID等, +// 可配置的是compareTarget + #[plugin_transform] pub fn process_transform(program: Program, metadata: TransformPluginProgramMetadata) -> Program { // 使用TransformPluginProgramMetadata获取环境变量 @@ -108,7 +112,6 @@ pub fn process_transform(program: Program, metadata: TransformPluginProgramMetad println!("env: {}", env); println!("filename: {}", filename); println!("cwd: {}", cwd); - println!("看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我看我"); program.fold_with(&mut as_folder(TransformVisitor::new())) }