> I'm not referencing Basic.swc directly anymore > "js-library-path": [ > "../libs/" > ]
Is Basic.swc not in the ../libs/ directory? Based on your proposed solution, it seems like it switches from Basic.swc to BasicJS.swc by switching from frameworks/libs to frameworks/js/libs (unless I'm misunderstanding, and these just happen to be coincidentally named). > I understand this correctly for each project I'll need 2 separate target swcs - one for JS and one for SWF? If you want your library to be usable from both SWF and JS, then yes, you need two SWCs. > So instead of ... I should have ... That seems correct for the JS SWC. If you also want a SWF SWC, you would need a separate asconfig.json file. You can't build multiple SWCs from a single asconfig.json file. Mainly because you can't build multiple SWCs from one single execution of the compiler. -- Josh Tynjala Bowler Hat LLC https://bowlerhat.dev/ On Tue, Jul 8, 2025 at 2:04 PM Yishay Weiss <yishayj...@hotmail.com> wrote: > >So, when you > >use Basic.swc instead of BasicJS.swc, I would definitely expect conflicts > >like you are seeing > > I'm not referencing Basic.swc directly anymore (remember I've switched to > asconfig.json and rely on royale-config.xml), but if I understand this > correctly for each project I'll need 2 separate target swcs - one for JS > and one for SWF? > > > So instead of > > { > "config": "royale", > "type": "lib", > "compilerOptions": { > "targets": [ > "SWF", > "JSRoyale" > ], > "source-path": [ > "src" > ], > "output": "../libs/ApacheFlexSpellingFramework.swc", > "library-path": [ > "../libs/" > ], > "js-library-path": [ > "../libs/" > ] > }, > "files": [ > "src" > ] > } > > I should have > > { > "config": "royale", > "type": "lib", > "compilerOptions": { > "targets": [ > "SWF", > "JSRoyale" > ], > "source-path": [ > "src" > ], > "output": "../libs/ApacheFlexSpellingFramework.swc", > "library-path": [ > "../libs/" > ], > "js-library-path": [ > "../js/libs/" > ] > }, > "files": [ > "src" > ] > } > > How do I tell asconfig.json about the js output folder ? > ________________________________ > From: Josh Tynjala <joshtynj...@bowlerhat.dev> > Sent: Tuesday, July 8, 2025 7:01 PM > To: dev@royale.apache.org <dev@royale.apache.org> > Subject: Re: Any Ideas What This compc Error is About? > > > I'm still confused because when I open Basic.swc I see the JS files as > well. I thought libs typically contained code for both swf and js, so > that's also how I configured my build.. > > I honestly don't know why Basic.swc has JS files in it. > > I remember Alex Harui once mentioning that he wanted to support hybrid SWCs > that could be used for both SWF and JS targets. Maybe that's why Basic.swc > contains JS files. Regardless, even if the JS files are there, they aren't > actually usable as hybrid SWCs. It's because the SWF bytecode in Basic.swc > is compiled with COMPILE::SWF set to true and COMPILE::JS set to false. > That bytecode is what is used for type-checking by the compiler, *even when > targeting JS*. As I understand it, that's why we have separate SWF and JS > SWCs. Because a SWC can't (at least currently) contain two > separate bytecodes for type-checking SWF and JS differently. So, when you > use Basic.swc instead of BasicJS.swc, I would definitely expect conflicts > like you are seeing because the bytecode side of it doesn't know anything > about JS APIs and expects to find things from the flash.* package instead. > > In short, there's currently no way for the compiler to do correct type > checking on both SWF and JSRoyale targets using a single SWC file. So when > you target JS, you can't use Basic.swc and must use BasicJS.swc instead. > > > What I meant here was if all JS dependencies were in > <js-external-library/> and all swf dependencies were in > <external-library/>. > > For a library, you should be able to make all dependencies external, as > long as you add both your library and all of its dependencies as > non-external when you build an app (or another library) with it. In this > case, you should be able to use external-library-path for SWF and > js-external-library-path for JS. > > However, I should note that I don't think that this will allow you to use > Basic.swc instead of BasicJS.swc when targeting JS. Even if making > Basic.swc external for JS somehow allows both your library and your app to > technically compile, I think it would still be brittle and you'd risk it > giving you new errors later if you used the right APIs from Basic.swc that > don't match up with BasicJS.swc in the bytecode. > > > That's what gets me confused. Why does this code (note > flash.utils.IDataInput is in the SWF block) > > For context, I am getting this message when building a new library which > has ApacheFlexSpellingFramework.swc as a dependency. Compiling > ApacheFlexSpellingFramework does not give any errors. > > Hopefully, my explanation above helps. You > compiled ApacheFlexSpellingFramework.swc with Basic.swc, which has bytecode > compiled with COMPILE::SWF set to true, so it depends on > flash.utils.IDataInput and flash.utils.IDataOutput. Since you're compiling > to JS, the compiler (correctly) can't find classes in the flash.* package. > It should work if you switch to BasicJS.swc instead. > > -- > Josh Tynjala > Bowler Hat LLC > https://bowlerhat.dev/ > > > On Tue, Jul 8, 2025 at 10:00 AM Yishay Weiss <yishayj...@hotmail.com> > wrote: > > > Thanks for the explanation (and the history lesson). > > > > I'm still confused because when I open Basic.swc I see the JS files as > > well. I thought libs typically contained code for both swf and js, so > > that's also how I configured my build... > > > > > >What should happen if instead they were all included in external? > > > > What I meant here was if all JS dependencies were in > > <js-external-library/> and all swf dependencies were in > > <external-library/>. I'm trying to avoid duplicating dependencies on > Royale > > if there's more than one swc. > > > > >So, for the first pass with the SWF target, COMPILE::SWF is true > > >and COMPILE::JS is false. Then, in the second pass with the JSRoyale > > >target, COMPILE::SWF is false and COMPILE::JS is true. > > > > That's what gets me confused. Why does this code (note > > flash.utils.IDataInput is in the SWF block) > > > > COMPILE::JS{ > > import org.apache.royale.utils.net.IDataInput; > > import org.apache.royale.utils.net.IDataOutput; > > } > > COMPILE::SWF{ > > import flash.utils.IDataInput; > > import flash.utils.IDataOutput; > > } > > > > Give me > > > > COMPCJSCRoyale > > > > > C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc > > The definition flash.utils.IDataInput depended on by > > com.adobe.linguistics.spelling.framework.ResourceTable in the SWC > > > > > C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc > > could not be found > > > > (Note COMPCJSCRoyale, which means it's in the JS pass) > > > > For context, I am getting this message when building a new library which > > has ApacheFlexSpellingFramework.swc as a dependency. Compiling > > ApacheFlexSpellingFramework does not give any errors. > > > > > > ________________________________ > > From: Josh Tynjala <joshtynj...@bowlerhat.dev> > > Sent: Tuesday, July 8, 2025 5:10 PM > > To: dev@royale.apache.org <dev@royale.apache.org> > > Subject: Re: Any Ideas What This compc Error is About? > > > > > I see that <external-library-path/> is used only for playerglobal.swc > > while the rest of the framework/libs are added in <library-path/> > > > <js-external-library-path/> has only js.swc and GCL.swc and anything > > under framework/js/libs (e.g. BasicJS.swc) is under <js-library-path/> > > > > Yes. I feel like it might be a good idea to explain why the SWCs are > added > > in each of those options, just in case it isn't clear. > > > > Before Royale, we had only library-path and external-library-path because > > there was only one target: SWF. Traditionally, library-path was for SWCs > > that contain full implementations of AS3 classes that don't exist in the > > flash.* package. Meanwhile, external-library-path was for classes that > > don't need to be compiled into the output, but the compiler needs to know > > which symbols are available for type checking. playerglobal.swc doesn't > > contain full AS3 implementations of the flash.* classes compiled into it. > > It's just stubs of the classes in the flash.* package (which is similar > to > > Royale's JS externs/typedefs). You could also use external-library-path > for > > classes that might be available from a different SWF at run-time, and you > > don't want to duplicate them to save on file size. > > > > In Royale/FlexJS, we added swf-library-path, swf-external-library-path, > > js-library-path, and js-external-library-path. > > > > - If swf-library-path is defined, it will take precedence over > > library-path, but only when targeting SWF. > > - If swf-external-library-path is defined, it will take precedence > over > > external-library-path, but only when targeting SWF. > > - If js-library-path is defined, it will take precedence over > > library-path, but only when targeting JS. > > - If js-external-library-path is defined, it will take precedence over > > external-library-path, but only when targeting JS. > > > > As I understand it, in royale-config.xml, we decided to keep using > > library-path and external-library-path for the SWF target. Probably > because > > that's how it worked before Royale, and changing to use swf-library-path > > and swf-external-library-path might break existing SWF-only projects if > > they tried to switch to the Royale compiler from the Flex SDK or AIR SDK > > compilers. > > > > However, we need to provide SWCs in the same royale-config.xml for the JS > > target too. Those JS SWCs should be ignored when targeting SWF, so we > can't > > just add them all to library-path and external-library-path. With that in > > mind, for JS, we use js-library-path and js-external-library-path. > > > > js.swc and GCL.swc are the JS equivalent of playerglobal.swc. They don't > > contain the actual classes, but just define the APIs so that the compiler > > can typecheck. That's why they're external. > > > > The frameworks/js/libs SWCs are for JS only and contain full > > implementations of the Royale framework, similar to how the > frameworks/libs > > SWCs are SWF only and contain full implementations. > > > > > What should happen if instead they were all included in external? > > > > js.swc and playerglobal.swc in the same external-library-path? It would > > make symbols meant for just one target available to both targets, from > the > > compiler's perspective. So the compiler might think that > > flash.display.Sprite is available in JS. Or HTMLDivElement is available > in > > SWF. We don't want that. > > > > > Also, why are the JS.swc included in <js-library-path/> instead of the > > regular swc ones? > > > > The frameworks/js/libs/*JS.swc files are the full implementations of the > > Royale framework, but targeting JS only. So they are added to > > js-library-path. That's similar to frameworks/libs/*.swc that are > > full implementations for SWF being added to library-path (or, in theory, > > they could be added to swf-library-path). > > > > > I get the same result with asconfigc with the following conf: > > > "targets": [ > > > "SWF", > > > "JSRoyale" > > > ], > > > > By default, COMPILE::SWF and COMPILE::JS are both set to AUTO. When the > > target is SWF, the AUTO value means that COMPILE::SWF is true and > > COMPILE::JS is false. When the target is JSRoyale, the AUTO value means > > that COMPILE::SWF is false and COMPILE::JS is true. > > > > It's important to understand that when you have multiple values in the > > targets compiler option, the compiler internally restarts fresh for each > > target. So, for the first pass with the SWF target, COMPILE::SWF is true > > and COMPILE::JS is false. Then, in the second pass with the JSRoyale > > target, COMPILE::SWF is false and COMPILE::JS is true. > > > > If you're making a SWC that is intended for JS only, you don't actually > > want to use the default AUTO value. AUTO is good for when you're building > > an app with Royale, but not for a library. For a JS-only library you > > actually need to force COMPILE::SWF to false and COMPILE::JS to true. > > > > You can see that we do that for the JS SWCs in royale-asjs: > > > > > > > https://github.com/apache/royale-asjs/blob/5b52c04/frameworks/js/projects/BasicJS/src/main/config/compile-js-config.xml#L38-L45 > > > > And for the SWF-only SWCs, we set them to the opposite values: > > > > > > > https://github.com/apache/royale-asjs/blob/5b52c04/frameworks/projects/Basic/src/main/config/compile-swf-config.xml#L49-L56 > > > > -- > > Josh Tynjala > > Bowler Hat LLC > > https://bowlerhat.dev/ > > > > > > On Tue, Jul 8, 2025 at 8:24 AM Yishay Weiss <yishayj...@hotmail.com> > > wrote: > > > > > > In my experience, it is usually because either > > swf-external-library-path > > > or > > > js-external-library-path is set > > > > > > When I look at royale-config.xml I see that <external-library-path/> is > > > used only for playerglobal.swc while the rest of the framework/libs are > > > added in <library-path/> > > > > > > <js-external-library-path/> has only js.swc and GCL.swc and anything > > under > > > framework/js/libs (e.g. BasicJS.swc) is under <js-library-path/> > > > > > > What should happen if instead they were all included in external? Also, > > > why are the JS.swc included in <js-library-path/> instead of the > regular > > > swc ones? > > > > > > >I saw that you are compiling for the SWF target. Note it prints > > > COMPCJSCRoyale before giving the error. > > > > > > I get the same result with asconfigc with the following conf: > > > > > > { > > > "config": "royale", > > > "type": "lib", > > > "compilerOptions": { > > > "targets": [ > > > "SWF", > > > "JSRoyale" > > > ], > > > "source-path": [ > > > "src" > > > ], > > > "output": "../libs/ApacheFlexSpellingUI.swc", > > > "library-path": [ > > > "../libs/" > > > ], > > > "js-library-path": [ > > > "../libs/" > > > ] > > > }, > > > "files": [ > > > "src" > > > ] > > > } > > > > > > > > > > > > > > > ________________________________ > > > From: Josh Tynjala <joshtynj...@bowlerhat.dev> > > > Sent: Tuesday, July 8, 2025 2:57 PM > > > To: dev@royale.apache.org <dev@royale.apache.org> > > > Subject: Re: Any Ideas What This compc Error is About? > > > > > > > It looks like the trick is to use -library-path instead of > > > -external-library-path. I am not sure why external is not enough. > > > > > > Sometimes, external-library-path seems like it isn't working properly. > In > > > my experience, it is usually because either swf-external-library-path > or > > > js-external-library-path is set, and they are designed to take > precedence > > > over external-library-path. It's worth mentioning that you may not be > the > > > one setting them in your own project's compiler options. They might be > > set > > > as a default in royale-config.xml. > > > > > > > Does that mean that the JS compile is trying to use the COMPILE::SWF > > > block? > > > > > > In your original message, I saw that you are compiling for the SWF > target > > > (so I would expect COMPILE::SWF to be true, in that case): > > > > > > <arg value="-targets=SWF" /> > > > > > > > > > -- > > > Josh Tynjala > > > Bowler Hat LLC > > > https://bowlerhat.dev/ > > > > > > > > > On Tue, Jul 8, 2025 at 6:46 AM Yishay Weiss <yishayj...@hotmail.com> > > > wrote: > > > > > > > It looks like the trick is to use -library-path instead of > > > > -external-library-path. I am not sure why external is not enough. > > > > > > > > Following that I have an issue with a class that has this: > > > > > > > > COMPILE::JS{ > > > > import org.apache.royale.utils.net.IDataInput; > > > > import org.apache.royale.utils.net.IDataOutput; > > > > } > > > > COMPILE::SWF{ > > > > import flash.utils.IDataInput; > > > > import flash.utils.IDataOutput; > > > > } > > > > > > > > When referencing that class from a different library, I get: > > > > > > > > COMPCJSCRoyale > > > > > > > > > > C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc > > > > The definition flash.utils.IDataInput depended on by > > > > com.adobe.linguistics.spelling.framework.ResourceTable in the SWC > > > > > > > > > > C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc > > > > could not be found > > > > > > > > Does that mean that the JS compile is trying to use the COMPILE::SWF > > > block? > > > > > > > > > > > > ________________________________ > > > > From: Yishay Weiss <yishayj...@hotmail.com> > > > > Sent: Tuesday, July 8, 2025 10:29 AM > > > > To: Apache Royale Development <dev@royale.apache.org> > > > > Subject: Re: Any Ideas What This compc Error is About? > > > > > > > > > > > > Adding > > > > <jvmarg value="-Droyalelib=${ROYALE_HOME}/frameworks" /> > > > > > > > > And removing > > > > > > > > <arg value="-library-path+=${ROYALE_HOME}/frameworks/libs/Core.swc" > /> > > > > <arg > > > > > > > > > > value="-library-path+=${ROYALE_HOME}/frameworks/projects/Basic/target/Basic.swc" > > > > /> > > > > > > > > Fixed it for now... > > > > > > > > ________________________________ > > > > From: Yishay Weiss <yishayj...@hotmail.com> > > > > Sent: Tuesday, July 8, 2025 9:34 AM > > > > To: Apache Royale Development <dev@royale.apache.org> > > > > Subject: Re: Any Ideas What This compc Error is About? > > > > > > > > T1.as looks like this: > > > > > > > > package > > > > { > > > > import org.apache.royale.core.UIBase; > > > > > > > > public class T1 extends UIBase > > > > { > > > > } > > > > } > > > > ________________________________ > > > > From: Yishay Weiss <yishayj...@hotmail.com> > > > > Sent: Tuesday, July 8, 2025 9:29 AM > > > > To: Apache Royale Development <dev@royale.apache.org> > > > > Subject: Any Ideas What This compc Error is About? > > > > > > > > I'm getting this [1] error when running this [2] ant task > > > > > > > > [1] compileframework: > > > > [java] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 > > > > [java] args: > > > > [java] -external-library-path > > > > [java] C:\dev\player/11.1/playerglobal.swc > > > > [java] > > > > > > > > > > -library-path+=C:\dev\full_royale_sdk\royale-asjs/frameworks/libs/Core.swc > > > > [java] > > > > > > > > > > -library-path+=C:\dev\full_royale_sdk\royale-asjs/frameworks/projects/Basic/target/Basic.swc > > > > [java] -targets=SWF > > > > [java] -output > > > > [java] libs/ApacheFlexSpellingFramework.swc > > > > [java] -source-path > > > > [java] SpellingFramework/src2 > > > > [java] -include-classes > > > > [java] T1 > > > > [java] -dump-config > > > > [java] sq_dump > > > > [java] COMPC > > > > [java] > > > > [java] 1.1542501 seconds > > > > [java] Error: interface method dispatchEvent in interface > > > > IEventDispatcher is implemented with an incompatible signature in > class > > > T1 > > > > [java] > > > > [java] > > > > [java] interface method dispatchEvent in interface > > IEventDispatcher > > > > is implemented with an incompatible signature in class T1 > > > > [java] > > > > [java] > > > > > > > > [2] > > > > <target name="compileframework" depends="init"> > > > > <java jar="${COMPC.JAR}" fork="true" failonerror="true"> > > > > <jvmarg value="-Xmx384m" /> > > > > <jvmarg value="-Dsun.io.useCanonCaches=false" /> > > > > <arg value="-external-library-path"/> > > > > <arg > > > > > value="${PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc"/> > > > > <arg value="-library-path+=${ROYALE_HOME}/frameworks/libs/Core.swc" > /> > > > > <arg > > > > > > > > > > value="-library-path+=${ROYALE_HOME}/frameworks/projects/Basic/target/Basic.swc" > > > > /> > > > > <arg value="-targets=SWF" /> > > > > <arg value="-output"/> > > > > <arg value="${OUTPUT_DIR}/ApacheFlexSpellingFramework.swc"/> > > > > <arg value="-source-path"/> > > > > <arg value="SpellingFramework/src2"/> > > > > <arg value="-include-classes"/> > > > > <arg value="T1"/> > > > > <arg value="-dump-config"/> > > > > <arg value="sq_dump"/> > > > > </java> > > > > </target> > > > > > > > > > >