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 import.meta.main #1835

Merged
merged 9 commits into from Feb 26, 2019

Conversation

3 participants
@bartlomieju
Copy link
Contributor

bartlomieju commented Feb 24, 2019

Closes #1834

I tried to move ImportMeta declaration to separate, however TS was crushing then, I'll investigate that tomorrow.

I had also test in C++, but it felt duplicated with TS test.

bartlomieju added some commits Feb 24, 2019

@kitsonk

This comment has been minimized.

Copy link
Contributor

kitsonk commented Feb 24, 2019

As this stands at the moment, it won't flow through to the runtime type library. (If you do deno --types you will see it is missing).

The interface is already a global interface (interface ImportMeta {}) as it has been reserved in the language for a long time. We need to extend this interface in the global scope, which is what happens when it is located in lib.web_assembly.d.ts file as that is simply inlined in the runtime type library, but that isn't the "right" way to do it for extending this in the long term. I think it is better that we put this directly in the globals.ts, the only problem is that we need to change ts_library_builder in the mergeGlobal function to copy over any interfaces there into the type library.

That is a bit complicated, so if you wanted to, just move it back to the web assembly library, and then I can do a follow up PR making the change to ts_library_builder. Otherwise you can try to tackle it. It should be added somewhere around here and needs to be done is iterate over any interfaces, ensuring it weeds out the special global interface and adds those to the target.

Show resolved Hide resolved libdeno/binding.cc Outdated
@bartlomieju

This comment has been minimized.

Copy link
Contributor Author

bartlomieju commented Feb 25, 2019

@kitsonk actually I get:

$ deno --types | grep -i importmeta -A 3 -B 3
// @url js/lib.import_meta.d.ts

interface ImportMeta {
  url: string;
  main: boolean;
}

EDIT: Okay I reread your comment and understand the problem. Let's tackle it in another PR.

@ry

This comment has been minimized.

Copy link
Collaborator

ry commented Feb 25, 2019

Maybe we can add an argument to deno_mod_new() to tell if it's main...

@bartlomieju

This comment has been minimized.

Copy link
Contributor Author

bartlomieju commented Feb 25, 2019

@ry I can then place it in ModuleInfo - ModuleInfo.main?

@ry

This comment has been minimized.

Copy link
Collaborator

ry commented Feb 25, 2019

@bartlomieju yes that makes sense to me

@bartlomieju

This comment has been minimized.

Copy link
Contributor Author

bartlomieju commented Feb 25, 2019

@ry not super happy because there's a lot of bool flags passing but it got job done

Show resolved Hide resolved BUILD.gn Outdated
Show resolved Hide resolved libdeno/modules_test.cc Outdated
Show resolved Hide resolved libdeno/modules_test.cc Outdated
@ry
Copy link
Collaborator

ry left a comment

Nice work! Just a few comments.

@bartlomieju

This comment has been minimized.

Copy link
Contributor Author

bartlomieju commented Feb 26, 2019

@ry changes applied

Show resolved Hide resolved js/lib.web_assembly.d.ts Outdated
deno_mod_evaluate(d, d, throw_main);
EXPECT_EQ(nullptr, deno_last_exception(d));

deno_delete(d);

This comment has been minimized.

@ry

ry Feb 26, 2019

Collaborator

Nice test!

bartlomieju and others added some commits Feb 26, 2019

@bartlomieju

This comment has been minimized.

Copy link
Contributor Author

bartlomieju commented Feb 26, 2019

Thanks @ry, somehow missed that file...

@ry

ry approved these changes Feb 26, 2019

Copy link
Collaborator

ry left a comment

LGTM : )

@ry ry merged commit 5dfbbbb into denoland:master Feb 26, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@bartlomieju bartlomieju deleted the bartlomieju:meta_main branch Feb 26, 2019

@MylesBorins MylesBorins referenced this pull request Feb 26, 2019

Open

import.meta.main #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.