BowlerHatLLC / vscode-as3mxml

ActionScript & MXML language extension for Visual Studio Code. Develop apps for Adobe AIR, Adobe Flash Player, or Apache Royale.
https://as3mxml.com/
Apache License 2.0
257 stars 39 forks source link

Defining a flat output and to a flat output path #719

Closed velara3 closed 10 months ago

velara3 commented 10 months ago

In my application I have setup as following (before compilation):

/project 
   asconfig.json
   /src
      - MyApp.as
      - myapp.html
   /public
       /js

I want to output to a single .js file to the /public/js directory but I'm getting the following error:

Internal error: java.lang.RuntimeException: Unable to create release directory at /public/js/bin/js-release org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyalePublisher.setupOutputFolder(MXMLRoyalePublisher.java:1103)org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyalePublisher.getOutputFolder(MXMLRoyalePublisher.java:182)org.apache.royale.compiler.clients.MXMLJSCNative.compile(MXMLJSCNative.java:403)org.apache.royale.compiler.clients.MXMLJSCNative._mainNoExit(MXMLJSCNative.java:248)org.apache.royale.compiler.clients.MXMLJSCNative.mainNoExit(MXMLJSCNative.java:205)org.apache.royale.compiler.clients.MXMLJSC._mainNoExit(MXMLJSC.java:382)org.apache.royale.compiler.clients.MXMLJSC.mainNoExit(MXMLJSC.java:281)org.apache.royale.compiler.clients.MXMLJSC.staticMainNoExit(MXMLJSC.java:241)org.apache.royale.compiler.clients.MXMLJSC.main(MXMLJSC.java:220)

I'm using the js-output compiler option:

{
    "config": "js",
    "compilerOptions": {
        "debug": true,
        "source-path": [
            "src"
        ],
        "js-output": "/public/js",
        "html-template": "template.html",
        "source-map": true
    },
    "mainClass": "LoginApp"
}

What I want:

/project 
   asconfig.json
   /src
      MyApp.as
      myapp.html
   /public
      /js
        MyApp.js
      myapp.html
velara3 commented 10 months ago

The way typescript does it is if you have a file, myapp.ts, it will compile that to myapp.js. It's very basic but very simple. You don't even need a tsconfig (I believe).

Project before compilation:

/project 
   myapp.ts

After compilation:

/project 
   myapp.ts
   myapp.js
joshtynjala commented 10 months ago

A starting slash is probably considered an absolute path by the compiler:

"js-output": "/public/js",

Did you try this?

"js-output": "public/js",
velara3 commented 10 months ago

That's what I have now:

{
    "config": "js",
    "compilerOptions": {
        "debug": false,
        "source-path": [
            "src"
        ],
        "js-output": "public/js",
        "html-template": "astemplate.html",
        "source-map": true
    },
    "mainClass": "MyApp"
}

This is the output in the /project/public directory:

image

It publishes to the /public/js folder the sub folders /bin/js-debug/

/project
    /src
      - myapp.as
    /public
       /js
          /bin
             /js-debug
                /library
                /org
             - index.html
             - myapp.as
             - myapp.as.map

What I'd like if possible is export one single js in the same directory or to the /public directory:

/project
    /src
      - myapp.as
      - myapp.js
/project
    /src
      - myapp.as
    /public
      - myapp.js

Or sub directory:

/project
    /src
      - myapp.as
    /public
       /js
         - myapp.as
         - myapp.as.map

In this case, the html page is already built and in the public directory. So I just need to get the js app into the root or sub directory of the index page if possible.

Side note: What are, /library and /org used for? Can they not be exported in debug?

joshtynjala commented 10 months ago

What I'd like if possible is export one single js in the same directory or to the /public directory:

Royale does not currently support outputting a single JS file in a specific directory. It will always create js-debug, js-release, or both. If you do a release build, it will generate a single JS file, but it will go in the js-release directory.

You'll need to open a feature request for https://github.com/apache/royale-compiler. vscode-as3mxml has no control over how Royale outputs its JS code.

In this case, the html page is already built and in the public directory.

If you have your own HTML page, you can omit the html-template compiler option (or possibly set it to an empty string), and the Royale compiler won't create its own index.html.

Side note: What are, /library and /org used for? Can they not be exported in debug?

I believe that library contains the Google Closure Library, which Royale depends on. The org directory probably contains the classes from org.apache.royale.* package. The Language class, in particular, is needed even if you aren't using the Royale framework. It provides implementations of some of the features of AS3 that aren't native to JS.