Skip to content
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

Remove msg_generated hack #409

Merged
merged 3 commits into from
Jul 26, 2018
Merged

Remove msg_generated hack #409

merged 3 commits into from
Jul 26, 2018

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Jul 25, 2018

Resolves #403

It mostly makes it maintainable. TypeScript still wants to resolve the msg_generated itself to be type safe. So we had to go away from a relative MID and go to an absolute and then map that absolute to resolve to the generated modules (ergo the paths in the tsconfig.json now). It also means we have to pick a resolution order. It also means that an editor, like VSCode, will error until at least one msg_generated.ts is generated.

We also had to generate another bit of logic in the rollup.config.js to resolve the module at bundle time properly.

I think I cleaned up all the hackery.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you!

tsconfig.json Outdated
"experimentalDecorators": true
"experimentalDecorators": true,
"paths": {
"*": [ "*", "out/debug/gen/*", "out/default/gen/*", "out/release/gen/*" ]
Copy link
Member

@ry ry Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build path isn't guaranteed to look like these. On travis, for example, we use $HOME/out/Default (capitalization intentional)

I suppose this is what's causing travis to fail. Try building with ./tools/build.py --build_path=/tmp/deno_build to debug. Can we somehow tell TS to just ignore msg_generated ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with "ignoring" it is that it is hacky and also stop TypeScript from ensuring that it is used type safe, which seems contrary to the whole thing.

What I could do, is keep this for design time editors, but in the rollup.config.js is dynamically use the build path when compiling the bundle. Not sure why I didn't think of that first.

rollup.config.js Outdated
resolveId(importee) {
if (importee === "msg_generated") {
return path.resolve(
path.join(process.cwd(), "gen", "msg_generated.ts")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works. It's a little hacky to hardcode "gen/msg_generated.ts" but much better than what we previously had. Consider adding a comment about how this path could change if BUILD.gn was updated...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. This may not be the only generated asset that ends up in the bundle, so I should change it to be a more generic too. So that any MID that starts with gen/* gets remapped to the current build directory.

":msg_ts",
]
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice.

@kitsonk
Copy link
Contributor Author

kitsonk commented Jul 26, 2018

I think I got everything squared away and it feels a lot more maintainable now, than trading one ugly hack for a less ugly hack.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you!

@ry ry merged commit 5562c36 into denoland:master Jul 26, 2018
@kitsonk kitsonk deleted the msg_generated branch July 27, 2018 01:12
piscisaureus pushed a commit to piscisaureus/deno that referenced this pull request Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove js/msg_generated.ts from repo
2 participants