Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

unwanted injection of isomorphicDir by smartgwt linker

$
0
0
My Smart GWT project happened to have a resource named Page.js
I was quite stunned to see a line being inserted in the corresponding output file in the war folder during GWT compilation, breaking my code.

Culprit is SmartGwtLinker line 49ff:
Code:

            if (partialPath.endsWith("/ISC_Core.js") || partialPath.endsWith("/Page.js")) {

                String contents = getContents(emittedArtifact, logger);
                int insertIdx = contents.indexOf("*/") + 2;
                StringBuffer sb = new StringBuffer(contents);
                sb.insert(insertIdx, "\nif(typeof isomorphicDir == 'undefined'){isomorphicDir = '" + context.getModuleName() + "/sc/';}\n");

                toReturn.remove(emittedArtifact);
                toReturn.add(emitString(logger, sb.toString(), partialPath));
            }

It processes simply any resource named Page.js.
My suggestion would be:
1) search for a more specific tag in these files (and insert this tag into your own ISC_Core.js and Page.js)
2) check if this tag is being found before inserting the line

Like so:

Code:

            if (partialPath.endsWith("/ISC_Core.js") || partialPath.endsWith("/Page.js")) {

                String contents = getContents(emittedArtifact, logger);
                int insertIdx = contents.indexOf("#ISO_DIR#*/") + 11;
                if (insertIdx > 0) {
                    StringBuffer sb = new StringBuffer(contents);
                    sb.insert(insertIdx, "\nif(typeof isomorphicDir == 'undefined'){isomorphicDir = '" + context.getModuleName() + "/sc/';}\n");

                    toReturn.remove(emittedArtifact);
                    toReturn.add(emitString(logger, sb.toString(), partialPath));
                }
            }

Regards,
ECT

Viewing all articles
Browse latest Browse all 4756

Trending Articles