rttist / examples

Set of examples in React, Angular, vanilla TS, Webpack, Parcel, Rollup etc. with configured reflection.
MIT License
0 stars 2 forks source link

Examples don't work? #2

Open mindplay-dk opened 1 year ago

mindplay-dk commented 1 year ago

I checked out the example repo - as mentioned here, I can't get it to work.

Is this example supposed to work? I was able to run it, but both URLs return an empty response.

Do you have any working examples that currently run?

Are there any specific requirements to get them running? You didn't check in your package-lock.json, so I might be getting some newer dependencies that don't work anymore?

I also noticed this in the main repo, which looks similar and newer, but doesn't seem to have the route function?

I tried adding this line to registerControllers:

console.log(Metadata.getTypes().map(t => t.id));

It looks like only the built-in types can be reflected:

[
  '::invalid::Invalid',
  '::native::any',
  '::native::unknown',
  '::native::void',
  '::native::never',
  '::native::null',
  '::native::undefined',
  '::native::object',
  '::native::String',
  '::native::Number',
  '::native::BigInt',
  '::native::Boolean',
  '::native::true',
  '::native::false',
  '::native::Date',
  '::native::Error',
  '::native::Symbol',
  '::native::UniqueSymbol',
  '::native::RegExp',
  '::native::Int8Array',
  '::native::Uint8Array',
  '::native::Uint8ClampedArray',
  '::native::Int16Array',
  '::native::Uint16Array',
  '::native::Int32Array',
  '::native::Uint32Array',
  '::native::Float32Array',
  '::native::Float64Array',
  '::native::BigInt64Array',
  '::native::BigUint64Array',
  '::native::ArrayBuffer',
  '::native::SharedArrayBuffer',
  '::native::Atomics',
  '::native::DataView',
  '::native::Array{::native::Any}',
  '::native::Function'
]

I checked against reflection.config.json and tsconfig.json in dev/hookyns/2 in the main repo and tried a bunch of different settings - no luck, but I also don't see anything that looks wrong to me.

Also updated from alpha.6 to alpha.7 release.

Really excited to try this out, but no idea what else to try...

mindplay-dk commented 1 year ago

I also tried to run dev/hookyns/2, following instructions here, and this doesn't work either.

At npx ttsc, it fails with error messages like the following:

framework/Router.ts:12:38 - error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './controllers/IController.js'?

12 import { IController }          from "./controllers/IController";
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~

I tried adding the .js extensions, and was able to run it - and it says it's producing types:

[DEV] tst-reflect-transformer Completed! 
        Initialization:  0.06423  sec. 
        Type discovery and transformations:  0.00019  sec. 
        Serialization and emitting of metadata:  0.20191  sec. 
        Total time:  0.26634  sec. 
        Processed  191  type(s) from  18  module(s).  

The version in the examples repo never displayed this message.

However, it also doesn't work, and with the added console.log statement from above:

[
  '::invalid::Invalid',
  '::native::any',
  '::native::unknown',
  '::native::void',
  '::native::never',
  '::native::null',
  '::native::undefined',
  '::native::object',
  '::native::String',
  '::native::Number',
  '::native::BigInt',
  '::native::Boolean',
  '::native::true',
  '::native::false',
  '::native::Date',
  '::native::Error',
  '::native::Symbol',
  '::native::UniqueSymbol',
  '::native::RegExp',
  '::native::Int8Array',
  '::native::Uint8Array',
  '::native::Uint8ClampedArray',
  '::native::Int16Array',
  '::native::Uint16Array',
  '::native::Int32Array',
  '::native::Uint32Array',
  '::native::Float32Array',
  '::native::Float64Array',
  '::native::BigInt64Array',
  '::native::BigUint64Array',
  '::native::ArrayBuffer',
  '::native::SharedArrayBuffer',
  '::native::Atomics',
  '::native::DataView',
  '::native::Array{::native::Any}',
  '::native::Function'
]

It looks like there are still no reflections available at run-time.

Hookyns commented 1 year ago

Latest versions of TS, webpack, ts-loader and a lot of other tools does not work properly as I mentioned in the #7 Alpha issue it's the reason why I stoped working on the current Alpha and jumped right on the solution planned for 2024.

This StackBlitz example from the rttist.org website works. Try it out.

Here is StackBlitz example with decorators.

And here I get up and running the "MVC" example. I found out that tst-reflect-transformer@1.0.0-alpha.11 is broken but version alpha.10 (tst-reflect-transformer@1.0.0-alpha.11) works just fine.

mindplay-dk commented 1 year ago

Note that there are still other examples that don't work.

I haven't tested all of them, but I suspect this one is the only one that works right now.

I'm sure all the examples will need adjustments when you start making some of the bigger changes, but it might be a good idea to leave this issue open for other testers to notice.