#2919 Building JS with Fantom 1.0.80

SlimerDude Mon 10 Jun

Hi, I have a project with native JS files, that isn't ready for conversion to ES just yet. But it does not seem possible to build it with Fantom 1.0.80.

In my build.fan I set the jsDirs:

jsDirs = [`js/`]

and in that js/ I have a couple of .js files, some are Fantom Peer files and others are just native JS files I'd like bundled up in the pod.

$ ls js

acmeAwesome.3.1.4.min.js
MyClassPeer.js

For both of those files, the new compilerEs looks for counterparts in the es/ directory - but neither exist, so I get a java.io.FileNotFoundException - es/acmeAwesome.3.1.4.min.js instead.

A simple check if the es/xxx file exists or not in compilerEs::JsPod.make() before adding it to a list of natives seems to do the trick.

diff --git a/org.fantom.compilerEs/fan/ast/JsPod.fan b/org.fantom.compilerEs/fan/ast/JsPod.fan
index 1d08421..f1a9142 100644
--- a/org.fantom.compilerEs/fan/ast/JsPod.fan
+++ b/org.fantom.compilerEs/fan/ast/JsPod.fan
@@ -26,7 +26,9 @@ class JsPod : JsNode
     // map native files by name
     c.jsFiles?.each |f| {
       // we expect ES javascript files in es/ directory
-      natives[f.name] = f.parent.parent.plus(`es/${f.name}`)
+      esFile := f.parent.parent.plus(`es/${f.name}`)
+      if (esFile.exists)
+        natives[f.name] = esFile
     }

matthew Tue 11 Jun

Ticket promoted to #2919 and assigned to matthew

Thanks for reporting. Will fix this for next build.

matthew Tue 11 Jun

Ticket resolved in 1.0.81

GitHub commit

SlimerDude Sun 16 Jun

Hi, conversely - is it possible to only compile ES code without any older JS code?

Or do I have to supply placeholder JS files in js/ so the surrogate ES files are looked up in the es/ dir?

Login or Signup to reply.