@tarojs/helper 4.0.0-beta.0 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/esbuild/index.js +2 -2
  2. package/dist/esbuild/index.js.map +1 -1
  3. package/dist/utils.d.ts +3 -3
  4. package/dist/utils.js +3 -6
  5. package/dist/utils.js.map +1 -1
  6. package/package.json +4 -3
  7. package/swc/.gitkeep +0 -0
  8. package/swc/swc_plugin_compile_mode.wasm +0 -0
  9. package/swc/swc_plugin_define_config.wasm +0 -0
  10. package/swc/plugin-compile-mode/.cargo/config +0 -5
  11. package/swc/plugin-compile-mode/.editorconfig +0 -6
  12. package/swc/plugin-compile-mode/.vscode/settings.json +0 -3
  13. package/swc/plugin-compile-mode/Cargo.lock +0 -2021
  14. package/swc/plugin-compile-mode/Cargo.toml +0 -22
  15. package/swc/plugin-compile-mode/package.json +0 -15
  16. package/swc/plugin-compile-mode/src/lib.rs +0 -71
  17. package/swc/plugin-compile-mode/src/tests/attributes.rs +0 -54
  18. package/swc/plugin-compile-mode/src/tests/children.rs +0 -86
  19. package/swc/plugin-compile-mode/src/tests/condition.rs +0 -50
  20. package/swc/plugin-compile-mode/src/tests/entry.rs +0 -20
  21. package/swc/plugin-compile-mode/src/tests/harmony/attributes.rs +0 -45
  22. package/swc/plugin-compile-mode/src/tests/harmony/children.rs +0 -74
  23. package/swc/plugin-compile-mode/src/tests/harmony/condition.rs +0 -79
  24. package/swc/plugin-compile-mode/src/tests/harmony/entry.rs +0 -67
  25. package/swc/plugin-compile-mode/src/tests/harmony/looping.rs +0 -62
  26. package/swc/plugin-compile-mode/src/tests/harmony/mod.rs +0 -45
  27. package/swc/plugin-compile-mode/src/tests/looping.rs +0 -84
  28. package/swc/plugin-compile-mode/src/tests/mod.rs +0 -100
  29. package/swc/plugin-compile-mode/src/tests/shake.rs +0 -27
  30. package/swc/plugin-compile-mode/src/transform.rs +0 -474
  31. package/swc/plugin-compile-mode/src/transform_harmony.rs +0 -526
  32. package/swc/plugin-compile-mode/src/utils/constants.rs +0 -152
  33. package/swc/plugin-compile-mode/src/utils/harmony/components.rs +0 -61
  34. package/swc/plugin-compile-mode/src/utils/harmony/mod.rs +0 -1
  35. package/swc/plugin-compile-mode/src/utils/mod.rs +0 -347
  36. package/swc/plugin-compile-mode/target/wasm32-wasi/release/swc_plugin_compile_mode.wasm +0 -0
  37. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_handle_events.js +0 -8
  38. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_keep_static_attrs_only_in_templates.js +0 -8
  39. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_turn_dynamic_attrs.js +0 -11
  40. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_native_component.js +0 -7
  41. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_react_component.js +0 -7
  42. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_fragment.js +0 -44
  43. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_render_fn.js +0 -8
  44. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_and_expr.js +0 -14
  45. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_conditional_expr.js +0 -15
  46. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/entry.rs/should_support_multi_compile_mode.js +0 -10
  47. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_handle_events.js +0 -183
  48. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_turn_dynamic_attrs.js +0 -186
  49. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_render_react_component.js +0 -76
  50. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_fragment.js +0 -341
  51. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_render_fn.js +0 -186
  52. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_and_expr.js +0 -211
  53. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_complex_condition.js +0 -244
  54. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_and_unkonw_component.js +0 -139
  55. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_expr.js +0 -344
  56. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_compile_child_node.js +0 -141
  57. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_component_not_in_config.js +0 -91
  58. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_multi_compile_mode.js +0 -209
  59. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_single_compile_mode.js +0 -66
  60. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -76
  61. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt_and_set_parent_dynamic_id.js +0 -89
  62. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_function_expr.js +0 -86
  63. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -8
  64. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_expr.js +0 -6
  65. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_function_expr.js +0 -20
  66. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_support_nested_loop.js +0 -15
  67. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/shake.rs/should_static_jsx_being_shaked.js +0 -20
  68. package/swc/plugin-define-config/.cargo/config +0 -5
  69. package/swc/plugin-define-config/Cargo.lock +0 -2110
  70. package/swc/plugin-define-config/Cargo.toml +0 -18
  71. package/swc/plugin-define-config/src/lib.rs +0 -141
  72. package/swc/plugin-define-config/target/wasm32-wasi/release/swc_plugin_define_config.wasm +0 -0
  73. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_app.js +0 -2
  74. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_page.js +0 -2
  75. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_exports.js +0 -11
  76. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_app.js +0 -3
  77. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_page.js +0 -3
