Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27167] CLI: Move Alloy optimizations into core SDK build

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2020-01-30T21:27:26.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.0
ComponentsCLI
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2019-06-19T13:01:46.000+0000
Updated2020-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)

Comments

  1. Christopher Williams 2019-10-11

    Started moving this out to a Babel plugin we could include in node-titanium-sdk: https://github.com/appcelerator/babel-plugin-transform-titanium
  2. Sergey Volkov 2019-12-13

    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)?
  3. Christopher Williams 2019-12-17

    node-titanium-sdk PR: https://github.com/appcelerator/node-titanium-sdk/pull/131
  4. Christopher Williams 2019-12-17

    A WIP PR for the SDK: https://github.com/appcelerator/titanium_mobile/pull/11400
  5. Christopher Williams 2019-12-17

    [~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 tweak defaultAnalyzeOptions.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)
  6. Lokesh Choudhary 2020-01-27

    FR Passed. PR Merged.
  7. Lokesh Choudhary 2020-01-30

    Verified the fix with SDK 9.0.0.v20200130075800. Closing.

JSON Source