You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Jochen Kemnade <jo...@eddyson.de> on 2017/12/01 11:11:53 UTC

Re: [1/3] tapestry-5 git commit: TAP5-2591: add support for TypeScript modules

Hi Thiago,

Am 30.11.2017 um 17:19 schrieb Thiago H. de Paula Figueiredo:
> Just one question: since 5.5 requires Java 8, couldn't we use its embedded
> JavaScript support (Nashorn) instead of Mozilla's Rhino? 

Yes, we could probably do that. But Rhino was already there, so I just 
used it. But I guess we can always switch to Nashorn later.

Jochen

> 
> On Thu, Nov 30, 2017 at 2:12 PM, Thiago H. de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
> 
>> This is awesome! Thank you very much!
>>
>> On Mon, Nov 27, 2017 at 10:01 AM, <jk...@apache.org> wrote:
>>
>>> Repository: tapestry-5
>>> Updated Branches:
>>>    refs/heads/master 80f65eb4b -> 0f2c01c9a
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>> 1c9/tapestry-webresources/src/test/groovy/t5/webresources/
>>> tests/TypeScriptCompilerSpec.groovy
>>> ----------------------------------------------------------------------
>>> diff --git a/tapestry-webresources/src/test/groovy/t5/webresources/test
>>> s/TypeScriptCompilerSpec.groovy b/tapestry-webresources/src/te
>>> st/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy
>>> new file mode 100644
>>> index 0000000..aafd30a
>>> --- /dev/null
>>> +++ b/tapestry-webresources/src/test/groovy/t5/webresources/test
>>> s/TypeScriptCompilerSpec.groovy
>>> @@ -0,0 +1,58 @@
>>> +package t5.webresources.tests;
>>> +
>>> +import org.apache.tapestry5.SymbolConstants
>>> +import org.apache.tapestry5.internal.InternalSymbols
>>> +import org.apache.tapestry5.internal.test.PageTesterContext
>>> +import org.apache.tapestry5.internal.webresources.TypeScriptCompiler
>>> +import org.apache.tapestry5.ioc.MappedConfiguration
>>> +import org.apache.tapestry5.ioc.annotations.Autobuild
>>> +import org.apache.tapestry5.ioc.annotations.Inject
>>> +import org.apache.tapestry5.ioc.annotations.SubModule
>>> +import org.apache.tapestry5.ioc.internal.util.ClasspathResource
>>> +import org.apache.tapestry5.modules.AssetsModule
>>> +import org.apache.tapestry5.modules.TapestryModule
>>> +import org.apache.tapestry5.services.ApplicationGlobals
>>> +import org.apache.tapestry5.webresources.modules.WebResourcesModule
>>> +
>>> +import spock.lang.Shared
>>> +import spock.lang.Specification
>>> +
>>> +@SubModule([TapestryModule, WebResourcesModule,
>>> TypeScriptCompilerSpec.TestModule, AssetsModule])
>>> +class TypeScriptCompilerSpec extends Specification {
>>> +
>>> +  @Autobuild
>>> +  private TypeScriptCompiler typeScriptCompiler;
>>> +
>>> +  @Inject
>>> +  @Shared
>>> +  private ApplicationGlobals applicationGlobals
>>> +
>>> +  def setupSpec(){
>>> +    applicationGlobals.storeContext(new PageTesterContext("/test"));
>>> +  }
>>> +
>>> +  def "Compile Hello World example"(){
>>> +    when:
>>> +    def resource = new ClasspathResource("t5/webresources/greeter.ts")
>>> +    def compiled = typeScriptCompiler.transform(resource, null)
>>> +    then:
>>> +    compiled.text == TypeScriptCompilerSpec.class.g
>>> etResourceAsStream('/t5/webresources/greeter-compiled.js').text
>>> +  }
>>> +
>>> +  def "Type information is preserved"(){
>>> +    when:
>>> +    def resource = new ClasspathResource("t5/webresou
>>> rces/park-example.ts")
>>> +    def compiled = typeScriptCompiler.transform(resource, null)
>>> +    then:
>>> +    compiled.text == TypeScriptCompilerSpec.class.g
>>> etResourceAsStream('/t5/webresources/park-example-compiled.js').text
>>> +  }
>>> +
>>> +  public static class TestModule {
>>> +
>>> +    def contributeApplicationDefaults(MappedConfiguration
>>> configuration){
>>> +      configuration.add(InternalSymbols.APP_NAME, "test")
>>> +      configuration.add("tapestry.app-package", "typescript")
>>> +      configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
>>> +    }
>>> +  }
>>> +}
>>>
>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>> 1c9/tapestry-webresources/src/test/resources/t5/
>>> webresources/greeter-compiled.js
>>> ----------------------------------------------------------------------
>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/greeter-compiled.js
>>> b/tapestry-webresources/src/test/resources/t5/webresources/
>>> greeter-compiled.js
>>> new file mode 100644
>>> index 0000000..0794189
>>> --- /dev/null
>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>> greeter-compiled.js
>>> @@ -0,0 +1,8 @@
>>> +define(["require", "exports"], function (require, exports) {
>>> +    "use strict";
>>> +    function greeter(person) {
>>> +        return "Hello, " + person;
>>> +    }
>>> +    var user = "Jane User";
>>> +    document.body.innerHTML = greeter(user);
>>> +});
>>>
>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>> 1c9/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
>>> ----------------------------------------------------------------------
>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
>>> b/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
>>> new file mode 100644
>>> index 0000000..7fc2d1a
>>> --- /dev/null
>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
>>> @@ -0,0 +1,7 @@
>>> +function greeter(person) {
>>> +    return "Hello, " + person;
>>> +}
>>> +
>>> +var user = "Jane User";
>>> +
>>> +document.body.innerHTML = greeter(user);
>>> \ No newline at end of file
>>>
>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>> 1c9/tapestry-webresources/src/test/resources/t5/
>>> webresources/park-example-compiled.js
>>> ----------------------------------------------------------------------
>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/park-example-compiled.js
>>> b/tapestry-webresources/src/test/resources/t5/webresources/
>>> park-example-compiled.js
>>> new file mode 100644
>>> index 0000000..6d8e725
>>> --- /dev/null
>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>> park-example-compiled.js
>>> @@ -0,0 +1,26 @@
>>> +var __decorate = (this && this.__decorate) || function (decorators,
>>> target, key, desc) {
>>> +    var c = arguments.length, r = c < 3 ? target : desc === null ? desc
>>> = Object.getOwnPropertyDescriptor(target, key) : desc, d;
>>> +    if (typeof Reflect === "object" && typeof Reflect.decorate ===
>>> "function") r = Reflect.decorate(decorators, target, key, desc);
>>> +    else for (var i = decorators.length - 1; i >= 0; i--) if (d =
>>> decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target,
>>> key)) || r;
>>> +    return c > 3 && r && Object.defineProperty(target, key, r), r;
>>> +};
>>> +var __metadata = (this && this.__metadata) || function (k, v) {
>>> +    if (typeof Reflect === "object" && typeof Reflect.metadata ===
>>> "function") return Reflect.metadata(k, v);
>>> +};
>>> +define(["require", "exports"], function (require, exports) {
>>> +    "use strict";
>>> +    var Pterodactyls = /** @class */ (function () {
>>> +        function Pterodactyls() {
>>> +        }
>>> +        return Pterodactyls;
>>> +    }());
>>> +    var Park = /** @class */ (function () {
>>> +        function Park(x, y) {
>>> +        }
>>> +        Park = __decorate([
>>> +            Aviary,
>>> +            __metadata("design:paramtypes", [Pterodactyls, String])
>>> +        ], Park);
>>> +        return Park;
>>> +    }());
>>> +});
>>>
>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>> 1c9/tapestry-webresources/src/test/resources/t5/
>>> webresources/park-example.ts
>>> ----------------------------------------------------------------------
>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/park-example.ts
>>> b/tapestry-webresources/src/test/resources/t5/webresources/
>>> park-example.ts
>>> new file mode 100644
>>> index 0000000..ce9b4f2
>>> --- /dev/null
>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>> park-example.ts
>>> @@ -0,0 +1,6 @@
>>> +class Pterodactyls {}
>>> +
>>> +@Aviary
>>> +class Park {
>>> +  constructor(x: Pterodactyls, y: string) {}
>>> +}
>>> \ No newline at end of file
>>>
>>>
>>
>>
>> --
>> Thiago
>>
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: [1/3] tapestry-5 git commit: TAP5-2591: add support for TypeScript modules

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hello!