@@ -1,18 +0,0 @@
1
- [package]
2
- name = "swc-plugin-define-config"
3
- version = "0.2.0"
4
- edition = "2021"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
-
9
- [profile.release]
10
- lto = true
11
-
12
- [dependencies]
13
- serde = "1"
14
- swc_core = { version = "0.86.*", features = ["ecma_plugin_transform", "__utils"] }
15
-
16
- # .cargo/config defines few alias to build plugin.
17
- # cargo build-wasi generates wasm-wasi32 binary
18
- # cargo build-wasm32 generates wasm32-unknown-unknown binary.
@@ -1,141 +0,0 @@
1
- use swc_core::{
2
- ecma::{
3
- ast::*,
4
- transforms::testing::test,
5
- visit::{as_folder, FoldWith, VisitMut, VisitMutWith},
6
- utils::{quote_ident, FunctionFactory, prepend_stmt},
7
- },
8
- common::{DUMMY_SP as span, SyntaxContext },
9
- plugin::{plugin_transform, proxies::TransformPluginProgramMetadata},
10
- };
11
-
12
- struct DefineConfigVisitor {
13
- fn_name: Option<Ident>
14
- }
15
-
16
- impl VisitMut for DefineConfigVisitor {
17
- fn visit_mut_call_expr(&mut self, expr: &mut CallExpr) {
18
- expr.visit_mut_children_with(self);
19
- if let Callee::Expr(expr) = &expr.callee {
20
- if let Expr::Ident(ident) = &**expr {
21
- if ident.sym == "defineAppConfig" || ident.sym == "definePageConfig" {
22
- self.fn_name = Some(ident.clone());
23
- }
24
- }
25
- }
26
- }
27
- }
28
-
29
- pub struct TransformVisitor;
30
-
31
- impl VisitMut for TransformVisitor {
32
- fn visit_mut_module_items(&mut self, items: &mut Vec<ModuleItem>) {
33
- let mut folder = DefineConfigVisitor { fn_name: None };
34
-
35
- let is_found = items.iter_mut().any(|item| {
36
- item.visit_mut_with(&mut folder);
37
- folder.fn_name.is_some()
38
- });
39
-
40
- if is_found {
41
- let fn_name = folder.fn_name.take().unwrap();
42
- let func = Function {
43
- span,
44
- decorators: Default::default(),
45
- params: vec![Param {
46
- span,
47
- decorators: Default::default(),
48
- pat: Pat::Ident(quote_ident!("config").into()),
49
- }],
50
- body: Some(BlockStmt {
51
- span,
52
- stmts: vec![Stmt::Return(ReturnStmt {
53
- span,
54
- arg: Some(Box::new(quote_ident!("config").into())),
55
- })],
56
- }),
57
- is_async: false,
58
- is_generator: false,
59
- type_params: None,
60
- return_type: None,
61
- };
62
- prepend_stmt(items, ModuleItem::Stmt(Stmt::Decl(Decl::Fn(func.into_fn_decl(fn_name)))));
63
- }
64
- }
65
- }
66
-
67
- /// An example plugin function with macro support.
68
- /// `plugin_transform` macro interop pointers into deserialized structs, as well
69
- /// as returning ptr back to host.
70
- ///
71
- /// It is possible to opt out from macro by writing transform fn manually
72
- /// if plugin need to handle low-level ptr directly via
73
- /// `__transform_plugin_process_impl(
74
- /// ast_ptr: *const u8, ast_ptr_len: i32,
75
- /// unresolved_mark: u32, should_enable_comments_proxy: i32) ->
76
- /// i32 /* 0 for success, fail otherwise.
77
- /// Note this is only for internal pointer interop result,
78
- /// not actual transform result */`
79
- ///
80
- /// This requires manual handling of serialization / deserialization from ptrs.
81
- /// Refer swc_plugin_macro to see how does it work internally.
82
- #[plugin_transform]
83
- pub fn process_transform(program: Program, _metadata: TransformPluginProgramMetadata) -> Program {
84
- program.fold_with(&mut as_folder(TransformVisitor))
85
- }
86
-
87
- // An example to test plugin transform.
88
- // Recommended strategy to test plugin's transform is verify
89
- // the Visitor's behavior, instead of trying to run `process_transform` with mocks
90
- // unless explicitly required to do so.
91
- test!(
92
- Default::default(),
93
- |_| as_folder(TransformVisitor),
94
- module_decl_default_app,
95
- r#"export default defineAppConfig({})"#
96
- );
97
-
98
- test!(
99
- Default::default(),
100
- |_| as_folder(TransformVisitor),
101
- module_decl_default_page,
102
- r#"export default definePageConfig({})"#
103
- );
104
-
105
- test!(
106
- Default::default(),
107
- |_| as_folder(TransformVisitor),
108
- var_decl_app,
109
- r#"
110
- const config = defineAppConfig({})
111
- export default config
112
- "#
113
- );
114
-
115
- test!(
116
- Default::default(),
117
- |_| as_folder(TransformVisitor),
118
- var_decl_page,
119
- r#"
120
- const config = definePageConfig({})
121
- export default config
122
- "#
123
- );
124
-
125
- test!(
126
- Default::default(),
127
- |_| as_folder(TransformVisitor),
128
- module_exports,
129
- r#"
130
- var require_index_config = __commonJS({
131
- "src/pages/index/index.config.ts": function(exports1, module) {
132
- var config = definePageConfig({
133
- navigationBarTitleText: "首页",
134
- usingComponents: {}
135
- });
136
- module.exports = config;
137
- }
138
- });
139
- var _default = require_index_config();
140
- "#
141
- );
@@ -1,2 +0,0 @@
1
- function defineAppConfig(config) {return config}
2
- export default defineAppConfig({})
@@ -1,2 +0,0 @@
1
- function definePageConfig(config) {return config}
2
- export default definePageConfig({})
@@ -1,11 +0,0 @@
1
- function definePageConfig(config) {return config}
2
- var require_index_config = __commonJS({
3
- "src/pages/index/index.config.ts": function(exports1, module) {
4
- var config = definePageConfig({
5
- navigationBarTitleText: "首页",
6
- usingComponents: {}
7
- });
8
- module.exports = config;
9
- }
10
- });
11
- var _default = require_index_config();
@@ -1,3 +0,0 @@
1
- function defineAppConfig(config) {return config}
2
- const config = defineAppConfig({})
3
- export default config
@@ -1,3 +0,0 @@
1
- function definePageConfig(config) {return config}
2
- const config = definePageConfig({})
3
- export default config