-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[TS/JS] New gen TS code gen #6302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This is a good first step. Next would be splitting per table as java does? |
|
@krojew yep might be, I've added a TODO list in the issue description. |
|
How's it going? Do you need any help? |
|
@krojew afraid I still haven't gotten free time for it, if you want to get started now please do! I aim to get some alone and free time in xmax holidays to possibly pick this up so somewhere 25-30 december. Keep me in the loop. :) |
|
@krojew will try to get somewhere with this today. What's your status? |
|
I haven't managed to get any free time to work on this yet. But at least, I think we know how to proceed - remove JS support and output a file per table, as Java does. This implies no more |
de8b0bd to
707d2c1
Compare
|
I'm slowly realizing this will require more than just simple tweaks to existing code and I'm unfortunately quite far from being able to get somewhere. Ideally I would like to have a better setup/testing story than to compile, run the flatc binary and inspect output. |
|
I think we should keep kebab case, since we would cause problems for Angular users otherwise. |
|
@krojew ok I have no strong opinion so agreed. |
|
@krojew getting somewhere, now generating separate files in kebab case. (still large amount of work remaining on actual code output though) |
|
For future reference this is what imports could look like: import { SIZE_PREFIX_LENGTH } from '../../js/constants'
import { Long, createLong } from '../../js/long'
import { Offset, Table } from '../../js/types'
import { Builder } from '../../js/builder'
import { ByteBuffer } from '../../js/byte-buffer'
import { Encoding } from '../../js/encoding' |
|
@krojew any ideas on how to alias flatbuffers imports? A |
|
I suggest |
|
@krojew output looks promising now however not really tested at this point. Feel free to do an early review. |
|
@krojew instead of |
krojew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also remove JS-specific flags.
tests/tsconfig.json
Outdated
| "target": "ES6", | ||
| "lib": ["ES2015", "ES2020.BigInt", "DOM"], | ||
| "noImplicitAny": false, | ||
| "strict": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test for maxium strict support.
|
@krojew I'm not 100% confident about my approach to import tracking and namespace aliasing when needed which replaces the need for prefix/namespace wrappings. But I've just now verified it seems to be working in my external project where the end result bundle ends up almost 40% smaller so that's a nice side-effect of this work. |
|
I would need to see regenerated test files to have an opinion. Right now, it's hard to see what the actual output is. |
This comment has been minimized.
This comment has been minimized.
82cee47 to
638b5e4
Compare
|
Rebased with more success (I sure hope so). |
|
@aardappel can you merge? |
|
@aardappel any news on this? |
|
Thanks for all the hard work :) |
| opts.natural_utf8 = true; | ||
| } else if (arg == "--no-js-exports") { | ||
| opts.skip_js_exports = true; | ||
| } else if (arg == "--goog-js-export") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work now? I have a bunch of users internally who are setting this flag and it no longer is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjornharrtell it is hard for me to see what changed here since it such a big merge. how does --goog-js-export work now that the flag is removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems unwise to have removed that flag or any code related to it, since we couldn't test that externally. Apologies if I didn't spot that during this huge PR and huge review..
But this has been merged for a while now, so all we can do is try and fix this forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory is vague at this point but I think the general idea was that TS is the only target and exports using es modules. If someone needs another module format they'd have to transpile it themselves.
Modernize TS/JS code gen by doing a reworked TS only code gen.
TODO
Documentation
Compiler.md,JavaScriptUsage.md,Tutorial.mdandjavascript_sample.shTODO (undecided)