Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24980] Allow babel plugins to be added via config.json

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sAlloy 2.0.0
ComponentsTooling
Labelsalloy, babel
ReporterBrenton House
AssigneeChristopher Williams
Created2017-07-18T18:46:28.000+0000
Updated2019-03-14T14:24:19.000+0000

Description

{noformat} As a developer, I want to be able to add/configure babel plugins to run on my code, So that I can add features without Alloy pull request. {noformat} There are a lot of features that can be added to Alloy by allow babel presets and plugins to be defined in config.json. Currently, it is somewhat possible to add a preset by pushing them to sourceMapper.OPTIONS_OUTPUT.presets from inside alloy.jmk. However, when adding plugins, they are removed because Alloy is overwriting all plugins here: https://github.com/appcelerator/alloy/blob/master/Alloy/commands/compile/index.js#L1131-L1136 If instead it used _.defaults (or even better, a merge), it could preserve any changes to sourceMapper.OPTIONS_OUTPUT.plugins

Comments

  1. Sharif AbuDarda 2017-07-18

    Thanks for the ticket. Our engineers will look into it.
  2. Christopher Williams 2017-08-22

    This is a pretty good idea. I'd also like to be able to give users a way to control additional babel plugins/presets they may want to use in the normal Titanium build process. Right now we do parsing to analyze the JS for Api usage for tracking, and will use babili to minify if minification is turned on. I wonder if users could simply add a .babelrc to their project and we could consume/extend it to also use babili when minifying (and make sure the transpilation happens after we parse to look for Ti API usage for tracking).
  3. Christopher Williams 2017-08-22

    There's a work in progress PR here: https://github.com/appcelerator/alloy/pull/842 It has broader implications since alloy is still using underscore and older backbone versions - and underscore doesn't have a deep merge method. Lodash, underscore's more popular fork, does though. And it may make more sense to move to loads, deprecate underscore, and update backbone to latest and have it use lodash under the covers.
  4. Brenton House 2017-08-22

    [~cwilliams] -- I replace underscore with lodash in most of my alloy projects and am aware of most of the gotchas if you want any help with that. Some of the biggest issues are a result of the fact that the alloy compiler and the alloy runtime share the same underscore.js file. If we could separate that for now, it would make upgrading alloy runtime to lodash much easier. Update -- looks like you have already done this in the PR. I will take a look at it. Thanks!!
  5. Christopher Williams 2017-08-22

    OK, so using Lodash in place of underscore is a bigger fish to fry and may be a breaking change (or require allowing users to configure whether they use underscore or loads and deprecating underscore). So I opened a smaller PR just for this change: https://github.com/appcelerator/alloy/pull/843
  6. Brenton House 2018-12-17

    [~cwilliams] - Is this now something that is supported via the webpack/babel integration?

JSON Source