Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-1574

Unable to use ES6 import/exports in alloy controllers due to bad code generation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Alloy 1.10.4
    • Component/s: Tooling
    • Labels:
      None

      Description

      If you add imports or exports to an alloy controller, we can now parse the code and handle it in our use of babel/babylon instead of uglify. BUT, we don't "hoist" the imports/exports to the top of the generated code, so it can become embedded underneath a function which is invalid ES6 code. imports and exports must be "moved" up to the global top-level or else the code is invalid.

      i.e.

      import 'foo' from 'bar';
      export const foo = Math.sqrt(2);
      

      On a related note, we don't really "handle" ES6 imports/exports anyways down the line, but that's another ticket we can address in titanium CLI/build to just use babel transpilation to generate requires out of them (until the wider JS community has settled how to handle module vs script difference and imports/exports)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fmiao Feon Sua Xin Miao
                Reporter:
                cwilliams Christopher Williams
              • Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code