@tarojs/helper 4.0.0-alpha.0 → 4.0.0-alpha.10

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 (98) hide show
  1. package/LICENSE +11 -4
  2. package/README.md +4 -1
  3. package/dist/babelRegister.d.ts +4 -5
  4. package/dist/babelRegister.js +2 -54
  5. package/dist/babelRegister.js.map +1 -1
  6. package/dist/constants.d.ts +1 -3
  7. package/dist/constants.js +7 -12
  8. package/dist/constants.js.map +1 -1
  9. package/dist/dotenv.js +1 -1
  10. package/dist/dotenv.js.map +1 -1
  11. package/dist/esbuild/index.js +3 -2
  12. package/dist/esbuild/index.js.map +1 -1
  13. package/dist/esbuild/swc-plugin.js +3 -3
  14. package/dist/esbuild/swc-plugin.js.map +1 -1
  15. package/dist/esbuild/utils.js +2 -2
  16. package/dist/esbuild/utils.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/npm.js.map +1 -1
  21. package/dist/swcRegister.js.map +1 -1
  22. package/dist/terminal.d.ts +1 -1
  23. package/dist/terminal.js.map +1 -1
  24. package/dist/utils.d.ts +0 -1
  25. package/dist/utils.js +15 -66
  26. package/dist/utils.js.map +1 -1
  27. package/package.json +34 -39
  28. package/swc/.gitkeep +0 -0
  29. package/swc/swc_plugin_compile_mode.wasm +0 -0
  30. package/swc/swc_plugin_define_config.wasm +0 -0
  31. package/swc/plugin-compile-mode/.cargo/config +0 -5
  32. package/swc/plugin-compile-mode/.editorconfig +0 -6
  33. package/swc/plugin-compile-mode/.vscode/settings.json +0 -3
  34. package/swc/plugin-compile-mode/Cargo.lock +0 -2021
  35. package/swc/plugin-compile-mode/Cargo.toml +0 -22
  36. package/swc/plugin-compile-mode/package.json +0 -15
  37. package/swc/plugin-compile-mode/src/lib.rs +0 -71
  38. package/swc/plugin-compile-mode/src/tests/attributes.rs +0 -54
  39. package/swc/plugin-compile-mode/src/tests/children.rs +0 -86
  40. package/swc/plugin-compile-mode/src/tests/condition.rs +0 -50
  41. package/swc/plugin-compile-mode/src/tests/entry.rs +0 -20
  42. package/swc/plugin-compile-mode/src/tests/harmony/attributes.rs +0 -45
  43. package/swc/plugin-compile-mode/src/tests/harmony/children.rs +0 -74
  44. package/swc/plugin-compile-mode/src/tests/harmony/condition.rs +0 -79
  45. package/swc/plugin-compile-mode/src/tests/harmony/entry.rs +0 -67
  46. package/swc/plugin-compile-mode/src/tests/harmony/looping.rs +0 -62
  47. package/swc/plugin-compile-mode/src/tests/harmony/mod.rs +0 -45
  48. package/swc/plugin-compile-mode/src/tests/looping.rs +0 -84
  49. package/swc/plugin-compile-mode/src/tests/mod.rs +0 -100
  50. package/swc/plugin-compile-mode/src/tests/shake.rs +0 -27
  51. package/swc/plugin-compile-mode/src/transform.rs +0 -474
  52. package/swc/plugin-compile-mode/src/transform_harmony.rs +0 -526
  53. package/swc/plugin-compile-mode/src/utils/constants.rs +0 -152
  54. package/swc/plugin-compile-mode/src/utils/harmony/components.rs +0 -61
  55. package/swc/plugin-compile-mode/src/utils/harmony/mod.rs +0 -1
  56. package/swc/plugin-compile-mode/src/utils/mod.rs +0 -347
  57. package/swc/plugin-compile-mode/target/wasm32-wasi/release/swc_plugin_compile_mode.wasm +0 -0
  58. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_handle_events.js +0 -8
  59. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_keep_static_attrs_only_in_templates.js +0 -8
  60. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_turn_dynamic_attrs.js +0 -11
  61. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_native_component.js +0 -7
  62. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_react_component.js +0 -7
  63. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_fragment.js +0 -44
  64. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_render_fn.js +0 -8
  65. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_and_expr.js +0 -14
  66. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_conditional_expr.js +0 -15
  67. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/entry.rs/should_support_multi_compile_mode.js +0 -10
  68. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_handle_events.js +0 -183
  69. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_turn_dynamic_attrs.js +0 -186
  70. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_render_react_component.js +0 -76
  71. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_fragment.js +0 -341
  72. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_render_fn.js +0 -186
  73. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_and_expr.js +0 -211
  74. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_complex_condition.js +0 -244
  75. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_and_unkonw_component.js +0 -139
  76. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_expr.js +0 -344
  77. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_compile_child_node.js +0 -141
  78. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_component_not_in_config.js +0 -91
  79. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_multi_compile_mode.js +0 -209
  80. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_single_compile_mode.js +0 -66
  81. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -76
  82. 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
  83. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_function_expr.js +0 -86
  84. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -8
  85. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_expr.js +0 -6
  86. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_function_expr.js +0 -20
  87. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_support_nested_loop.js +0 -15
  88. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/shake.rs/should_static_jsx_being_shaked.js +0 -20
  89. package/swc/plugin-define-config/.cargo/config +0 -5
  90. package/swc/plugin-define-config/Cargo.lock +0 -2110
  91. package/swc/plugin-define-config/Cargo.toml +0 -18
  92. package/swc/plugin-define-config/src/lib.rs +0 -141
  93. package/swc/plugin-define-config/target/wasm32-wasi/release/swc_plugin_define_config.wasm +0 -0
  94. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_app.js +0 -2
  95. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_page.js +0 -2
  96. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_exports.js +0 -11
  97. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_app.js +0 -3
  98. 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