close

Filter

loading table of contents...

CoreMedia Content Cloud v11 Upgrade Guide / Version 2110

Table Of Contents

7.3.1.3 Imports and Exports

In ActionScript, each compilation unit (usually a class, but interfaces and global variables, constants or functions are also compilation units) has a fully qualified name that is globally unique. This name is used to reference other compilation units when importing them.

As TypeScript is an extension of ECMAScript, it uses the ECMAScript module system. Since ES5, any source file that contains imports and/or exports is a module. In import statements, modules are references by file path without extension. This file path may either be relative to the current source file, starting with ./ or ../, or it refers to an NPM package name and then specifies the relative path within that package.

NPM packages are the counterparts of Maven modules, and ActionScript packages correspond to TypeScript (ECMAScript) modules, so there is quite some potential for terminology confusion!

So each Jangaroo ActionScript Maven module has been mapped to a Jangaroo NPM package, and each different ActionScript package within such module has been mapped to a relative path to a TypeScript module within that package.

Thus, a main difference between Jangaroo Maven/ActionScript and NPM/TypeScript is that because ActionScript fully-qualified names are globally unique, import references in ActionScript are agnostic of the Maven module (there only must be a Maven dependency), while import references in TypeScript contain the target's NPM package name.

We map Jangaroo Maven module names to NPM packages names through same pattern-matching-magic, considering that NPM package names should use a scope (here: @coremedia for core and @coremeda-blueprint for Blueprint packages), separated by a slash from the actual NPM package name.

To avoid unnecessary deep paths for TypeScript modules in NPM packages, we mapped the ActionScript package names within one Maven module to a shortened relative path in the NPM package. We configured the longest possible common ActionScript package name prefix to be left out for the relative path.

As an example, we use the Maven module com.coremedia.ui.toolkit:client-core, which is mapped to @coremedia/studio-client.ext.client-core. The Maven module contains ActionScript packages com.coremedia.ui.data.... and com.coremedia.ui.util. We tell the jangaroo-maven-plugin that the desired redundant prefix to remove during TypeScript/NPM conversion is com.coremedia.ui through the configuration option extNamespace:

 <plugin>
  <groupId>net.jangaroo</groupId>
  <artifactId>jangaroo-maven-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <extNamespace>com.coremedia.ui</extNamespace>
    ...
  </configuration>
</plugin> 

Example 7.1.  Removing redundant prefix configuration


Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.