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 for -v flag using package.json info #1676

Closed
wants to merge 1 commit into from

Conversation

kevinkassimo
Copy link
Contributor

Similar to the way we pass deno crate version

@kevinkassimo kevinkassimo changed the title Add back TypeScript version for -v flags using package.json info Add back TypeScript version for -v flag using package.json info Feb 4, 2019
@@ -129,6 +129,11 @@ deno_cargo_info = exec_script("build_extra/rust/get_cargo_info.py",
[ rebase_path("Cargo.toml", root_build_dir) ],
"json")

# Reads the typescript info from package.json
deno_ts_info = exec_script("build_extra/rust/get_ts_info.py",
Copy link
Member

Choose a reason for hiding this comment

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

Hrm. This works, but it's kinda ad hoc... We have a similar situation with deno.platform where we need to inject some information into the build. It's done using rollup here:

deno/rollup.config.js

Lines 92 to 124 in 748b0f9

/** Inject deno.platform.arch and deno.platform.os
* @param {any} param0
*/
function platform({ include, exclude } = {}) {
if (!include) {
throw new Error("include option must be passed");
}
const filter = createFilter(include, exclude);
return {
name: "platform",
/**
* @param {any} _code
* @param {string} id
*/
transform(_code, id) {
if (filter(id)) {
// Adapted from https://github.com/rollup/rollup-plugin-inject/blob/master/src/index.js
const arch = archNodeToDeno[process.arch];
const os = osNodeToDeno[process.platform];
// We do not have to worry about the interface here, because this is just to generate
// the actual runtime code, not any type information integrated into Deno
const magicString = new MagicString(`
export const platform = { arch: "${arch}", os:"${os}" };`);
return {
code: magicString.toString(),
map: magicString.generateMap()
};
}
}
};
}

What do you think about doing something similar for the TS version?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think that makes much more sense, though it sort of would be great not to have to go to JavaScript at all, the other two strings exist in Rust already and we pass it to JS to just print it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it should also work (this platform injection was also done by me quite a while ago). Probably we can centralize all the injected variables during build in a single file (to avoid being too messy in the future when we possibly also inject other stuff)? I'll go and work on that if sound okay.

Another problem I realized with GN injection is that it would not work with cargo build, unless specially handled in build.rs...

Copy link
Member

Choose a reason for hiding this comment

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

though it sort of would be great not to have to go to JavaScript at all

I don't think that's worth optimizing for.

Another problem I realized with GN injection is that it would not work with cargo build, unless specially handled in build.rs...

Good point

It 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.

Copy link
Member

@kt3k kt3k Feb 7, 2019

Choose a reason for hiding this comment

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

How about using rollup-plugin-replace for embedding the version number in script? The plugin can replace certain types of symbols in scripts with the supplied values.

@kt3k
Copy link
Member

kt3k commented Feb 15, 2019

I did a simple experiment using rollup-plugin-replace on my fork. It seems working and this looks a little simpler than this patch (the diff is +11,-2).

@kevinkassimo @ry
If you're ok, I'd like to continue work on this issue on my branch.

@kevinkassimo
Copy link
Contributor Author

kevinkassimo commented Feb 15, 2019

@kt3k SGTM. I'll close this once you have your PR set up.

@kevinkassimo
Copy link
Contributor Author

Closed in favor of #1788

@kevinkassimo kevinkassimo deleted the flags/ts_version branch December 27, 2019 07:51
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

4 participants