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

Add back typescript version number and add Deno.version object. #1788

Merged
merged 7 commits into from Feb 18, 2019

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Feb 16, 2019

This is a continuation of #1676. This adds back the printing of typescript version number.
This also addresses the comment:

t would be good to have access to the versions in the runtime environment - maybe that can be done as part of this work... deno.version.v8 for example would be nice to have.

This PR uses rollup-plugin-replace for embedding typescript version in the bundle.


depends on denoland/deno_third_party#33

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

Couple comments.

Also the diff is pulling in sourcemap-codec into third_party/node_modules and I am not sure why. Seems like something we don't want/need in the project.

js/version.ts Outdated
@@ -0,0 +1,15 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// tslint:disable-next-line:no-reference
/// <reference path="./const.d.ts" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this, I would just add it to the globals in globals.ts:

deno/js/globals.ts

Lines 35 to 38 in 4dc4329

declare global {
const console: consoleTypes.Console;
const setTimeout: typeof timers.setTimeout;
}

Then you won't need an additional type declaration file.

Copy link
Member Author

Choose a reason for hiding this comment

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

The situation seems a little tricky here. rollup-plugin-replace replaces the occurence even in type declaration. So const TS_VERSION: string becomes const "3.2.1": string; before passed to typescript.

I found that rollup-plugin-replace doesn't do any parsing of the source code. So we can do something like: { version: "TS_VERSION" }. This seems better because it doesn't require any type declaration. So I swtich to this pattern.

js/main.ts Outdated
@@ -24,12 +25,14 @@ export default function denoMain() {
libdeno.builtinModules["deno"] = deno;
Object.freeze(libdeno.builtinModules);

version.deno = startResMsg.denoVersion();
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider adding a set function that is exported from version.ts and marked @internal to do the setting, like we have with setEnv() now. This will make it more maintainable in the long term and keep logic out of here. And setVersions() should freeze the version object too.

@kt3k
Copy link
Member Author

kt3k commented Feb 16, 2019

@kitsonk

the diff is pulling in sourcemap-codec into third_party/node_modules and I am not sure why. Seems like something we don't want/need in the project.

rollup-plugin-replace@2.1.0 depends on magic-string@^0.25.1.
magic-string seems depending on sourcemap-codec since v0.23.0 Rich-Harris/magic-string#133

If we pinned the version of rollup-plugin-replace to v2.0.0 which depends magic-string@^0.22.4, we would remove sourcemap-codec dependecy. But I'm not sure that is the desired solution.

This doesn't need any type declartion
Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

One final comment.

I understand the sourcemap-codec as well now, so am ok with that.

};

/**
* Sets the deno and v8 versions and freezes the version object.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would set this to @internal so it doesn't get leaked to the runtime type library.

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

LGTM

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 - this is great to have back - and also Deno.version - thank you!

@ry ry merged commit 55edc06 into denoland:master Feb 18, 2019
@kt3k kt3k deleted the feature/ts-version branch January 21, 2020 17:17
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.

None yet

3 participants