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

Comment out export * statements #2

Closed
pozhidaevak opened this issue Nov 20, 2018 · 7 comments
Closed

Comment out export * statements #2

pozhidaevak opened this issue Nov 20, 2018 · 7 comments

Comments

@pozhidaevak
Copy link
Contributor

Export statements like export * from "file" should be commented out as they are translated to code with require() that is not supported by google script
However export val and export function seem to work fine.

@grant also suggested to comment out __export()

Will try to create a PR for this issue...

@pozhidaevak
Copy link
Contributor Author

pozhidaevak commented Nov 20, 2018

@grant , can you please explain why __export() should be also commented?
In my case __export() apears only after translation. Are there cases there it can be used before translation?
I added commenting of only export ... from ... and it works fine

v--TS--v
export * from 'file'
–––
var exports = exports || {};
var module = module || { exports: exports };
// export * from 'file'
 ^--GS--^

@grant
Copy link
Owner

grant commented Nov 20, 2018

@pozhidaevak I'm really not sure what the case would be. __export is not valid in Apps Script of course.

Can you provide example expected INPUT and OUTPUT code?

@pozhidaevak
Copy link
Contributor Author

@grant It is kind of follow up of this issue
On that issue, you suggested to comment __export but __export is actually in the OUTPUT when export is in INPUT. So I don't see why __export should be commented... I think there is no use case for __export be in the input. But I'm new to js so I may be wrong...
Both input and output are presented in original issue

@grant
Copy link
Owner

grant commented Nov 20, 2018

So ts2gas work like:

  • Take ts
  • Transpile to gs
  • Add this line to fix export errors:
var exports = exports || {};
var module = module || { exports: exports };

I think we may need to additionally test that export * transpiling works.

  • Add some tests
  • Add any necessary transforms.

@pozhidaevak
Copy link
Contributor Author

@grant , I thought you were ok with me just commenting out export * in input for ts2gas.
Here is how it looks:

v--TS--v
export * from 'file'
–––
var exports = exports || {};
var module = module || { exports: exports };
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}

__export(require("file"));
 ^--GS--^

the result is not valid due to require()

so I want to make it look like

v--TS--v
export * from 'file'
–––
var exports = exports || {};
var module = module || { exports: exports };
// export * from 'file'
 ^--GS--^

@grant
Copy link
Owner

grant commented Nov 20, 2018

@pozhidaevak, Yes, commenting export * before transpiling sounds good. I haven't tried it.

@grant grant changed the title Comment out export statements Comment out export * statements Nov 20, 2018
@grant
Copy link
Owner

grant commented Nov 21, 2018

Published with ca542f2.

@grant grant closed this as completed Nov 21, 2018
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

No branches or pull requests

2 participants