Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25057] Hyperloop: Support ES6 user code

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2018-03-28T18:48:16.000+0000
Affected Version/sn/a
Fix Version/sHyperloop 3.1.0
ComponentsHyperloop
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2017-08-02T16:05:29.000+0000
Updated2018-03-28T18:48:16.000+0000

Description

We need to be able to handle es6 user code in hyperloop. I don't know if we have any issues around using uglify for any of the hooks we use, but I do know that we have an issue around our require detection if users starts using import instead. We currently do some ugly regexp searching of the code to look for native require calls. We need to modify that regexp to find native import calls as well (or even use a real JS parser like babylon). We should also consider if we can ease use of the hyperloop wrappers by allowing nice ES6 imports of frameworks/packages. i.e. in Android you can require a Java package and access types off of the returned object. Do we need to do anything special to support something like this?
import { ArrayList, Calendar } from 'java.util';

Comments

  1. Hans Knöchel 2018-02-03

    Proposed functionality (by [~cwilliams] from the [PR](https://github.com/appcelerator/hyperloop.next/pull/270)): iOS:
       // types
       var UIAlertController = require('UIKit/UIAlertController');
       import UIAlertController from 'UIKit/UIAlertController';
       import * as UIAlertController from 'UIKit/UIAlertController';
       // types from frameworks
       import { UIAlertController, UIView } from 'UIKit';
       // builtins/methods/whatever from frameworks
       var CGRectMake = require('CoreGraphics/CoreGraphics').CGRectMake;
       var CGRectMake = require('CoreGraphics').CGRectMake;
       import { CGRectMake, CGAffineTransformRotate } from 'CoreGraphics';
       
       // invalid/ambiguous/unsupported?
       import UIView from 'UIKit';
       // are they trying to import UIKit/UIKit and alias it as 'UIView'?
       // Or import UIView from 'UIKit/UIView';?
       
    Android:
       // types
       var Activity = require('android.app.Activity');
       import Activity from 'android.app.Activity';
       import * as Activity from 'android.app.Activity';
       // packages
       import { ArrayList, Calendar } from 'java.util.*';
       var javaUtil = require('java.util.*');
       var ArrayList = javaUtil.ArrayList;
       

JSON Source