[TIMOB-27167] CLI: Move Alloy optimizations into core SDK build
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-01-30T21:27:26.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.0.0 |
Components | CLI |
Labels | n/a |
Reporter | Christopher Williams |
Assignee | Christopher Williams |
Created | 2019-06-19T13:01:46.000+0000 |
Updated | 2020-01-30T21:27:26.000+0000 |
Description
Alloy does some additional work in specialized Babel plugins to "optimize" Alloy applications. But most of these can be generally useful for Titanium apps and should be moved into the mainline build process to benefit all apps (and to simplify Alloy's build process which is poorly written resulting in some hard to fix build/source map bugs and performance issues).
Specifically Alloy allows developers to make use of special references that get replaced by true/false:
- OS_IOS, OS_ANDROID, OS_WINDOWS
- ENV_DEV, ENV_DEVELOPMENT, ENV_TEST, ENV_PROD, ENV_PRODUCTION
- DIST_ADHOC, DIST_STORE
Then it strips out dead code as a result (because these are typically use in if/else guards for platform-specific code)
Started moving this out to a Babel plugin we could include in node-titanium-sdk: https://github.com/appcelerator/babel-plugin-transform-titanium
Hi. Is there a way to integrate this Babel plugin (or any other) in a classic project (actually I need it to be executed after alloy)?
node-titanium-sdk PR: https://github.com/appcelerator/node-titanium-sdk/pull/131
A WIP PR for the SDK: https://github.com/appcelerator/titanium_mobile/pull/11400
[~s.volkov] This PR sort of shows how you could forcibly do this if you control the options that get into node-titanium-sdk's jsanalyze: https://github.com/appcelerator/node-titanium-sdk/pull/131/files#diff-5868425a37491ef8e1872789e566db31R137 We don't really expose a way to fiddle with that though. This is the location you'd try and pass in a
plugins
value that should eventually get rolled in: https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/commands/_build.js#L2715 (for android) In this example you'd want to tweakdefaultAnalyzeOptions.plugins
to be an array with babel plugin entries. (each item being either the string name, or an array with two elements first is plugin name/object second is the options to pass to the plugin)FR Passed. PR Merged.
Verified the fix with SDK 9.0.0.v20200130075800. Closing.