Why don't we do it before the first release with it? This way, we can avoid
possible result differences later.

On Fri, Dec 1, 2017 at 9:11 AM, Jochen Kemnade <jo...@eddyson.de>
wrote:

> Hi Thiago,
>
> Am 30.11.2017 um 17:19 schrieb Thiago H. de Paula Figueiredo:
>
>> Just one question: since 5.5 requires Java 8, couldn't we use its embedded
>> JavaScript support (Nashorn) instead of Mozilla's Rhino?
>>
>
> Yes, we could probably do that. But Rhino was already there, so I just
> used it. But I guess we can always switch to Nashorn later.
>
> Jochen
>
>
>> On Thu, Nov 30, 2017 at 2:12 PM, Thiago H. de Paula Figueiredo <
>> thiagohp@gmail.com> wrote:
>>
>> This is awesome! Thank you very much!
>>>
>>> On Mon, Nov 27, 2017 at 10:01 AM, <jk...@apache.org> wrote:
>>>
>>> Repository: tapestry-5
>>>> Updated Branches:
>>>>    refs/heads/master 80f65eb4b -> 0f2c01c9a
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>>> 1c9/tapestry-webresources/src/test/groovy/t5/webresources/
>>>> tests/TypeScriptCompilerSpec.groovy
>>>> ----------------------------------------------------------------------
>>>> diff --git a/tapestry-webresources/src/test/groovy/t5/webresources/test
>>>> s/TypeScriptCompilerSpec.groovy b/tapestry-webresources/src/te
>>>> st/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy
>>>> new file mode 100644
>>>> index 0000000..aafd30a
>>>> --- /dev/null
>>>> +++ b/tapestry-webresources/src/test/groovy/t5/webresources/test
>>>> s/TypeScriptCompilerSpec.groovy
>>>> @@ -0,0 +1,58 @@
>>>> +package t5.webresources.tests;
>>>> +
>>>> +import org.apache.tapestry5.SymbolConstants
>>>> +import org.apache.tapestry5.internal.InternalSymbols
>>>> +import org.apache.tapestry5.internal.test.PageTesterContext
>>>> +import org.apache.tapestry5.internal.webresources.TypeScriptCompiler
>>>> +import org.apache.tapestry5.ioc.MappedConfiguration
>>>> +import org.apache.tapestry5.ioc.annotations.Autobuild
>>>> +import org.apache.tapestry5.ioc.annotations.Inject
>>>> +import org.apache.tapestry5.ioc.annotations.SubModule
>>>> +import org.apache.tapestry5.ioc.internal.util.ClasspathResource
>>>> +import org.apache.tapestry5.modules.AssetsModule
>>>> +import org.apache.tapestry5.modules.TapestryModule
>>>> +import org.apache.tapestry5.services.ApplicationGlobals
>>>> +import org.apache.tapestry5.webresources.modules.WebResourcesModule
>>>> +
>>>> +import spock.lang.Shared
>>>> +import spock.lang.Specification
>>>> +
>>>> +@SubModule([TapestryModule, WebResourcesModule,
>>>> TypeScriptCompilerSpec.TestModule, AssetsModule])
>>>> +class TypeScriptCompilerSpec extends Specification {
>>>> +
>>>> +  @Autobuild
>>>> +  private TypeScriptCompiler typeScriptCompiler;
>>>> +
>>>> +  @Inject
>>>> +  @Shared
>>>> +  private ApplicationGlobals applicationGlobals
>>>> +
>>>> +  def setupSpec(){
>>>> +    applicationGlobals.storeContext(new PageTesterContext("/test"));
>>>> +  }
>>>> +
>>>> +  def "Compile Hello World example"(){
>>>> +    when:
>>>> +    def resource = new ClasspathResource("t5/webresources/greeter.ts")
>>>> +    def compiled = typeScriptCompiler.transform(resource, null)
>>>> +    then:
>>>> +    compiled.text == TypeScriptCompilerSpec.class.g
>>>> etResourceAsStream('/t5/webresources/greeter-compiled.js').text
>>>> +  }
>>>> +
>>>> +  def "Type information is preserved"(){
>>>> +    when:
>>>> +    def resource = new ClasspathResource("t5/webresou
>>>> rces/park-example.ts")
>>>> +    def compiled = typeScriptCompiler.transform(resource, null)
>>>> +    then:
>>>> +    compiled.text == TypeScriptCompilerSpec.class.g
>>>> etResourceAsStream('/t5/webresources/park-example-compiled.js').text
>>>> +  }
>>>> +
>>>> +  public static class TestModule {
>>>> +
>>>> +    def contributeApplicationDefaults(MappedConfiguration
>>>> configuration){
>>>> +      configuration.add(InternalSymbols.APP_NAME, "test")
>>>> +      configuration.add("tapestry.app-package", "typescript")
>>>> +      configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
>>>> +    }
>>>> +  }
>>>> +}
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>>> 1c9/tapestry-webresources/src/test/resources/t5/
>>>> webresources/greeter-compiled.js
>>>> ----------------------------------------------------------------------
>>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/
>>>> greeter-compiled.js
>>>> b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> greeter-compiled.js
>>>> new file mode 100644
>>>> index 0000000..0794189
>>>> --- /dev/null
>>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> greeter-compiled.js
>>>> @@ -0,0 +1,8 @@
>>>> +define(["require", "exports"], function (require, exports) {
>>>> +    "use strict";
>>>> +    function greeter(person) {
>>>> +        return "Hello, " + person;
>>>> +    }
>>>> +    var user = "Jane User";
>>>> +    document.body.innerHTML = greeter(user);
>>>> +});
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>>> 1c9/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
>>>> ----------------------------------------------------------------------
>>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/
>>>> greeter.ts
>>>> b/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
>>>> new file mode 100644
>>>> index 0000000..7fc2d1a
>>>> --- /dev/null
>>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> greeter.ts
>>>> @@ -0,0 +1,7 @@
>>>> +function greeter(person) {
>>>> +    return "Hello, " + person;
>>>> +}
>>>> +
>>>> +var user = "Jane User";
>>>> +
>>>> +document.body.innerHTML = greeter(user);
>>>> \ No newline at end of file
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>>> 1c9/tapestry-webresources/src/test/resources/t5/
>>>> webresources/park-example-compiled.js
>>>> ----------------------------------------------------------------------
>>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/
>>>> park-example-compiled.js
>>>> b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> park-example-compiled.js
>>>> new file mode 100644
>>>> index 0000000..6d8e725
>>>> --- /dev/null
>>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> park-example-compiled.js
>>>> @@ -0,0 +1,26 @@
>>>> +var __decorate = (this && this.__decorate) || function (decorators,
>>>> target, key, desc) {
>>>> +    var c = arguments.length, r = c < 3 ? target : desc === null ? desc
>>>> = Object.getOwnPropertyDescriptor(target, key) : desc, d;
>>>> +    if (typeof Reflect === "object" && typeof Reflect.decorate ===
>>>> "function") r = Reflect.decorate(decorators, target, key, desc);
>>>> +    else for (var i = decorators.length - 1; i >= 0; i--) if (d =
>>>> decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target,
>>>> key)) || r;
>>>> +    return c > 3 && r && Object.defineProperty(target, key, r), r;
>>>> +};
>>>> +var __metadata = (this && this.__metadata) || function (k, v) {
>>>> +    if (typeof Reflect === "object" && typeof Reflect.metadata ===
>>>> "function") return Reflect.metadata(k, v);
>>>> +};
>>>> +define(["require", "exports"], function (require, exports) {
>>>> +    "use strict";
>>>> +    var Pterodactyls = /** @class */ (function () {
>>>> +        function Pterodactyls() {
>>>> +        }
>>>> +        return Pterodactyls;
>>>> +    }());
>>>> +    var Park = /** @class */ (function () {
>>>> +        function Park(x, y) {
>>>> +        }
>>>> +        Park = __decorate([
>>>> +            Aviary,
>>>> +            __metadata("design:paramtypes", [Pterodactyls, String])
>>>> +        ], Park);
>>>> +        return Park;
>>>> +    }());
>>>> +});
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c0
>>>> 1c9/tapestry-webresources/src/test/resources/t5/
>>>> webresources/park-example.ts
>>>> ----------------------------------------------------------------------
>>>> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/
>>>> park-example.ts
>>>> b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> park-example.ts
>>>> new file mode 100644
>>>> index 0000000..ce9b4f2
>>>> --- /dev/null
>>>> +++ b/tapestry-webresources/src/test/resources/t5/webresources/
>>>> park-example.ts
>>>> @@ -0,0 +1,6 @@
>>>> +class Pterodactyls {}
>>>> +
>>>> +@Aviary
>>>> +class Park {
>>>> +  constructor(x: Pterodactyls, y: string) {}
>>>> +}
>>>> \ No newline at end of file
>>>>
>>>>
>>>>
>>>
>>> --
>>> Thiago
>>>
>>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>


-- 
Thiago