flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [2/2] git commit: [flex-falcon] [refs/heads/release0.8.0] - compiler-jx: fixed issue where require() calls generated by PackageHeaderEmitter for Node.js modules would create invalid variable names because it didn't convert from dashes to camel case
Date Fri, 26 May 2017 22:01:25 GMT
compiler-jx: fixed issue where require() calls generated by PackageHeaderEmitter for Node.js
modules would create invalid variable names because it didn't convert from dashes to camel
case


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5a32df89
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5a32df89
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5a32df89

Branch: refs/heads/release0.8.0
Commit: 5a32df89de60f93f3da9dddbbd60788654eda875
Parents: 693af59
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Fri May 26 15:01:17 2017 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Fri May 26 15:01:17 2017 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/jx/PackageHeaderEmitter.java   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5a32df89/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
index 0f1d0cd..5d2c413 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
@@ -51,6 +51,7 @@ import org.apache.flex.compiler.targets.ITarget.TargetType;
 import org.apache.flex.compiler.tree.as.ITypeNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.utils.NativeUtils;
+import org.apache.flex.compiler.utils.NodeJSUtils;
 
 public class PackageHeaderEmitter extends JSSubEmitter implements
         ISubEmitter<IPackageDefinition>
@@ -402,26 +403,28 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
         if (externalRequiresList != null)
         {
             Collections.sort(externalRequiresList);
-            for (String imp : externalRequiresList)
+            for (String nodeJSModuleName : externalRequiresList)
             {
-                if (writtenRequires.indexOf(imp) == -1)
+                if (writtenRequires.indexOf(nodeJSModuleName) == -1)
                 {
+                    String moduleVariableName = NodeJSUtils.convertFromDashesToCamelCase(nodeJSModuleName);
                     /* var x = require('x');\n */
+                    /* var someModule = require('some-module');\n */
                     write(ASEmitterTokens.VAR);
                     write(ASEmitterTokens.SPACE);
-                    write(imp);
+                    write(moduleVariableName);
                     write(ASEmitterTokens.SPACE);
                     write(ASEmitterTokens.EQUAL);
                     write(ASEmitterTokens.SPACE);
                     write(NodeEmitterTokens.REQUIRE);
                     write(ASEmitterTokens.PAREN_OPEN);
                     write(ASEmitterTokens.SINGLE_QUOTE);
-                    write(imp);
+                    write(nodeJSModuleName);
                     write(ASEmitterTokens.SINGLE_QUOTE);
                     write(ASEmitterTokens.PAREN_CLOSE);
                     writeNewline(ASEmitterTokens.SEMICOLON);
 
-                    writtenRequires.add(imp);
+                    writtenRequires.add(nodeJSModuleName);
 
                     emitsExternalRequires = true;
                 }


Mime
View raw message